+/* $Id$
+
+This file is part of R²C²
+Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
#ifndef ENGINEER_H_
#define ENGINEER_H_
#include <msp/core/application.h>
-#include <msp/gl/font.h>
+#include <msp/gbase/simplewindow.h>
+#include <msp/gl/camera.h>
+#include <msp/gl/light.h>
+#include <msp/gl/lighting.h>
+#include <msp/gl/pipeline.h>
#include <msp/gltk/resources.h>
-#include "libmarklin/catalogue.h"
-#include "libmarklin/control.h"
-#include "libmarklin/trafficmanager.h"
+#include <msp/gltk/root.h>
+#include "libr2c2/catalogue.h"
+#include "libr2c2/train.h"
#include "3d/layout.h"
+#include "3d/overlay.h"
+#include "3d/path.h"
+#include "network/server.h"
+#include "options.h"
class MainPanel;
class TrainPanel;
+class TrainView;
class Engineer: public Msp::Application
{
public:
- Engineer(int argc, char **argv);
- ~Engineer();
+ sigc::signal<void, R2C2::Track *, int> signal_pick_done;
- Marklin::Control &get_control() { return control; }
- unsigned get_screen_width() const { return screen_w; }
- unsigned get_screen_height() const { return screen_h; }
- unsigned get_font_size() const { return font_size; }
- Msp::GL::Font &get_font() { return *font; }
- void add_train(unsigned);
- int main();
- void quit() { exit(0); }
private:
- typedef std::list<TrainPanel *> TrainPanelSeq;
+ Options options;
- unsigned screen_w;
- unsigned screen_h;
- unsigned font_size;
- bool fullscreen;
- Msp::GL::Font *font;
- Marklin::Catalogue catalogue;
- Marklin::Layout layout;
- Marklin::Layout3D layout_3d;
- Marklin::Control control;
- Marklin::Point cam_pos;
- float cam_rot;
+ Msp::Graphics::SimpleGLWindow window;
Msp::GLtk::Resources ui_res;
- MainPanel *main_panel;
- TrainPanelSeq train_panels;
- std::string status_text;
- bool no_lighting;
- Marklin::TrafficManager *trfc_mgr;
- Train *placing_train;
+ Msp::GLtk::Root *root;
+
+ R2C2::Catalogue catalogue;
+ R2C2::Layout layout;
+ R2C2::Layout3D layout_3d;
+ R2C2::Server *server;
+ Msp::IO::EventDispatcher event_disp;
+ R2C2::Overlay3D *overlay;
+ std::map<R2C2::Train *, Msp::GL::Color> train_colors;
+
+ Msp::GL::Camera camera;
+ Msp::GL::Lighting lighting;
+ Msp::GL::Light light;
+ Msp::GL::Pipeline pipeline;
+ Msp::GL::Mesh arrow_mesh;
+ MainPanel *main_panel;
+ std::list<TrainPanel *> train_panels;
+ std::list<TrainView *> train_views;
+ Msp::Time::TimeStamp status_timeout;
+ bool picking;
+ R2C2::Track *picking_track;
+ int picking_entry;
+ R2C2::Path3D *picking_path;
+ int pointer_x;
+ int pointer_y;
+ bool pointer_moved;
+
+public:
+ Engineer(int argc, char **argv);
+ ~Engineer();
+
+ const Msp::GLtk::Resources &get_ui_resources() const { return ui_res; }
+ Msp::GLtk::Root &get_root() const { return *root; }
+ const R2C2::Catalogue &get_catalogue() const { return catalogue; }
+ R2C2::Layout &get_layout() { return layout; }
+ R2C2::Layout3D &get_layout_3d() { return layout_3d; }
+ const Msp::GL::Lighting &get_lighting() const { return lighting; }
+ void set_status(const std::string &);
+ void rearrange_panels();
+ void add_train_view(TrainView &);
+ void remove_train_view(TrainView &);
+ void pick(bool);
+ int main();
+ void quit() { exit(0); }
+private:
void tick();
- void key_press(unsigned, unsigned);
- void button_press(int, int, unsigned);
- void button_release(int, int, unsigned);
+ void button_press(int, int, unsigned, unsigned);
void pointer_motion(int, int);
void view_all();
- void turnout_route_changed(unsigned);
- void sensor_state_changed(bool, unsigned);
- void project_3d();
- Marklin::Track3D *pick_track(int, int);
+ void set_block_color(const R2C2::Block &, const Msp::GL::Color &);
+ void reset_block_color(const R2C2::Block &);
+ void sensor_event(unsigned, bool);
+ void block_reserved(const R2C2::Block &, const R2C2::Train *);
+ R2C2::Track3D *pick_track(int, int);
+ void train_added(R2C2::Train &);
+ virtual void sighandler(int);
static Msp::Application::RegApp<Engineer> reg;
};