]> git.tdb.fi Git - r2c2.git/blob - source/engineer/engineer.h
48d60a2df9ae82679c75615852ed86d6f3c9aaf3
[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 "network/server.h"
24 #include "options.h"
25
26 class MainPanel;
27 class TrainPanel;
28 class TrainProperties;
29
30 class Engineer: public Msp::Application
31 {
32 private:
33         Options options;
34
35         Msp::Graphics::SimpleGLWindow window;
36         Msp::GLtk::Resources ui_res;
37         Msp::GLtk::Root *root;
38
39         Marklin::Catalogue catalogue;
40         Marklin::Layout layout;
41         Marklin::Layout3D layout_3d;
42         Marklin::Server *server;
43         Msp::IO::EventDispatcher event_disp;
44         Marklin::Overlay3D *overlay;
45         std::map<Marklin::Train *, Msp::GL::Color> train_colors;
46
47         Msp::GL::Camera camera;
48         Msp::GL::Lighting lighting;
49         Msp::GL::Light light;
50         Msp::GL::Pipeline pipeline;
51         Msp::GL::Mesh arrow_mesh;
52
53         MainPanel *main_panel;
54         std::list<TrainPanel *> train_panels;
55         Marklin::Train *placing_train;
56         Marklin::Block *placing_block;
57         unsigned placing_entry;
58
59 public:
60         Engineer(int argc, char **argv);
61         ~Engineer();
62
63         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
64         Msp::GLtk::Root &get_root() const { return *root; }
65         const Marklin::Catalogue &get_catalogue() const { return catalogue; }
66         Marklin::Layout &get_layout() { return layout; }
67         void place_train(Marklin::Train &);
68         int main();
69         void quit() { exit(0); }
70 private:
71         void tick();
72         void button_press(int, int, unsigned, unsigned);
73         void pointer_motion(int, int);
74         void view_all();
75         void set_block_color(const Marklin::Block &, const Msp::GL::Color &);
76         void reset_block_color(const Marklin::Block &);
77         void sensor_event(unsigned, bool);
78         void block_reserved(const Marklin::Block &, const Marklin::Train *);
79         Marklin::Track3D *pick_track(int, int);
80         void train_added(Marklin::Train &);
81         virtual void sighandler(int);
82
83         static Msp::Application::RegApp<Engineer> reg;
84 };
85
86 #endif