]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
Code reformatting:
[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/time/timestamp.h>
19 #include "libmarklin/catalogue.h"
20 #include "libmarklin/layout.h"
21 #include "3d/layout.h"
22 #include "3d/track.h"
23
24 class Input;
25 class Manipulator;
26 class Measure;
27 class Selection;
28
29 class Designer: public Msp::Application
30 {
31 private:
32         enum Mode
33         {
34                 SELECT,
35                 CATALOGUE,
36                 MANIPULATE,
37                 MEASURE,
38                 INPUT
39         };
40
41         Msp::Graphics::Display *dpy;
42         Msp::Graphics::Window *wnd;
43         Msp::Graphics::GLContext *glc;
44         unsigned screen_w;
45         unsigned screen_h;
46         Msp::GL::Font *font;
47
48         Marklin::Catalogue catalogue;
49         Marklin::Layout *layout;
50         Marklin::Layout3D *layout_3d;
51         Marklin::Layout *cat_layout;
52         Marklin::Layout3D *cat_layout_3d;
53         Msp::GL::Mesh *base_mesh;
54
55         Mode mode;
56         Selection *selection;
57         Manipulator *manipulator;
58         Measure *measure;
59         Input *input;
60
61         float cam_yaw;
62         float cam_pitch;
63         Marklin::Point cam_pos;
64
65         bool shift;
66         int move_x;
67         int move_y;
68         int zoom;
69         int rotate;
70         int pitch;
71         int pointer_x;
72         int pointer_y;
73
74         int tooltip_x;
75         int tooltip_y;
76         std::string tooltip;
77         Msp::Time::TimeStamp tooltip_timeout;
78
79         Msp::Time::TimeStamp last_tick;
80
81         static Msp::Application::RegApp<Designer> reg;
82
83 public:
84         Designer(int, char **);
85         ~Designer();
86
87         Marklin::Layout *get_layout() { return layout; }
88         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
89         Msp::GL::Font &get_font() { return *font; }
90         int main();
91         void map_pointer_coords(int, int, float &, float &);
92 private:
93         void tick();
94         void key_press(unsigned, unsigned, wchar_t);
95         void key_release(unsigned, unsigned);
96         void button_press(int, int, unsigned, unsigned);
97         void pointer_motion(int, int);
98         void project_3d();
99         void apply_camera();
100         void render();
101         Marklin::Track3D *pick_track(int, int);
102         void manipulation_status(const std::string &);
103         void manipulation_done(bool);
104         void measure_changed();
105         void measure_done();
106         void move_tooltip(int, int);
107         void save_accept();
108         void turnout_id_accept();
109         void sensor_id_accept();
110         void input_dismiss();
111 };
112
113 #endif