From: Mikko Rasa Date: Sat, 30 Oct 2010 19:50:33 +0000 (+0000) Subject: Add a forward toggle to TrainView X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=3889ed84ee54c312436503f2fd1e328f4a2ba5e5;p=r2c2.git Add a forward toggle to TrainView --- diff --git a/source/engineer/trainview.cpp b/source/engineer/trainview.cpp index b27136c..af2243c 100644 --- a/source/engineer/trainview.cpp +++ b/source/engineer/trainview.cpp @@ -22,6 +22,7 @@ TrainView::TrainView(Engineer &e, const Train &t): engineer(e), train(t), mode(SIDE), + forward(true), pipeline(280, 280, false), stale(false) { @@ -63,6 +64,11 @@ TrainView::TrainView(Engineer &e, const Train &t): btn->set_geometry(GLtk::Geometry(82, 10, 36, 25)); btn->signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &TrainView::set_mode), HEAD)); + add(*(tgl_forward = new GLtk::Toggle(res, "Fwd"))); + tgl_forward->set_geometry(GLtk::Geometry(118, 8, 36, 27)); + tgl_forward->set_value(true); + tgl_forward->signal_toggled.connect(sigc::mem_fun(this, &TrainView::set_forward)); + add(*(btn = new GLtk::Button(res, "Close"))); btn->set_geometry(GLtk::Geometry(geom.w-46, 10, 36, 25)); btn->signal_clicked.connect(sigc::mem_fun(this, &TrainView::close_clicked)); @@ -80,11 +86,18 @@ void TrainView::set_mode(Mode m) mode = m; } +void TrainView::set_forward(bool f) +{ + forward = f; +} + void TrainView::prepare() { const Vehicle &veh = train.get_vehicle(0); const Point &pos = veh.get_position(); float angle = veh.get_direction(); + if(!forward) + angle += M_PI; float c = cos(angle); float s = sin(angle); float l = veh.get_type().get_length(); diff --git a/source/engineer/trainview.h b/source/engineer/trainview.h index 16a1ef9..a452a71 100644 --- a/source/engineer/trainview.h +++ b/source/engineer/trainview.h @@ -12,6 +12,7 @@ Distributed under the GPL #include #include #include +#include #include "libmarklin/train.h" class Engineer; @@ -29,7 +30,9 @@ public: private: Engineer &engineer; const Marklin::Train &train; + Msp::GLtk::Toggle *tgl_forward; Mode mode; + bool forward; Msp::GL::Framebuffer fbo; Msp::GL::Texture2D tex; Msp::GL::Renderbuffer depth; @@ -42,6 +45,7 @@ public: ~TrainView(); void set_mode(Mode); + void set_forward(bool); void prepare(); private: virtual void button_release(int, int, unsigned);