]> git.tdb.fi Git - r2c2.git/blob - designer.h
cbf01d040a07b82808893fdd305f8732ade02080
[r2c2.git] / designer.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2006-2011 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 "libr2c2/catalogue.h"
25 #include "libr2c2/layout.h"
26 #include "3d/layout.h"
27 #include "3d/overlay.h"
28 #include "3d/track.h"
29 #include "3d/view.h"
30 #include "cameracontroller.h"
31 #include "manipulator.h"
32 #include "measure.h"
33 #include "selection.h"
34 #include "trackwrap.h"
35
36 class Toolbar;
37
38 class Designer: public Msp::Application
39 {
40 private:
41         enum Mode
42         {
43                 SELECT,
44                 CATALOGUE,
45                 MANIPULATE,
46                 MANIPULATE_DONE,
47                 MEASURE
48         };
49
50         Msp::Graphics::SimpleGLWindow window;
51         Msp::GLtk::Resources ui_res;
52         Msp::GLtk::Root root;
53
54         std::vector<Toolbar *> toolbars;
55         Msp::GLtk::Label *lbl_status;
56
57         R2C2::Catalogue catalogue;
58         R2C2::Layout3D *cat_layout_3d;
59         R2C2::View3D *cat_view;
60
61         std::string filename;
62         R2C2::Layout *layout;
63         R2C2::Layout3D *layout_3d;
64         R2C2::View3D *main_view;
65         R2C2::Overlay3D *overlay;
66         Msp::GL::Object *base_object;
67         R2C2::Route *cur_route;
68         R2C2::Zone *cur_zone;
69         std::list<R2C2::Track *> new_tracks;
70
71         Mode mode;
72         Selection selection;
73         Manipulator manipulator;
74         Measure measure;
75         CameraController *camera_ctl;
76         TrackWrap *track_wrap;
77
78         Msp::Time::TimeStamp last_tick;
79
80         static Msp::Application::RegApp<Designer> reg;
81
82 public:
83         Designer(int, char **);
84         ~Designer();
85
86         int main();
87         void save();
88         void quit();
89
90         const R2C2::Catalogue &get_catalogue() const { return catalogue; }
91         R2C2::Layout &get_layout() { return *layout; }
92         R2C2::Layout3D &get_layout_3d() { return *layout_3d; }
93         const CameraController &get_camera_controller() const { return *camera_ctl; }
94         const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
95         Msp::GLtk::Root &get_root() { return root; }
96
97         void new_track();
98         void erase_tracks();
99         void track_properties();
100         void extend_track();
101         void connect_tracks();
102         void flatten_tracks();
103         void svg_export();
104
105         void edit_route(R2C2::Route *);
106         void rename_route();
107         R2C2::Route *get_current_route() const { return cur_route; }
108         void add_selection_to_route();
109
110         void edit_zone(R2C2::Zone *);
111         void zone_properties();
112         R2C2::Zone *get_current_zone() const { return cur_zone; }
113         void add_selection_to_zone();
114
115         R2C2::Vector map_pointer_to_ground(int, int);
116 private:
117         void tick();
118         void key_press(unsigned, unsigned, wchar_t);
119         void button_press(int, int, unsigned, unsigned);
120         void pointer_motion(int, int);
121         void apply_camera();
122         void render();
123         void track_added(R2C2::Track &);
124         void track_removed(R2C2::Track &);
125         R2C2::Track *pick_track(int, int);
126         void update_track_icon(R2C2::Track3D &);
127         void selection_changed();
128         void manipulation_status(const std::string &);
129         void manipulation_done(bool);
130         void measure_changed();
131         void measure_done();
132         void arrange_toolbars();
133         void track_properties_response(int);
134         void route_name_accept(const std::string &);
135         void svg_export_accept(const std::string &);
136         std::string tooltip(int, int);
137         void clear_paths();
138         void show_route(const R2C2::Route &);
139         void show_zone(const R2C2::Zone &);
140 };
141
142 #endif