]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
c4591abf5f1260991044d2b1839dd11448f161dd
[r2c2.git] / source / designer / designer.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010 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/overlay.h"
28 #include "3d/track.h"
29 #include "cameracontroller.h"
30 #include "manipulator.h"
31 #include "measure.h"
32 #include "selection.h"
33
34 class Input;
35 class Toolbar;
36
37 class Designer: public Msp::Application
38 {
39 private:
40         enum Mode
41         {
42                 SELECT,
43                 CATALOGUE,
44                 MANIPULATE,
45                 MEASURE,
46                 INPUT
47         };
48
49         Msp::Graphics::SimpleGLWindow window;
50         Msp::GLtk::Resources ui_res;
51         Msp::GLtk::Root *root;
52
53         Toolbar *toolbar;
54         Msp::GLtk::Label *lbl_tooltip;
55         Msp::Time::TimeStamp tooltip_timeout;
56
57         Marklin::Catalogue catalogue;
58         Marklin::Layout3D *cat_layout_3d;
59         std::string filename;
60         Marklin::Layout *layout;
61         Marklin::Layout3D *layout_3d;
62         Marklin::Overlay3D *overlay;
63         Msp::GL::Object *base_object;
64         Marklin::Route *cur_route;
65         Msp::GL::Pipeline *pipeline;
66         Msp::GL::Camera camera;
67         Msp::GL::Lighting lighting;
68         Msp::GL::Light light;
69
70         Mode mode;
71         Selection selection;
72         Manipulator manipulator;
73         Measure measure;
74         Input *input;
75         CameraController camera_ctl;
76
77         bool shift;
78         int pointer_x;
79         int pointer_y;
80
81         Msp::Time::TimeStamp last_tick;
82
83         static Msp::Application::RegApp<Designer> reg;
84
85 public:
86         Designer(int, char **);
87         ~Designer();
88
89         int main();
90         void save();
91         void quit();
92
93         Marklin::Layout *get_layout() { return layout; }
94         Marklin::Layout3D *get_layout_3d() { return layout_3d; }
95         const Msp::GL::Camera &get_camera() const { return camera; }
96         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
97         Msp::GLtk::Root &get_root() const { return *root; }
98         void edit_route(Marklin::Route &);
99         Marklin::Route *get_current_route() const { return cur_route; }
100         void add_selection_to_route();
101
102         Marklin::Point map_pointer_coords(int, int);
103 private:
104         void tick();
105         void key_press(unsigned, unsigned, wchar_t);
106         void key_release(unsigned, unsigned);
107         void button_press(int, int, unsigned, unsigned);
108         void pointer_motion(int, int);
109         void apply_camera();
110         void render();
111         Marklin::Track3D *pick_track(int, int);
112         void update_track_icon(Marklin::Track3D &);
113         void manipulation_status(const std::string &);
114         void manipulation_done(bool);
115         void measure_changed();
116         void measure_done();
117         void set_tooltip(int, int, const std::string &);
118         void clear_tooltip();
119         void save_accept();
120         void turnout_id_accept();
121         void sensor_id_accept();
122         void input_dismiss();
123         void view_all();
124 };
125
126 #endif