15
15
* Released under GNU GPL, read the file 'COPYING' for more information
18
#include <sigc++/sigc++.h>
18
19
#include <2geom/point.h>
19
#include <2geom/affine.h>
20
#include <2geom/matrix.h>
20
21
#include <2geom/rect.h>
22
#include <sigc++/sigc++.h>
26
25
#include "message-context.h"
27
#include "seltrans-handles.h"
36
struct SPSelTransHandle;
31
class SPSelTransHandle;
40
36
Geom::Scale calcScaleFactors(Geom::Point const &initial_point, Geom::Point const &new_point, Geom::Point const &origin, bool const skew = false);
56
53
void increaseState();
58
55
void setCenter(Geom::Point const &p);
59
void grab(Geom::Point const &p, double x, double y, bool show_handles, bool translating);
60
void transform(Geom::Affine const &rel_affine, Geom::Point const &norm);
56
void grab(Geom::Point const &p, gdouble x, gdouble y, bool show_handles, bool translating);
57
void transform(Geom::Matrix const &rel_affine, Geom::Point const &norm);
63
void moveTo(Geom::Point const &xy, unsigned int state);
64
void stretch(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state);
65
void scale(Geom::Point &pt, unsigned int state);
66
void skew(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state);
67
void rotate(Geom::Point &pt, unsigned int state);
68
int request(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state);
69
int scaleRequest(Geom::Point &pt, unsigned int state);
70
int stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state);
71
int skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, unsigned int state);
72
int rotateRequest(Geom::Point &pt, unsigned int state);
73
int centerRequest(Geom::Point &pt, unsigned int state);
60
void moveTo(Geom::Point const &xy, guint state);
61
void stretch(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
62
void scale(Geom::Point &pt, guint state);
63
void skew(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
64
void rotate(Geom::Point &pt, guint state);
65
gboolean scaleRequest(Geom::Point &pt, guint state);
66
gboolean stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
67
gboolean skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
68
gboolean rotateRequest(Geom::Point &pt, guint state);
69
gboolean centerRequest(Geom::Point &pt, guint state);
75
int handleRequest(SPKnot *knot, Geom::Point *position, unsigned int state, SPSelTransHandle const &handle);
76
void handleGrab(SPKnot *knot, unsigned int state, SPSelTransHandle const &handle);
77
void handleClick(SPKnot *knot, unsigned int state, SPSelTransHandle const &handle);
78
void handleNewEvent(SPKnot *knot, Geom::Point *position, unsigned int state, SPSelTransHandle const &handle);
71
gboolean handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
72
void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle);
73
void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle);
74
void handleNewEvent(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
95
bool centerIsVisible() {
96
return ( SP_KNOT_IS_VISIBLE (knots[0]) );
99
void getNextClosestPoint(bool reverse);
91
bool centerIsVisible() {
92
return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) );
102
class BoundingBoxPrefsObserver: public Preferences::Observer
105
BoundingBoxPrefsObserver(SelTrans &sel_trans);
107
void notify(Preferences::Entry const &val);
110
SelTrans &_sel_trans;
113
friend class Inkscape::SelTrans::BoundingBoxPrefsObserver;
115
96
void _updateHandles();
116
97
void _updateVolatileState();
117
98
void _selChanged(Inkscape::Selection *selection);
118
void _selModified(Inkscape::Selection *selection, unsigned int flags);
119
void _boundingBoxPrefsChanged(int prefs_bbox);
121
void _showHandles(SPSelTransType type);
99
void _selModified(Inkscape::Selection *selection, guint flags);
100
void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
101
gchar const *even_tip, gchar const *odd_tip);
122
102
Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos);
123
103
Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale);
124
104
Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale);
125
void _keepClosestPointOnly(Geom::Point const &p);
105
void _keepClosestPointOnly(std::vector<std::pair<Geom::Point, int> > &points, const Geom::Point &reference);
106
void _display_snapsource();
128
109
STATE_SCALE, //scale or stretch
134
115
std::vector<SPItem *> _items;
135
116
std::vector<SPItem const *> _items_const;
136
std::vector<Geom::Affine> _items_affines;
117
std::vector<Geom::Matrix> _items_affines;
137
118
std::vector<Geom::Point> _items_centers;
139
std::vector<Inkscape::SnapCandidatePoint> _snap_points;
140
std::vector<Inkscape::SnapCandidatePoint> _bbox_points;
141
std::vector<Inkscape::SnapCandidatePoint> _all_snap_sources_sorted;
142
std::vector<Inkscape::SnapCandidatePoint>::iterator _all_snap_sources_iter;
120
std::vector<std::pair<Geom::Point, int> > _snap_points;
121
std::vector<std::pair<Geom::Point, int> > _bbox_points; // the bbox point of the selection as a whole, i.e. max. 4 corners plus optionally some midpoints
122
std::vector<std::pair<Geom::Point, int> > _bbox_points_for_translating; // the bbox points of each selected item, only to be used for translating
143
124
Inkscape::SelCue _selcue;
145
126
Inkscape::Selection *_selection;
154
135
SPItem::BBoxType _snap_bbox_type;
156
137
Geom::OptRect _bbox;
157
Geom::OptRect _visual_bbox;
138
Geom::OptRect _approximate_bbox;
158
139
Geom::OptRect _geometric_bbox;
140
gdouble _strokewidth;
161
Geom::Affine _current_relative_affine;
162
Geom::Affine _absolute_affine;
163
Geom::Affine _relative_affine;
142
Geom::Matrix _current_relative_affine;
143
Geom::Matrix _absolute_affine;
144
Geom::Matrix _relative_affine;
164
145
/* According to Merriam - Webster's online dictionary
165
146
* Affine: a transformation (as a translation, a rotation, or a uniform stretching) that carries straight
166
147
* lines into straight lines and parallel lines into parallel lines but may alter distance between points
173
154
Geom::Point _origin_for_specpoints;
174
155
Geom::Point _origin_for_bboxpoints;
179
160
boost::optional<Geom::Point> _center;
180
161
bool _center_is_set; ///< we've already set _center, no need to reread it from items
183
SPKnot *knots[NUMHANDS];
184
166
SPCanvasItem *_norm;
185
167
SPCanvasItem *_grip;
187
unsigned int _sel_changed_id;
188
unsigned int _sel_modified_id;
189
std::vector<SPItem*> _stamp_cache;
169
guint _sel_changed_id;
170
guint _sel_modified_id;
171
GSList *_stamp_cache;
191
173
Geom::Point _origin; ///< position of origin for transforms
192
174
Geom::Point _point; ///< original position of the knot being used for the current transform