]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/designer.h
Don't crash if a train has no router
[r2c2.git] / source / designer / designer.h
index e103a749a4f41a2d4c0bd286f1975dee00c9b7bb..a132b4791b4bcfdcca33e945430d8763a30d7b48 100644 (file)
@@ -1,91 +1,76 @@
-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #ifndef DESIGNER_H_
 #define DESIGNER_H_
 
 #include <string>
 #include <msp/core/application.h>
-#include <msp/gbase/display.h>
-#include <msp/gbase/window.h>
-#include <msp/gbase/glcontext.h>
+#include <msp/graphics/simplewindow.h>
+#include <msp/gl/camera.h>
 #include <msp/gl/font.h>
-#include <msp/gl/mesh.h>
+#include <msp/gl/light.h>
+#include <msp/gl/lighting.h>
+#include <msp/gl/object.h>
+#include <msp/gl/pipeline.h>
 #include <msp/gltk/label.h>
+#include <msp/gltk/layout.h>
 #include <msp/gltk/resources.h>
 #include <msp/gltk/root.h>
 #include <msp/time/timestamp.h>
-#include "libmarklin/catalogue.h"
-#include "libmarklin/layout.h"
+#include "libr2c2/catalogue.h"
+#include "libr2c2/layout.h"
 #include "3d/layout.h"
+#include "3d/overlay.h"
 #include "3d/track.h"
+#include "3d/view.h"
+#include "cameracontroller.h"
+#include "manipulator.h"
+#include "measure.h"
+#include "selection.h"
+#include "selectionwrap.h"
 
-class Input;
-class Manipulator;
-class Measure;
-class Selection;
 class Toolbar;
 
-class Designer: public Msp::Application
+class Designer: public Msp::RegisteredApplication<Designer>
 {
 private:
        enum Mode
        {
-               SELECT,
                CATALOGUE,
-               MANIPULATE,
-               MEASURE,
-               INPUT
+               TOOL
        };
 
-       Msp::Graphics::Display *dpy;
-       Msp::Graphics::Window *wnd;
-       Msp::Graphics::GLContext *glc;
-       unsigned screen_w;
-       unsigned screen_h;
+       Msp::Graphics::SimpleGLWindow window;
+       Msp::Input::Keyboard keyboard;
+       Msp::Input::Mouse mouse;
        Msp::GLtk::Resources ui_res;
-       Msp::GLtk::Root *root;
+       Msp::GLtk::Root root;
+       Msp::GLtk::Layout *root_layout;
+
+       std::vector<Toolbar *> toolbars;
+       Msp::GLtk::Label *lbl_status;
 
-       Toolbar *toolbar;
-       Msp::GLtk::Label *lbl_tooltip;
-       Msp::Time::TimeStamp tooltip_timeout;
+       R2C2::Catalogue catalogue;
+       R2C2::Layout3D *cat_layout_3d;
+       R2C2::View3D *cat_view;
 
-       Marklin::Catalogue catalogue;
-       Marklin::Layout *cat_layout;
-       Marklin::Layout3D *cat_layout_3d;
        std::string filename;
-       Marklin::Layout *layout;
-       Marklin::Layout3D *layout_3d;
-       Msp::GL::Mesh *base_mesh;
-       Marklin::Route *cur_route;
+       R2C2::Layout *layout;
+       R2C2::Layout3D *layout_3d;
+       R2C2::View3D *main_view;
+       R2C2::Overlay3D *overlay;
+       Msp::GL::Object *base_object;
+       R2C2::Route *cur_route;
+       R2C2::Zone *cur_zone;
+       std::list<R2C2::Path3D *> highlight_paths;
 
        Mode mode;
-       Selection *selection;
-       Manipulator *manipulator;
-       Measure *measure;
-       Input *input;
-
-       float cam_yaw;
-       float cam_pitch;
-       Marklin::Point cam_pos;
-
-       bool shift;
-       int move_x;
-       int move_y;
-       int zoom;
-       int rotate;
-       int pitch;
-       int pointer_x;
-       int pointer_y;
+       Selection selection;
+       SelectionWrap sel_wrap;
+       Tool *cur_tool;
+       unsigned keep_status;
+       CameraController *camera_ctl;
 
        Msp::Time::TimeStamp last_tick;
 
-       static Msp::Application::RegApp<Designer> reg;
-
 public:
        Designer(int, char **);
        ~Designer();
@@ -94,36 +79,53 @@ public:
        void save();
        void quit();
 
-       Marklin::Layout *get_layout() { return layout; }
-       Marklin::Layout3D *get_layout_3d() { return layout_3d; }
-       const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
-       Msp::GLtk::Root &get_root() const { return *root; }
-       void edit_route(Marklin::Route &);
-       Marklin::Route *get_current_route() const { return cur_route; }
+       const R2C2::Catalogue &get_catalogue() const { return catalogue; }
+       R2C2::Layout &get_layout() { return *layout; }
+       R2C2::Layout3D &get_layout_3d() { return *layout_3d; }
+       const R2C2::View3D &get_view() const { return *main_view; }
+       const CameraController &get_camera_controller() const { return *camera_ctl; }
+
+       void new_object();
+       void erase_objects();
+       void object_properties();
+       void extend_track();
+       void connect_tracks();
+       void flatten_tracks();
+       void svg_export();
+
+       void edit_route(R2C2::Route *);
+       void rename_route();
+       R2C2::Route *get_current_route() const { return cur_route; }
        void add_selection_to_route();
 
-       void map_pointer_coords(int, int, float &, float &);
+       void edit_zone(R2C2::Zone *);
+       void zone_properties();
+       R2C2::Zone *get_current_zone() const { return cur_zone; }
+       void add_selection_to_zone();
+
+       R2C2::Vector map_pointer_to_ground(const R2C2::Vector &);
 private:
        void tick();
-       void key_press(unsigned, unsigned, wchar_t);
-       void key_release(unsigned, unsigned);
-       void button_press(int, int, unsigned, unsigned);
-       void pointer_motion(int, int);
-       void project_3d();
+       void key_press(unsigned);
+       template<typename T>
+       T *use_tool_with_selected_objects();
+       template<typename T>
+       T *use_tool();
+       void use_tool(Tool *);
+       void use_select_tool();
+       void button_press(unsigned);
        void apply_camera();
        void render();
-       Marklin::Track3D *pick_track(int, int);
-       void update_track_color(Marklin::Track3D &);
-       void manipulation_status(const std::string &);
-       void manipulation_done(bool);
-       void measure_changed();
-       void measure_done();
-       void set_tooltip(int, int, const std::string &);
-       void clear_tooltip();
-       void save_accept();
-       void turnout_id_accept();
-       void sensor_id_accept();
-       void input_dismiss();
+       R2C2::Object *pick_object(const R2C2::Vector &);
+       void update_object_icon(R2C2::Object &);
+       void tool_status(const std::string &);
+       void object_properties_response(int);
+       void route_name_accept(const std::string &);
+       void svg_export_accept(const std::string &);
+       std::string tooltip(int, int);
+       void clear_paths();
+       void show_route(const R2C2::Route &);
+       void show_zone(const R2C2::Zone &);
 };
 
 #endif