]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
Derive application classes from RegisteredApplication
[r2c2.git] / source / designer / designer.h
1 #ifndef DESIGNER_H_
2 #define DESIGNER_H_
3
4 #include <string>
5 #include <msp/core/application.h>
6 #include <msp/graphics/simplewindow.h>
7 #include <msp/gl/camera.h>
8 #include <msp/gl/font.h>
9 #include <msp/gl/light.h>
10 #include <msp/gl/lighting.h>
11 #include <msp/gl/object.h>
12 #include <msp/gl/pipeline.h>
13 #include <msp/gltk/label.h>
14 #include <msp/gltk/resources.h>
15 #include <msp/gltk/root.h>
16 #include <msp/time/timestamp.h>
17 #include "libr2c2/catalogue.h"
18 #include "libr2c2/layout.h"
19 #include "3d/layout.h"
20 #include "3d/overlay.h"
21 #include "3d/track.h"
22 #include "3d/view.h"
23 #include "cameracontroller.h"
24 #include "manipulator.h"
25 #include "measure.h"
26 #include "selection.h"
27 #include "trackwrap.h"
28
29 class Toolbar;
30
31 class Designer: public Msp::RegisteredApplication<Designer>
32 {
33 private:
34         enum Mode
35         {
36                 SELECT,
37                 CATALOGUE,
38                 MANIPULATE,
39                 MANIPULATE_DONE,
40                 MEASURE
41         };
42
43         Msp::Graphics::SimpleGLWindow window;
44         Msp::GLtk::Resources ui_res;
45         Msp::GLtk::Root root;
46
47         std::vector<Toolbar *> toolbars;
48         Msp::GLtk::Label *lbl_status;
49
50         R2C2::Catalogue catalogue;
51         R2C2::Layout3D *cat_layout_3d;
52         R2C2::View3D *cat_view;
53
54         std::string filename;
55         R2C2::Layout *layout;
56         R2C2::Layout3D *layout_3d;
57         R2C2::View3D *main_view;
58         R2C2::Overlay3D *overlay;
59         Msp::GL::Object *base_object;
60         R2C2::Route *cur_route;
61         R2C2::Zone *cur_zone;
62         std::list<R2C2::Track *> new_tracks;
63
64         Mode mode;
65         Selection selection;
66         Manipulator manipulator;
67         Measure measure;
68         CameraController *camera_ctl;
69         TrackWrap *track_wrap;
70
71         Msp::Time::TimeStamp last_tick;
72
73 public:
74         Designer(int, char **);
75         ~Designer();
76
77         int main();
78         void save();
79         void quit();
80
81         const R2C2::Catalogue &get_catalogue() const { return catalogue; }
82         R2C2::Layout &get_layout() { return *layout; }
83         R2C2::Layout3D &get_layout_3d() { return *layout_3d; }
84         const CameraController &get_camera_controller() const { return *camera_ctl; }
85         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
86         Msp::GLtk::Root &get_root() { return root; }
87
88         void new_track();
89         void erase_tracks();
90         void track_properties();
91         void extend_track();
92         void connect_tracks();
93         void flatten_tracks();
94         void svg_export();
95
96         void edit_route(R2C2::Route *);
97         void rename_route();
98         R2C2::Route *get_current_route() const { return cur_route; }
99         void add_selection_to_route();
100
101         void edit_zone(R2C2::Zone *);
102         void zone_properties();
103         R2C2::Zone *get_current_zone() const { return cur_zone; }
104         void add_selection_to_zone();
105
106         R2C2::Vector map_pointer_to_ground(int, int);
107 private:
108         void tick();
109         void key_press(unsigned, unsigned, wchar_t);
110         void button_press(int, int, unsigned, unsigned);
111         void pointer_motion(int, int);
112         void apply_camera();
113         void render();
114         void track_added(R2C2::Track &);
115         void track_removed(R2C2::Track &);
116         R2C2::Track *pick_track(int, int);
117         void update_track_icon(R2C2::Track3D &);
118         void selection_changed();
119         void manipulation_status(const std::string &);
120         void manipulation_done(bool);
121         void measure_changed();
122         void measure_done();
123         void arrange_toolbars();
124         void track_properties_response(int);
125         void route_name_accept(const std::string &);
126         void svg_export_accept(const std::string &);
127         std::string tooltip(int, int);
128         void clear_paths();
129         void show_route(const R2C2::Route &);
130         void show_zone(const R2C2::Zone &);
131 };
132
133 #endif