]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
a72316e128044aea2e182190a59008f60712950c
[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/simplewindow.h>
14 #include <msp/gl/camera.h>
15 #include <msp/gl/font.h>
16 #include <msp/gl/light.h>
17 #include <msp/gl/lighting.h>
18 #include <msp/gl/object.h>
19 #include <msp/gl/pipeline.h>
20 #include <msp/gltk/label.h>
21 #include <msp/gltk/resources.h>
22 #include <msp/gltk/root.h>
23 #include <msp/time/timestamp.h>
24 #include "libmarklin/catalogue.h"
25 #include "libmarklin/layout.h"
26 #include "3d/layout.h"
27 #include "3d/track.h"
28 #include "cameracontroller.h"
29 #include "manipulator.h"
30 #include "measure.h"
31 #include "selection.h"
32
33 class Input;
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::SimpleGLWindow window;
49         Msp::GLtk::Resources ui_res;
50         Msp::GLtk::Root *root;
51
52         Toolbar *toolbar;
53         Msp::GLtk::Label *lbl_tooltip;
54         Msp::Time::TimeStamp tooltip_timeout;
55
56         Marklin::Catalogue catalogue;
57         Marklin::Layout3D *cat_layout_3d;
58         std::string filename;
59         Marklin::Layout *layout;
60         Marklin::Layout3D *layout_3d;
61         Msp::GL::Object *base_object;
62         Marklin::Route *cur_route;
63         Msp::GL::Pipeline *pipeline;
64         Msp::GL::Camera camera;
65         Msp::GL::Lighting lighting;
66         Msp::GL::Light light;
67
68         Mode mode;
69         Selection selection;
70         Manipulator manipulator;
71         Measure measure;
72         Input *input;
73         CameraController camera_ctl;
74
75         bool shift;
76         int pointer_x;
77         int pointer_y;
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         int main();
88         void save();
89         void quit();
90
91         Marklin::Layout *get_layout() { return layout; }
92         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
93         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
94         Msp::GLtk::Root &get_root() const { return *root; }
95         void edit_route(Marklin::Route &);
96         Marklin::Route *get_current_route() const { return cur_route; }
97         void add_selection_to_route();
98
99         Marklin::Point map_pointer_coords(int, int);
100 private:
101         void tick();
102         void key_press(unsigned, unsigned, wchar_t);
103         void key_release(unsigned, unsigned);
104         void button_press(int, int, unsigned, unsigned);
105         void pointer_motion(int, int);
106         void apply_camera();
107         void render();
108         Marklin::Track3D *pick_track(int, int);
109         void update_track_color(Marklin::Track3D &);
110         void manipulation_status(const std::string &);
111         void manipulation_done(bool);
112         void measure_changed();
113         void measure_done();
114         void set_tooltip(int, int, const std::string &);
115         void clear_tooltip();
116         void save_accept();
117         void turnout_id_accept();
118         void sensor_id_accept();
119         void input_dismiss();
120         void view_all();
121 };
122
123 #endif