]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
Add an internal layout to Catalogue for selecting tracks
[r2c2.git] / source / designer / designer.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef DESIGNER_H_
9 #define DESIGNER_H_
10
11 #include <string>
12 #include <msp/core/application.h>
13 #include <msp/gbase/simplewindow.h>
14 #include <msp/gl/font.h>
15 #include <msp/gl/light.h>
16 #include <msp/gl/lighting.h>
17 #include <msp/gl/object.h>
18 #include <msp/gl/pipeline.h>
19 #include <msp/gltk/label.h>
20 #include <msp/gltk/resources.h>
21 #include <msp/gltk/root.h>
22 #include <msp/time/timestamp.h>
23 #include "libmarklin/catalogue.h"
24 #include "libmarklin/layout.h"
25 #include "3d/layout.h"
26 #include "3d/track.h"
27 #include "manipulator.h"
28 #include "measure.h"
29 #include "selection.h"
30
31 class Input;
32 class Toolbar;
33
34 class Designer: public Msp::Application
35 {
36 private:
37         enum Mode
38         {
39                 SELECT,
40                 CATALOGUE,
41                 MANIPULATE,
42                 MEASURE,
43                 INPUT
44         };
45
46         Msp::Graphics::SimpleGLWindow window;
47         Msp::GLtk::Resources ui_res;
48         Msp::GLtk::Root *root;
49
50         Toolbar *toolbar;
51         Msp::GLtk::Label *lbl_tooltip;
52         Msp::Time::TimeStamp tooltip_timeout;
53
54         Marklin::Catalogue catalogue;
55         Marklin::Layout3D *cat_layout_3d;
56         std::string filename;
57         Marklin::Layout *layout;
58         Marklin::Layout3D *layout_3d;
59         Msp::GL::Object *base_object;
60         Marklin::Route *cur_route;
61         Msp::GL::Pipeline *pipeline;
62         Msp::GL::Lighting lighting;
63         Msp::GL::Light light;
64
65         Mode mode;
66         Selection selection;
67         Manipulator manipulator;
68         Measure measure;
69         Input *input;
70
71         float cam_yaw;
72         float cam_pitch;
73         Marklin::Point cam_pos;
74
75         bool shift;
76         int move_x;
77         int move_y;
78         int zoom;
79         int rotate;
80         int pitch;
81         int pointer_x;
82         int pointer_y;
83
84         Msp::Time::TimeStamp last_tick;
85
86         static Msp::Application::RegApp<Designer> reg;
87
88 public:
89         Designer(int, char **);
90         ~Designer();
91
92         int main();
93         void save();
94         void quit();
95
96         Marklin::Layout *get_layout() { return layout; }
97         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
98         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
99         Msp::GLtk::Root &get_root() const { return *root; }
100         void edit_route(Marklin::Route &);
101         Marklin::Route *get_current_route() const { return cur_route; }
102         void add_selection_to_route();
103
104         void map_pointer_coords(int, int, float &, float &);
105 private:
106         void tick();
107         void key_press(unsigned, unsigned, wchar_t);
108         void key_release(unsigned, unsigned);
109         void button_press(int, int, unsigned, unsigned);
110         void pointer_motion(int, int);
111         void project_3d();
112         void apply_camera();
113         void render();
114         Marklin::Track3D *pick_track(int, int);
115         void update_track_color(Marklin::Track3D &);
116         void manipulation_status(const std::string &);
117         void manipulation_done(bool);
118         void measure_changed();
119         void measure_done();
120         void set_tooltip(int, int, const std::string &);
121         void clear_tooltip();
122         void save_accept();
123         void turnout_id_accept();
124         void sensor_id_accept();
125         void input_dismiss();
126 };
127
128 #endif