]> git.tdb.fi Git - r2c2.git/blob - source/designer/rotatetool.cpp
Sprinkle some comments on the routing system
[r2c2.git] / source / designer / rotatetool.cpp
1 #include "rotatetool.h"
2
3 using namespace std;
4 using namespace Msp;
5 using namespace R2C2;
6
7 RotateTool::RotateTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, const set<Object *> &o):
8         Manipulator(d, k, m, o),
9         origin(Geometry::atan2(ground_pointer.y-center.y, ground_pointer.x-center.x))
10 { }
11
12 void RotateTool::pointer_motion()
13 {
14         Angle a = Geometry::atan2(ground_pointer.y-center.y, ground_pointer.x-center.x);
15         angle += a-origin;
16         origin = a;
17
18         Transform trans = Transform::rotation(angle, Vector(0, 0, 1));
19         for(ObjectArray::iterator i=objects.begin(); i!=objects.end(); ++i)
20         {
21                 i->object->set_position(center+trans.transform(i->original_position));
22                 i->object->set_rotation(angle+i->original_rotation);
23         }
24 }