]> git.tdb.fi Git - r2c2.git/blob - source/engineer/engineer.h
Only pick once per rendered frame
[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 TrainProperties;
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         Msp::Time::TimeStamp status_timeout;
60         bool picking;
61         Marklin::Track *picking_track;
62         int picking_entry;
63         Marklin::Path3D *picking_path;
64         int pointer_x;
65         int pointer_y;
66         bool pointer_moved;
67
68 public:
69         Engineer(int argc, char **argv);
70         ~Engineer();
71
72         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
73         Msp::GLtk::Root &get_root() const { return *root; }
74         const Marklin::Catalogue &get_catalogue() const { return catalogue; }
75         Marklin::Layout &get_layout() { return layout; }
76         void set_status(const std::string &);
77         void pick(bool);
78         int main();
79         void quit() { exit(0); }
80 private:
81         void tick();
82         void button_press(int, int, unsigned, unsigned);
83         void pointer_motion(int, int);
84         void view_all();
85         void set_block_color(const Marklin::Block &, const Msp::GL::Color &);
86         void reset_block_color(const Marklin::Block &);
87         void sensor_event(unsigned, bool);
88         void block_reserved(const Marklin::Block &, const Marklin::Train *);
89         Marklin::Track3D *pick_track(int, int);
90         void train_added(Marklin::Train &);
91         virtual void sighandler(int);
92
93         static Msp::Application::RegApp<Engineer> reg;
94 };
95
96 #endif