summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a9e6d5a)
raw | patch | inline | side by side (parent: a9e6d5a)
author | cilix42 <cilix42@users.sourceforge.net> | |
Fri, 1 Aug 2008 17:38:59 +0000 (17:38 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Fri, 1 Aug 2008 17:38:59 +0000 (17:38 +0000) |
src/knot-holder-entity.cpp | patch | blob | history | |
src/knot-holder-entity.h | patch | blob | history | |
src/object-edit.cpp | patch | blob | history |
index d6c278d496620e3c66378559ce0ef459d9ea2e5c..3c95bb0b4651c5005ed06f2370c22205d0e3203a 100644 (file)
#include "macros.h"
#include <libnr/nr-matrix-ops.h>
#include "sp-pattern.h"
-#include "inkscape.h"
#include "snap.h"
-#include "desktop-affine.h"
#include "desktop.h"
-#include "desktop-handles.h"
#include "sp-namedview.h"
#include <2geom/matrix.h>
this->parent_holder = parent;
this->item = item; // TODO: remove the item either from here or from knotholder.cpp
+ this->desktop = desktop;
my_counter = KnotHolderEntity::counter++;
_moved_connection.unblock();
}
+NR::Point
+KnotHolderEntity::snap_knot_position(NR::Point const &p)
+{
+ NR::Matrix const i2d (from_2geom(sp_item_i2d_affine(item)));
+ NR::Point s = p * i2d;
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop, item);
+ m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
+ return s * i2d.inverse();
+}
+
+
/* Pattern manipulation */
static gdouble sp_pattern_extract_theta(SPPattern *pat, NR::Point scale)
return NR::Point(pat->patternTransform[4], pat->patternTransform[5]);
}
-static NR::Point snap_knot_position(SPItem *item, NR::Point const &p)
-{
- SPDesktop const *desktop = inkscape_active_desktop();
- NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item)));
- NR::Point s = p * i2d;
- SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
- return s * i2d.inverse();
-}
-
void
PatternKnotHolderEntityXY::knot_set(NR::Point const &p, NR::Point const &origin, guint state)
{
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
- NR::Point p_snapped = snap_knot_position(item, p);
+ NR::Point p_snapped = snap_knot_position(p);
if ( state & GDK_CONTROL_MASK ) {
if (fabs((p - origin)[NR::X]) > fabs((p - origin)[NR::Y])) {
@@ -193,7 +192,7 @@ PatternKnotHolderEntityScale::knot_set(NR::Point const &p, NR::Point const &/*or
{
SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
- NR::Point p_snapped = snap_knot_position(item, p);
+ NR::Point p_snapped = snap_knot_position(p);
// get angle from current transform, (need get current scale first to calculate angle)
NR::Point oldscale = sp_pattern_extract_scale(pat);
index e0d0ca8e8ccbb27af8a33e1066ff93f61f0fe74d..432bf5501e407f576a26c9d10833ae0e77b11604 100644 (file)
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
void update_knot();
//private:
+ NR::Point snap_knot_position(NR::Point const &p);
+
SPKnot *knot;
SPItem *item;
+ SPDesktop *desktop;
KnotHolder *parent_holder;
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 52c5d42cce1961cbe0e9eb1897d5a4e344751f07..ea0291159bfd896ad9bb4224a5ed4b66f1ee37e0 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
#include "sp-offset.h"
#include "sp-flowtext.h"
#include "prefs-utils.h"
-#include "inkscape.h"
-#include "snap.h"
#include "desktop-affine.h"
#include "style.h"
#include "desktop.h"
public:
virtual NR::Point knot_get();
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
+
+protected:
+ void set_internal(NR::Point const &p, NR::Point const &origin, guint state);
};
/* handle for x/y adjustment */
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
};
-static NR::Point snap_knot_position(SPItem *item, NR::Point const &p)
-{
- SPDesktop const *desktop = inkscape_active_desktop();
- NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item)));
- NR::Point s = p * i2d;
- SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, item);
- m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, s);
- return s * i2d.inverse();
-}
-
NR::Point
RectKnotHolderEntityRX::knot_get()
{
return NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed);
}
-static void sp_rect_wh_set_internal(SPRect *rect, NR::Point const &p, NR::Point const &origin, guint state)
+void
+RectKnotHolderEntityWH::set_internal(NR::Point const &p, NR::Point const &origin, guint state)
{
- NR::Point const s = snap_knot_position(rect, p);
+ SPRect *rect = SP_RECT(item);
+ NR::Point const s = snap_knot_position(p);
if (state & GDK_CONTROL_MASK) {
// original width/height when drag started
@@ -321,10 +313,7 @@ static void sp_rect_wh_set_internal(SPRect *rect, NR::Point const &p, NR::Point
void
RectKnotHolderEntityWH::knot_set(NR::Point const &p, NR::Point const &origin, guint state)
{
- SPRect *rect = SP_RECT(item);
-
- sp_rect_wh_set_internal(rect, p, origin, state);
-
+ set_internal(p, origin, state);
update_knot();
}
@@ -349,7 +338,7 @@ RectKnotHolderEntityXY::knot_set(NR::Point const &p, NR::Point const &origin, gu
gdouble w_orig = opposite_x - origin[NR::X];
gdouble h_orig = opposite_y - origin[NR::Y];
- NR::Point const s = snap_knot_position(rect, p);
+ NR::Point const s = snap_knot_position(p);
// mouse displacement since drag started
gdouble minx = s[NR::X] - origin[NR::X];
virtual NR::Point knot_get() = 0;
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state) = 0;
- static NR::Point knot_get_generic(SPItem *item, unsigned int knot_id);
- static void knot_set_generic(SPItem *item, unsigned int knot_id, NR::Point const &p, guint state);
+ NR::Point knot_get_generic(SPItem *item, unsigned int knot_id);
+ void knot_set_generic(SPItem *item, unsigned int knot_id, NR::Point const &p, guint state);
};
NR::Point
void
Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, NR::Point const &new_pos, guint state)
{
- NR::Point const s = snap_knot_position(item, new_pos);
+ NR::Point const s = snap_knot_position(new_pos);
g_assert(item != NULL);
SPBox3D *box = SP_BOX3D(item);
@@ -637,7 +626,7 @@ Box3DKnotHolderEntity7::knot_set(NR::Point const &new_pos, NR::Point const &/*or
void
Box3DKnotHolderEntityCenter::knot_set(NR::Point const &new_pos, NR::Point const &origin, guint state)
{
- NR::Point const s = snap_knot_position(item, new_pos);
+ NR::Point const s = snap_knot_position(new_pos);
SPBox3D *box = SP_BOX3D(item);
NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item)));
ArcKnotHolderEntityRX::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint state)
{
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
- SPArc *arc = SP_ARC(item);
- NR::Point const s = snap_knot_position(arc, p);
+ NR::Point const s = snap_knot_position(p);
ge->rx.computed = fabs( ge->cx.computed - s[NR::X] );
@@ -839,7 +827,7 @@ ArcKnotHolderEntityRX::knot_set(NR::Point const &p, NR::Point const &/*origin*/,
ge->ry.computed = ge->rx.computed;
}
- ((SPObject *)arc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ ((SPObject *)item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
NR::Point
ArcKnotHolderEntityRY::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint state)
{
SPGenericEllipse *ge = SP_GENERICELLIPSE(item);
- SPArc *arc = SP_ARC(item);
- NR::Point const s = snap_knot_position(arc, p);
+ NR::Point const s = snap_knot_position(p);
ge->ry.computed = fabs( ge->cy.computed - s[NR::Y] );
@@ -875,7 +862,7 @@ ArcKnotHolderEntityRY::knot_set(NR::Point const &p, NR::Point const &/*origin*/,
ge->rx.computed = ge->ry.computed;
}
- ((SPObject *)arc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ ((SPObject *)item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
NR::Point
@@ -947,7 +934,7 @@ StarKnotHolderEntity1::knot_set(NR::Point const &p, NR::Point const &/*origin*/,
{
SPStar *star = SP_STAR(item);
- NR::Point const s = snap_knot_position(star, p);
+ NR::Point const s = snap_knot_position(p);
NR::Point d = s - star->center;
@@ -973,7 +960,7 @@ StarKnotHolderEntity2::knot_set(NR::Point const &p, NR::Point const &/*origin*/,
{
SPStar *star = SP_STAR(item);
- NR::Point const s = snap_knot_position(star, p);
+ NR::Point const s = snap_knot_position(p);
if (star->flatsided == false) {
NR::Point d = s - star->center;
@@ -1295,7 +1282,10 @@ OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolde
add_pattern_knotholder();
}
-class FlowtextKnotHolderEntity : public KnotHolderEntity {
+// TODO: this is derived from RectKnotHolderEntityWH because it used the same static function
+// set_internal as the latter before KnotHolderEntity was C++ified. Check whether this also makes
+// sense logically.
+class FlowtextKnotHolderEntity : public RectKnotHolderEntityWH {
public:
virtual NR::Point knot_get();
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
void
FlowtextKnotHolderEntity::knot_set(NR::Point const &p, NR::Point const &origin, guint state)
{
- SPRect *rect = SP_RECT(item);
-
- sp_rect_wh_set_internal(rect, p, origin, state);
+ set_internal(p, origin, state);
}
FlowtextKnotHolder::FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) :