]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
Support using a mesh as a background
[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         Marklin::Catalogue catalogue;
48         Marklin::Layout    *layout;
49         Marklin::Layout3D  *layout_3d;
50         Marklin::Layout    *cat_layout;
51         Marklin::Layout3D  *cat_layout_3d;
52         Msp::GL::Mesh  *base_mesh;
53         Selection      *selection;
54         Manipulator    *manipulator;
55         Measure        *measure;
56         Input          *input;
57         Mode           mode;
58         float          cam_yaw;
59         float          cam_pitch;
60         Marklin::Point cam_pos;
61         bool           shift;
62         int            move_x;
63         int            move_y;
64         int            zoom;
65         int            rotate;
66         int            pitch;
67         int            pointer_x;
68         int            pointer_y;
69         int            tooltip_x;
70         int            tooltip_y;
71         std::string    tooltip;
72         Msp::Time::TimeStamp tooltip_timeout;
73         Msp::Time::TimeStamp last_tick;
74
75 public:
76         Designer(int, char **);
77         ~Designer();
78
79         Marklin::Layout *get_layout() { return layout; }
80         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
81         Msp::GL::Font   &get_font()   { return *font; }
82         int             main();
83         void            map_pointer_coords(int, int, float &, float &);
84 private:
85         void tick();
86         void key_press(unsigned, unsigned, wchar_t);
87         void key_release(unsigned, unsigned);
88         void button_press(int, int, unsigned, unsigned);
89         void pointer_motion(int, int);
90         void project_3d();
91         void apply_camera();
92         void render();
93         Marklin::Track3D *pick_track(int, int);
94         void manipulation_status(const std::string &);
95         void manipulation_done(bool);
96         void measure_changed();
97         void measure_done();
98         void move_tooltip(int, int);
99         void save_accept();
100         void turnout_id_accept();
101         void sensor_id_accept();
102         void input_dismiss();
103
104         static Msp::Application::RegApp<Designer> reg;
105 };
106
107 #endif