]> git.tdb.fi Git - r2c2.git/blob - source/designer/elevatetool.cpp
Don't crash if a train has no router
[r2c2.git] / source / designer / elevatetool.cpp
1 #include <msp/strings/format.h>
2 #include "elevatetool.h"
3
4 using namespace std;
5 using namespace Msp;
6 using namespace R2C2;
7
8 ElevateTool::ElevateTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, const set<Object *> &o):
9         Manipulator(d, k, m, o)
10 {
11         origin = pointer.y;
12 }
13
14 void ElevateTool::axis_motion(unsigned axis, float value, float)
15 {
16         if(axis==1)
17         {
18                 Vector offset(0, 0, value-origin);
19
20                 signal_status.emit(format("Elevation: %+.0fmm (%.0fmm)", offset.z*1000, (center.z+offset.z)*1000));
21
22                 for(ObjectArray::iterator i=objects.begin(); i!=objects.end(); ++i)
23                         i->object->set_position(center+i->original_position+offset);
24         }
25 }