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