]> git.tdb.fi Git - r2c2.git/blob - source/designer/designer.h
499c06cee81f446a7253c4be3e1aa0a9c05ee4fd
[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/layout.h>
15 #include <msp/gltk/resources.h>
16 #include <msp/gltk/root.h>
17 #include <msp/time/timestamp.h>
18 #include "libr2c2/catalogue.h"
19 #include "libr2c2/layout.h"
20 #include "3d/layout.h"
21 #include "3d/overlay.h"
22 #include "3d/track.h"
23 #include "3d/view.h"
24 #include "cameracontroller.h"
25 #include "manipulator.h"
26 #include "measure.h"
27 #include "selection.h"
28 #include "selectionwrap.h"
29
30 class Toolbar;
31
32 class Designer: public Msp::RegisteredApplication<Designer>
33 {
34 private:
35         enum Mode
36         {
37                 CATALOGUE,
38                 TOOL
39         };
40
41         Msp::Graphics::SimpleGLWindow window;
42         Msp::Input::Keyboard keyboard;
43         Msp::Input::Mouse mouse;
44         Msp::GLtk::Resources ui_res;
45         Msp::GLtk::Root root;
46         Msp::GLtk::Layout *root_layout;
47
48         std::vector<Toolbar *> toolbars;
49         Msp::GLtk::Label *lbl_status;
50
51         R2C2::Catalogue catalogue;
52         R2C2::Layout3D *cat_layout_3d;
53         R2C2::View3D *cat_view;
54
55         std::string filename;
56         R2C2::Layout *layout;
57         R2C2::Layout3D *layout_3d;
58         R2C2::View3D *main_view;
59         R2C2::Overlay3D *overlay;
60         Msp::GL::Object *base_object;
61         R2C2::Route *cur_route;
62         R2C2::Zone *cur_zone;
63         std::list<R2C2::Path3D *> highlight_paths;
64
65         Mode mode;
66         Selection selection;
67         SelectionWrap sel_wrap;
68         Tool *cur_tool;
69         CameraController *camera_ctl;
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 R2C2::View3D &get_view() const { return *main_view; }
85         const CameraController &get_camera_controller() const { return *camera_ctl; }
86
87         void new_object();
88         void erase_objects();
89         void object_properties();
90         void extend_track();
91         void connect_tracks();
92         void flatten_tracks();
93         void svg_export();
94
95         void edit_route(R2C2::Route *);
96         void rename_route();
97         R2C2::Route *get_current_route() const { return cur_route; }
98         void add_selection_to_route();
99
100         void edit_zone(R2C2::Zone *);
101         void zone_properties();
102         R2C2::Zone *get_current_zone() const { return cur_zone; }
103         void add_selection_to_zone();
104
105         R2C2::Vector map_pointer_to_ground(const R2C2::Vector &);
106 private:
107         void tick();
108         void key_press(unsigned);
109         template<typename T>
110         T *use_tool_with_selected_objects();
111         template<typename T>
112         T *use_tool();
113         void use_tool(Tool *);
114         void use_select_tool();
115         void button_press(unsigned);
116         void apply_camera();
117         void render();
118         R2C2::Object *pick_object(const R2C2::Vector &);
119         void update_object_icon(R2C2::Object &);
120         void tool_status(const std::string &);
121         void object_properties_response(int);
122         void route_name_accept(const std::string &);
123         void svg_export_accept(const std::string &);
124         std::string tooltip(int, int);
125         void clear_paths();
126         void show_route(const R2C2::Route &);
127         void show_zone(const R2C2::Zone &);
128 };
129
130 #endif