]> git.tdb.fi Git - r2c2.git/blob - source/engineer/engineer.h
61a2f59e37730c53e88a87bccbfd26bda1ea6abc
[r2c2.git] / source / engineer / engineer.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef ENGINEER_H_
9 #define ENGINEER_H_
10
11 #include <msp/core/application.h>
12 #include <msp/gbase/simplewindow.h>
13 #include <msp/gl/camera.h>
14 #include <msp/gl/light.h>
15 #include <msp/gl/lighting.h>
16 #include <msp/gl/pipeline.h>
17 #include <msp/gltk/resources.h>
18 #include <msp/gltk/root.h>
19 #include "libmarklin/catalogue.h"
20 #include "libmarklin/train.h"
21 #include "3d/layout.h"
22 #include "3d/overlay.h"
23 #include "3d/path.h"
24 #include "network/server.h"
25 #include "options.h"
26
27 class MainPanel;
28 class TrainPanel;
29 class TrainView;
30
31 class Engineer: public Msp::Application
32 {
33 public:
34         sigc::signal<void, Marklin::Track *, int> signal_pick_done;
35
36 private:
37         Options options;
38
39         Msp::Graphics::SimpleGLWindow window;
40         Msp::GLtk::Resources ui_res;
41         Msp::GLtk::Root *root;
42
43         Marklin::Catalogue catalogue;
44         Marklin::Layout layout;
45         Marklin::Layout3D layout_3d;
46         Marklin::Server *server;
47         Msp::IO::EventDispatcher event_disp;
48         Marklin::Overlay3D *overlay;
49         std::map<Marklin::Train *, Msp::GL::Color> train_colors;
50
51         Msp::GL::Camera camera;
52         Msp::GL::Lighting lighting;
53         Msp::GL::Light light;
54         Msp::GL::Pipeline pipeline;
55         Msp::GL::Mesh arrow_mesh;
56
57         MainPanel *main_panel;
58         std::list<TrainPanel *> train_panels;
59         std::list<TrainView *> train_views;
60         Msp::Time::TimeStamp status_timeout;
61         bool picking;
62         Marklin::Track *picking_track;
63         int picking_entry;
64         Marklin::Path3D *picking_path;
65         int pointer_x;
66         int pointer_y;
67         bool pointer_moved;
68
69 public:
70         Engineer(int argc, char **argv);
71         ~Engineer();
72
73         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
74         Msp::GLtk::Root &get_root() const { return *root; }
75         const Marklin::Catalogue &get_catalogue() const { return catalogue; }
76         Marklin::Layout &get_layout() { return layout; }
77         Marklin::Layout3D &get_layout_3d() { return layout_3d; }
78         const Msp::GL::Lighting &get_lighting() const { return lighting; }
79         void set_status(const std::string &);
80         void rearrange_panels();
81         void add_train_view(TrainView &);
82         void remove_train_view(TrainView &);
83         void pick(bool);
84         int main();
85         void quit() { exit(0); }
86 private:
87         void tick();
88         void button_press(int, int, unsigned, unsigned);
89         void pointer_motion(int, int);
90         void view_all();
91         void set_block_color(const Marklin::Block &, const Msp::GL::Color &);
92         void reset_block_color(const Marklin::Block &);
93         void sensor_event(unsigned, bool);
94         void block_reserved(const Marklin::Block &, const Marklin::Train *);
95         Marklin::Track3D *pick_track(int, int);
96         void train_added(Marklin::Train &);
97         virtual void sighandler(int);
98
99         static Msp::Application::RegApp<Engineer> reg;
100 };
101
102 #endif