]> git.tdb.fi Git - r2c2.git/blob - manipulator.h
d8c3986a6161db02dd1bea7a84bd44a8e09d6841
[r2c2.git] / manipulator.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef MANIPULATOR_H_
9 #define MANIPULATOR_H_
10
11 #include <sigc++/sigc++.h>
12
13 class Designer;
14 class Selection;
15
16 class Manipulator
17 {
18 private:
19         enum Mode
20         {
21                 NONE,
22                 MOVE,
23                 ROTATE,
24                 ELEVATE,
25                 EXTEND
26         };
27
28         struct MTrack
29         {
30                 R2C2::Track *track;
31                 R2C2::Vector pos;
32                 float rot;
33
34                 MTrack(R2C2::Track *);
35         };
36
37         struct TrackOrder
38         {
39                 R2C2::Track *track;
40                 bool rev;
41
42                 TrackOrder(R2C2::Track *t, bool r): track(t), rev(r) { }
43         };
44
45 public:
46         sigc::signal<void, const std::string &> signal_status;
47         sigc::signal<void, bool> signal_done;
48
49 private:
50         Designer &designer;
51         Msp::Graphics::EventSource &event_source;
52         Selection &selection;
53         std::vector<MTrack> tracks;
54         R2C2::Vector center;
55
56         R2C2::Vector gpointer;
57         int pointer_y;
58         Mode mode;
59         R2C2::Vector move_origin;
60         float angle;
61         float rot_origin;
62         int elev_origin;
63         std::set<R2C2::Track *> neighbors;
64         std::vector<R2C2::Track *> extend_tracks;
65
66 public:
67         Manipulator(Designer &, Msp::Graphics::EventSource &, Selection &);
68
69         void start_move();
70         void start_rotate();
71         void start_elevate();
72         bool start_extend();
73         void duplicate();
74         void flatten();
75         void even_slope(bool =false);
76         void connect();
77         void cancel();
78 private:
79         void button_press(int, int, unsigned, unsigned);
80         void pointer_motion(int, int);
81         void selection_changed();
82         void update_tracks();
83         void update_neighbors();
84         void set_slope(TrackOrder &, float, float);
85         std::vector<R2C2::Track *> create_straight(const R2C2::Vector &, float, float, float);
86 };
87
88 #endif