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