]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
e103a749a4f41a2d4c0bd286f1975dee00c9b7bb
[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/display.h>
14 #include <msp/gbase/window.h>
15 #include <msp/gbase/glcontext.h>
16 #include <msp/gl/font.h>
17 #include <msp/gl/mesh.h>
18 #include <msp/gltk/label.h>
19 #include <msp/gltk/resources.h>
20 #include <msp/gltk/root.h>
21 #include <msp/time/timestamp.h>
22 #include "libmarklin/catalogue.h"
23 #include "libmarklin/layout.h"
24 #include "3d/layout.h"
25 #include "3d/track.h"
26
27 class Input;
28 class Manipulator;
29 class Measure;
30 class Selection;
31 class Toolbar;
32
33 class Designer: public Msp::Application
34 {
35 private:
36         enum Mode
37         {
38                 SELECT,
39                 CATALOGUE,
40                 MANIPULATE,
41                 MEASURE,
42                 INPUT
43         };
44
45         Msp::Graphics::Display *dpy;
46         Msp::Graphics::Window *wnd;
47         Msp::Graphics::GLContext *glc;
48         unsigned screen_w;
49         unsigned screen_h;
50         Msp::GLtk::Resources ui_res;
51         Msp::GLtk::Root *root;
52
53         Toolbar *toolbar;
54         Msp::GLtk::Label *lbl_tooltip;
55         Msp::Time::TimeStamp tooltip_timeout;
56
57         Marklin::Catalogue catalogue;
58         Marklin::Layout *cat_layout;
59         Marklin::Layout3D *cat_layout_3d;
60         std::string filename;
61         Marklin::Layout *layout;
62         Marklin::Layout3D *layout_3d;
63         Msp::GL::Mesh *base_mesh;
64         Marklin::Route *cur_route;
65
66         Mode mode;
67         Selection *selection;
68         Manipulator *manipulator;
69         Measure *measure;
70         Input *input;
71
72         float cam_yaw;
73         float cam_pitch;
74         Marklin::Point cam_pos;
75
76         bool shift;
77         int move_x;
78         int move_y;
79         int zoom;
80         int rotate;
81         int pitch;
82         int pointer_x;
83         int pointer_y;
84
85         Msp::Time::TimeStamp last_tick;
86
87         static Msp::Application::RegApp<Designer> reg;
88
89 public:
90         Designer(int, char **);
91         ~Designer();
92
93         int main();
94         void save();
95         void quit();
96
97         Marklin::Layout *get_layout() { return layout; }
98         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
99         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
100         Msp::GLtk::Root &get_root() const { return *root; }
101         void edit_route(Marklin::Route &);
102         Marklin::Route *get_current_route() const { return cur_route; }
103         void add_selection_to_route();
104
105         void map_pointer_coords(int, int, float &, float &);
106 private:
107         void tick();
108         void key_press(unsigned, unsigned, wchar_t);
109         void key_release(unsigned, unsigned);
110         void button_press(int, int, unsigned, unsigned);
111         void pointer_motion(int, int);
112         void project_3d();
113         void apply_camera();
114         void render();
115         Marklin::Track3D *pick_track(int, int);
116         void update_track_color(Marklin::Track3D &);
117         void manipulation_status(const std::string &);
118         void manipulation_done(bool);
119         void measure_changed();
120         void measure_done();
121         void set_tooltip(int, int, const std::string &);
122         void clear_tooltip();
123         void save_accept();
124         void turnout_id_accept();
125         void sensor_id_accept();
126         void input_dismiss();
127 };
128
129 #endif