diff --git a/src/seltrans.h b/src/seltrans.h
index e8aee252ec4175c7db574bf55810d828f66773f3..0183683ffe028026dd0bbdd525a0c4e4cd04d5ba 100644 (file)
--- a/src/seltrans.h
+++ b/src/seltrans.h
/*
* Helper object for transforming selected items
*
/*
* Helper object for transforming selected items
*
- * Author:
+ * Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Carl Hetherington <inkscape@carlh.net>
* Lauris Kaplinski <lauris@kaplinski.com>
* Carl Hetherington <inkscape@carlh.net>
+ * Diederik van Lierop <mail@diedenrezi.nl>
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2002 Lauris Kaplinski
*
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 1999-2002 Lauris Kaplinski
*/
#include <sigc++/sigc++.h>
*/
#include <sigc++/sigc++.h>
-#include <libnr/nr-point.h>
-#include <libnr/nr-matrix.h>
-#include <libnr/nr-rect.h>
+#include <2geom/point.h>
+#include <2geom/matrix.h>
+#include <2geom/rect.h>
+#include "knot.h"
#include "forward.h"
#include "selcue.h"
#include "message-context.h"
#include <vector>
#include "forward.h"
#include "selcue.h"
#include "message-context.h"
#include <vector>
+#include "sp-item.h"
struct SPKnot;
class SPDesktop;
struct SPKnot;
class SPDesktop;
namespace Inkscape
{
namespace Inkscape
{
+Geom::Scale calcScaleFactors(Geom::Point const &initial_point, Geom::Point const &new_point, Geom::Point const &origin, bool const skew = false);
+
namespace XML
{
class Node;
namespace XML
{
class Node;
void increaseState();
void resetState();
void increaseState();
void resetState();
- void setCenter(NR::Point const &p);
- void grab(NR::Point const &p, gdouble x, gdouble y, bool show_handles);
- void transform(NR::Matrix const &rel_affine, NR::Point const &norm);
+ void setCenter(Geom::Point const &p);
+ void grab(Geom::Point const &p, gdouble x, gdouble y, bool show_handles, bool translating);
+ void transform(Geom::Matrix const &rel_affine, Geom::Point const &norm);
void ungrab();
void stamp();
void ungrab();
void stamp();
- void moveTo(NR::Point const &xy, guint state);
- void stretch(SPSelTransHandle const &handle, NR::Point &pt, guint state);
- void scale(NR::Point &pt, guint state);
- void skew(SPSelTransHandle const &handle, NR::Point &pt, guint state);
- void rotate(NR::Point &pt, guint state);
- gboolean scaleRequest(NR::Point &pt, guint state);
- gboolean stretchRequest(SPSelTransHandle const &handle, NR::Point &pt, guint state);
- gboolean skewRequest(SPSelTransHandle const &handle, NR::Point &pt, guint state);
- gboolean rotateRequest(NR::Point &pt, guint state);
- gboolean centerRequest(NR::Point &pt, guint state);
-
- gboolean handleRequest(SPKnot *knot, NR::Point *position, guint state, SPSelTransHandle const &handle);
+ void moveTo(Geom::Point const &xy, guint state);
+ void stretch(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
+ void scale(Geom::Point &pt, guint state);
+ void skew(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
+ void rotate(Geom::Point &pt, guint state);
+ gboolean scaleRequest(Geom::Point &pt, guint state);
+ gboolean stretchRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
+ gboolean skewRequest(SPSelTransHandle const &handle, Geom::Point &pt, guint state);
+ gboolean rotateRequest(Geom::Point &pt, guint state);
+ gboolean centerRequest(Geom::Point &pt, guint state);
+
+ gboolean handleRequest(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle);
void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle);
void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle);
void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle);
- void handleNewEvent(SPKnot *knot, NR::Point *position, guint state, SPSelTransHandle const &handle);
+ void handleNewEvent(SPKnot *knot, Geom::Point *position, guint state, SPSelTransHandle const &handle);
enum Show
{
enum Show
{
return _empty;
}
bool isGrabbed() {
return _empty;
}
bool isGrabbed() {
- return _grabbed;
+ return _grabbed;
}
}
-
+ bool centerIsVisible() {
+ return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) );
+ }
+
private:
void _updateHandles();
void _updateVolatileState();
private:
void _updateHandles();
void _updateVolatileState();
void _selModified(Inkscape::Selection *selection, guint flags);
void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
gchar const *even_tip, gchar const *odd_tip);
void _selModified(Inkscape::Selection *selection, guint flags);
void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
gchar const *even_tip, gchar const *odd_tip);
+ Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos);
+ Geom::Point _calcAbsAffineDefault(Geom::Scale const default_scale);
+ Geom::Point _calcAbsAffineGeom(Geom::Scale const geom_scale);
+ void _keepClosestPointOnly(std::vector<Inkscape::SnapCandidatePoint> &points, const Geom::Point &reference);
+ void _display_snapsource();
enum State {
enum State {
- STATE_SCALE,
- STATE_ROTATE
+ STATE_SCALE, //scale or stretch
+ STATE_ROTATE //rotate or skew
};
};
-
+
SPDesktop *_desktop;
SPDesktop *_desktop;
- std::vector<std::pair<SPItem *, NR::Matrix> > _items;
- std::vector<std::pair<SPItem *, NR::Point> > _items_centers;
-
- std::vector<NR::Point> _snap_points;
- std::vector<NR::Point> _bbox_points;
-
+ std::vector<SPItem *> _items;
+ std::vector<SPItem const *> _items_const;
+ std::vector<Geom::Matrix> _items_affines;
+ std::vector<Geom::Point> _items_centers;
+
+ std::vector<Inkscape::SnapCandidatePoint> _snap_points;
+ std::vector<Inkscape::SnapCandidatePoint> _bbox_points; // the bbox point of the selection as a whole, i.e. max. 4 corners plus optionally some midpoints
+ std::vector<Inkscape::SnapCandidatePoint> _bbox_points_for_translating; // the bbox points of each selected item, only to be used for translating
+
Inkscape::SelCue _selcue;
Inkscape::Selection *_selection;
Inkscape::SelCue _selcue;
Inkscape::Selection *_selection;
bool _empty;
bool _changed;
bool _empty;
bool _changed;
- NR::Maybe<NR::Rect> _box;
+ SPItem::BBoxType _snap_bbox_type;
+
+ Geom::OptRect _bbox;
+ Geom::OptRect _approximate_bbox;
+ Geom::OptRect _geometric_bbox;
gdouble _strokewidth;
gdouble _strokewidth;
- NR::Matrix _current;
- NR::Point _opposite; ///< opposite point to where a scale is taking place
- NR::Maybe<NR::Point> _center;
+ Geom::Matrix _current_relative_affine;
+ Geom::Matrix _absolute_affine;
+ Geom::Matrix _relative_affine;
+ /* According to Merriam - Webster's online dictionary
+ * Affine: a transformation (as a translation, a rotation, or a uniform stretching) that carries straight
+ * lines into straight lines and parallel lines into parallel lines but may alter distance between points
+ * and angles between lines <affine geometry>
+ */
+
+ Geom::Point _opposite; ///< opposite point to where a scale is taking place
+ Geom::Point _opposite_for_specpoints;
+ Geom::Point _opposite_for_bboxpoints;
+ Geom::Point _origin_for_specpoints;
+ Geom::Point _origin_for_bboxpoints;
+
+ gdouble _handle_x;
+ gdouble _handle_y;
+
+ boost::optional<Geom::Point> _center;
bool _center_is_set; ///< we've already set _center, no need to reread it from items
SPKnot *_shandle[8];
bool _center_is_set; ///< we've already set _center, no need to reread it from items
SPKnot *_shandle[8];
SPCanvasItem *_l[4];
guint _sel_changed_id;
guint _sel_modified_id;
SPCanvasItem *_l[4];
guint _sel_changed_id;
guint _sel_modified_id;
- GSList *_stamp_cache;
+ GSList *_stamp_cache;
- NR::Point _origin; ///< position of origin for transforms
- NR::Point _point; ///< original position of the knot being used for the current transform
+ Geom::Point _origin; ///< position of origin for transforms
+ Geom::Point _point; ///< original position of the knot being used for the current transform
+ Geom::Point _point_geom; ///< original position of the knot being used for the current transform
Inkscape::MessageContext _message_context;
Inkscape::MessageContext _message_context;
- SigC::Connection _sel_changed_connection;
- SigC::Connection _sel_modified_connection;
+ sigc::connection _sel_changed_connection;
+ sigc::connection _sel_modified_connection;
};
}
};
}