]> git.tdb.fi Git - r2c2.git/blob - source/engineer/engineer.h
Complete rewrite of the engineer UI
[r2c2.git] / source / engineer / engineer.h
1 #ifndef ENGINEER_H_
2 #define ENGINEER_H_
3
4 #include <msp/core/application.h>
5 #include <msp/graphics/simplewindow.h>
6 #include <msp/gl/camera.h>
7 #include <msp/gl/light.h>
8 #include <msp/gl/lighting.h>
9 #include <msp/gl/pipeline.h>
10 #include <msp/gltk/resources.h>
11 #include <msp/gltk/root.h>
12 #include "libr2c2/catalogue.h"
13 #include "libr2c2/train.h"
14 #include "3d/layout.h"
15 #include "3d/overlay.h"
16 #include "3d/path.h"
17 #include "network/server.h"
18 #include "options.h"
19
20 class MainWindow;
21 class TrainView;
22
23 class Engineer: public Msp::RegisteredApplication<Engineer>
24 {
25 public:
26         sigc::signal<void, R2C2::Track *, int> signal_pick_done;
27
28 private:
29         Options options;
30
31         Msp::Graphics::SimpleGLWindow window;
32         Msp::Input::Keyboard keyboard;
33         Msp::Input::Mouse mouse;
34         Msp::GLtk::Resources ui_res;
35         Msp::GLtk::Root *root;
36
37         R2C2::Catalogue catalogue;
38         R2C2::Layout layout;
39         R2C2::Layout3D layout_3d;
40         R2C2::Server *server;
41         Msp::IO::EventDispatcher event_disp;
42         R2C2::Overlay3D *overlay;
43         std::map<R2C2::Train *, Msp::GL::Color> train_colors;
44
45         Msp::GL::Camera camera;
46         Msp::GL::Lighting lighting;
47         Msp::GL::Light light;
48         Msp::GL::Pipeline pipeline;
49         Msp::GL::Mesh arrow_mesh;
50
51         MainWindow *main_wnd;
52         std::list<R2C2::Train *> new_trains;
53         std::list<TrainView *> train_views;
54         Msp::Time::TimeStamp status_timeout;
55         bool picking;
56         R2C2::Track *picking_track;
57         int picking_entry;
58         R2C2::Path3D *picking_path;
59         R2C2::Vector pointer;
60         bool pointer_moved;
61
62 public:
63         Engineer(int argc, char **argv);
64         ~Engineer();
65
66         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
67         Msp::GLtk::Root &get_root() const { return *root; }
68         const R2C2::Catalogue &get_catalogue() const { return catalogue; }
69         R2C2::Layout &get_layout() { return layout; }
70         R2C2::Layout3D &get_layout_3d() { return layout_3d; }
71         const Msp::GL::Lighting &get_lighting() const { return lighting; }
72         void set_status(const std::string &);
73         void add_train_view(TrainView &);
74         void remove_train_view(TrainView &);
75         void pick(bool);
76         int main();
77         void quit() { exit(0); }
78 private:
79         void tick();
80         void button_press(unsigned);
81         void axis_motion(unsigned, float, float);
82         void view_all();
83         void set_block_color(const R2C2::Block &, const Msp::GL::Color &);
84         void reset_block_color(const R2C2::Block &);
85         void sensor_event(unsigned, bool);
86         void block_reserved(const R2C2::Block &, const R2C2::Train *);
87         R2C2::Object *pick_object(const R2C2::Vector &);
88         void train_added(R2C2::Train &);
89         void process_new_train(R2C2::Train &);
90         virtual void sighandler(int);
91 };
92
93 #endif