From: johanengelen Date: Fri, 1 Aug 2008 17:45:13 +0000 (+0000) Subject: change knot.h to Geom::Point only instead of NR::Point. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=41cb516a78b9e54daf81ca4a7e7fc55164c03dfa;p=inkscape.git change knot.h to Geom::Point only instead of NR::Point. --- diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 3d109a69c..1a77008f1 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1151,7 +1151,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) NR::Maybe bbox = sp_item_bbox_desktop(cc->active_shape); if (bbox) { NR::Point center = bbox->midpoint(); - sp_knot_set_position(cc->connpthandle, ¢er, 0); + sp_knot_set_position(cc->connpthandle, center, 0); sp_knot_show(cc->connpthandle); } else { sp_knot_hide(cc->connpthandle); @@ -1171,10 +1171,10 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) { // Just adjust handle positions. NR::Point startpt = curve->first_point() * i2d; - sp_knot_set_position(cc->endpt_handle[0], &startpt, 0); + sp_knot_set_position(cc->endpt_handle[0], startpt, 0); NR::Point endpt = curve->last_point() * i2d; - sp_knot_set_position(cc->endpt_handle[1], &endpt, 0); + sp_knot_set_position(cc->endpt_handle[1], endpt, 0); return; } @@ -1238,10 +1238,10 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) } NR::Point startpt = curve->first_point() * i2d; - sp_knot_set_position(cc->endpt_handle[0], &startpt, 0); + sp_knot_set_position(cc->endpt_handle[0], startpt, 0); NR::Point endpt = curve->last_point() * i2d; - sp_knot_set_position(cc->endpt_handle[1], &endpt, 0); + sp_knot_set_position(cc->endpt_handle[1], endpt, 0); sp_knot_show(cc->endpt_handle[0]); sp_knot_show(cc->endpt_handle[1]); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 7489f9451..71b71b1c3 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -584,7 +584,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p); if (s.getSnapped()) { p = s.getPoint(); - sp_knot_moveto (knot, &p); + sp_knot_moveto (knot, p); } else { bool was_snapped = false; double dist = NR_HUGE; @@ -595,7 +595,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi p[NR::Y] = dragger->parent->hor_levels[i]; s = Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_GRADIENT, dist, snap_dist, false); was_snapped = true; - sp_knot_moveto (knot, &p); + sp_knot_moveto (knot, p); } } for (guint i = 0; i < dragger->parent->vert_levels.size(); i++) { @@ -604,7 +604,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi p[NR::X] = dragger->parent->vert_levels[i]; s = Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_GRADIENT, dist, snap_dist, false); was_snapped = true; - sp_knot_moveto (knot, &p); + sp_knot_moveto (knot, p); } } if (was_snapped) { @@ -685,7 +685,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi } if (move[NR::X] < 9999) { p += move; - sp_knot_moveto (knot, &p); + sp_knot_moveto (knot, p); } g_slist_free(snap_vectors); @@ -837,7 +837,7 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, NR::Point const *ppointer, guin } } drg->point += this_move; - sp_knot_moveto (drgknot, & drg->point); + sp_knot_moveto (drgknot, drg->point); drg->fireDraggables (false); drg->updateDependencies(false); } @@ -1168,7 +1168,7 @@ GrDragger::moveThisToDraggable (SPItem *item, gint point_type, gint point_i, boo this->point = sp_item_gradient_get_coords (item, point_type, point_i, fill_or_stroke); this->point_original = this->point; - sp_knot_moveto (this->knot, &(this->point)); + sp_knot_moveto (this->knot, this->point); for (GSList const* i = this->draggables; i != NULL; i = i->next) { GrDraggable *da = (GrDraggable *) i->data; @@ -1286,7 +1286,7 @@ GrDragger::GrDragger (GrDrag *parent, NR::Point p, GrDraggable *draggable) sp_knot_update_ctrl(this->knot); // move knot to the given point - sp_knot_set_position (this->knot, &p, SP_KNOT_STATE_NORMAL); + sp_knot_set_position (this->knot, p, SP_KNOT_STATE_NORMAL); sp_knot_show (this->knot); // connect knot's signals @@ -1792,7 +1792,7 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial) did = true; d->point += NR::Point (x, y); d->point_original = d->point; - sp_knot_moveto (d->knot, &(d->point)); + sp_knot_moveto (d->knot, d->point); d->fireDraggables (write_repr, scale_radial); @@ -1828,7 +1828,7 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial) GrDragger *drg = (GrDragger*) i->data; SPKnot *drgknot = drg->knot; drg->point += displacement; - sp_knot_moveto (drgknot, & drg->point); + sp_knot_moveto (drgknot, drg->point); drg->fireDraggables (true); drg->updateDependencies(true); did = true; diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 3c95bb0b4..d40fd735a 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -81,7 +81,7 @@ KnotHolderEntity::update_knot() NR::Point dp(knot_get() * i2d); _moved_connection.block(); - sp_knot_set_position(knot, &dp, SP_KNOT_STATE_NORMAL); + sp_knot_set_position(knot, dp, SP_KNOT_STATE_NORMAL); _moved_connection.unblock(); } diff --git a/src/knot.cpp b/src/knot.cpp index 7e4a3dd25..1584769b4 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -189,8 +189,8 @@ static void sp_knot_init(SPKnot *knot) knot->flags = 0; knot->size = 8; - knot->pos = NR::Point(0, 0); - knot->grabbed_rel_pos = NR::Point(0, 0); + knot->pos = Geom::Point(0, 0); + knot->grabbed_rel_pos = Geom::Point(0, 0); knot->anchor = GTK_ANCHOR_CENTER; knot->shape = SP_KNOT_SHAPE_SQUARE; knot->mode = SP_KNOT_MODE_XOR; @@ -261,7 +261,7 @@ static void sp_knot_dispose(GObject *object) /** * Update knot for dragging and tell canvas an item was grabbed. */ -void sp_knot_start_dragging(SPKnot *knot, NR::Point p, gint x, gint y, guint32 etime) +void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y, guint32 etime) { // save drag origin xp = x; @@ -313,7 +313,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot break; case GDK_BUTTON_PRESS: if (event->button.button == 1 && !knot->desktop->event_context->space_panning) { - NR::Point const p = knot->desktop->w2d(NR::Point(event->button.x, event->button.y)); + Geom::Point const p = knot->desktop->w2d(Geom::Point(event->button.x, event->button.y)); sp_knot_start_dragging(knot, p, (gint) event->button.x, (gint) event->button.y, event->button.time); consumed = TRUE; } @@ -377,10 +377,10 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot SP_KNOT_DRAGGING, TRUE); } - NR::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_w(event->motion.x, event->motion.y); NR::Point const motion_dt = knot->desktop->w2d(motion_w); - NR::Point p = motion_dt - knot->grabbed_rel_pos; - sp_knot_request_position (knot, &p, event->motion.state); + Geom::Point p = motion_dt - knot->grabbed_rel_pos; + sp_knot_request_position (knot, p, event->motion.state); knot->desktop->scroll_to_point (&motion_dt); knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different! if (event->motion.state & GDK_BUTTON1_MASK) @@ -506,7 +506,7 @@ void sp_knot_hide(SPKnot *knot) /** * Request or set new position for knot. */ -void sp_knot_request_position(SPKnot *knot, NR::Point *p, guint state) +void sp_knot_request_position(SPKnot *knot, Geom::Point const &p, guint state) { g_return_if_fail(knot != NULL); g_return_if_fail(SP_IS_KNOT(knot)); @@ -515,7 +515,7 @@ void sp_knot_request_position(SPKnot *knot, NR::Point *p, guint state) g_signal_emit(knot, knot_signals[REQUEST], 0, - p, + &p, state, &done); @@ -529,16 +529,16 @@ void sp_knot_request_position(SPKnot *knot, NR::Point *p, guint state) /** * Return distance of point to knot's position; unused. */ -gdouble sp_knot_distance(SPKnot * knot, NR::Point *p, guint state) +gdouble sp_knot_distance(SPKnot * knot, Geom::Point const &p, guint state) { g_return_val_if_fail(knot != NULL, 1e18); g_return_val_if_fail(SP_IS_KNOT(knot), 1e18); - gdouble distance = NR::L2(*p - knot->pos); + gdouble distance = Geom::L2(p - knot->pos); g_signal_emit(knot, knot_signals[DISTANCE], 0, - p, + &p, state, &distance); @@ -548,20 +548,20 @@ gdouble sp_knot_distance(SPKnot * knot, NR::Point *p, guint state) /** * Move knot to new position. */ -void sp_knot_set_position(SPKnot *knot, NR::Point *p, guint state) +void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state) { g_return_if_fail(knot != NULL); g_return_if_fail(SP_IS_KNOT (knot)); - knot->pos = *p; + knot->pos = p; if (knot->item) { - SP_CTRL(knot->item)->moveto (*p); + SP_CTRL(knot->item)->moveto (p); } g_signal_emit(knot, knot_signals[MOVED], 0, - p, + &p, state); knot->_moved_signal.emit(knot, p, state); } @@ -569,22 +569,22 @@ void sp_knot_set_position(SPKnot *knot, NR::Point *p, guint state) /** * Move knot to new position, without emitting a MOVED signal. */ -void sp_knot_moveto(SPKnot *knot, NR::Point *p) +void sp_knot_moveto(SPKnot *knot, Geom::Point const &p) { g_return_if_fail(knot != NULL); g_return_if_fail(SP_IS_KNOT(knot)); - knot->pos = *p; + knot->pos = p; if (knot->item) { - SP_CTRL(knot->item)->moveto (*p); + SP_CTRL(knot->item)->moveto (p); } } /** * Returns position of knot. */ -NR::Point sp_knot_position(SPKnot const *knot) +Geom::Point sp_knot_position(SPKnot const *knot) { g_assert(knot != NULL); g_assert(SP_IS_KNOT (knot)); diff --git a/src/knot.h b/src/knot.h index b1505daac..07c2640c3 100644 --- a/src/knot.h +++ b/src/knot.h @@ -18,7 +18,7 @@ #include #include "display/display-forward.h" #include "forward.h" -#include +#include <2geom/point.h> #include "knot-enums.h" #include @@ -43,9 +43,9 @@ struct SPKnot : GObject { guint flags; guint size; /**< Always square. */ - NR::Point pos; /**< Our desktop coordinates. */ - NR::Point grabbed_rel_pos; /**< Grabbed relative position. */ - NR::Point drag_origin; /**< Origin of drag. */ + Geom::Point pos; /**< Our desktop coordinates. */ + Geom::Point grabbed_rel_pos; /**< Grabbed relative position. */ + Geom::Point drag_origin; /**< Origin of drag. */ GtkAnchorType anchor; /**< Anchor. */ SPKnotShapeType shape; /**< Shape type. */ @@ -68,11 +68,11 @@ struct SPKnot : GObject { // C++ signals /** - sigc::signal _moved_signal; + sigc::signal _moved_signal; sigc::signal _click_signal; - sigc::signal _ungrabbed_signal; + sigc::signal _ungrabbed_signal; **/ - sigc::signal _moved_signal; + sigc::signal _moved_signal; sigc::signal _click_signal; sigc::signal _ungrabbed_signal; @@ -138,14 +138,14 @@ struct SPKnotClass { void (* doubleclicked) (SPKnot *knot, guint state); void (* grabbed) (SPKnot *knot, guint state); void (* ungrabbed) (SPKnot *knot, guint state); - void (* moved) (SPKnot *knot, NR::Point *position, guint state); + void (* moved) (SPKnot *knot, Geom::Point const &position, guint state); void (* stamped) (SPKnot *know, guint state); /** Request knot to move to absolute position. */ - bool (* request) (SPKnot *knot, NR::Point *pos, guint state); + bool (* request) (SPKnot *knot, Geom::Point const &pos, guint state); /** Find complex distance from knot to point. */ - gdouble (* distance) (SPKnot *knot, NR::Point *pos, guint state); + gdouble (* distance) (SPKnot *knot, Geom::Point const &pos, guint state); }; GType sp_knot_get_type(); @@ -163,18 +163,18 @@ void sp_knot_hide(SPKnot *knot); void sp_knot_set_flag(SPKnot *knot, guint flag, bool set); void sp_knot_update_ctrl(SPKnot *knot); -void sp_knot_request_position(SPKnot *knot, NR::Point *pos, guint state); -gdouble sp_knot_distance(SPKnot *knot, NR::Point *p, guint state); +void sp_knot_request_position(SPKnot *knot, Geom::Point const &pos, guint state); +gdouble sp_knot_distance(SPKnot *knot, Geom::Point const &p, guint state); -void sp_knot_start_dragging(SPKnot *knot, NR::Point p, gint x, gint y, guint32 etime); +void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y, guint32 etime); /** Moves knot and emits "moved" signal. */ -void sp_knot_set_position(SPKnot *knot, NR::Point *p, guint state); +void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state); /** Moves knot without any signal. */ -void sp_knot_moveto(SPKnot *knot, NR::Point *p); +void sp_knot_moveto(SPKnot *knot, Geom::Point const &p); -NR::Point sp_knot_position(SPKnot const *knot); +Geom::Point sp_knot_position(SPKnot const *knot); #endif /* !__SP_KNOT_H__ */ diff --git a/src/knotholder.cpp b/src/knotholder.cpp index df50b9ff5..629aa7368 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -132,7 +132,7 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } void -KnotHolder::knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state) +KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) { // this was a local change and the knotholder does not need to be recreated: this->local_change = TRUE; @@ -140,7 +140,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state) for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { - NR::Point const q = *p / from_2geom(sp_item_i2d_affine(item)); + NR::Point const q = p / from_2geom(sp_item_i2d_affine(item)); e->knot_set(q, e->knot->drag_origin / from_2geom(sp_item_i2d_affine(item)), state); break; } diff --git a/src/knotholder.h b/src/knotholder.h index bd57776db..6b838b3c9 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -21,6 +21,7 @@ #include "knot-enums.h" #include "forward.h" #include "libnr/nr-forward.h" +#include <2geom/forward.h> #include "knot-holder-entity.h" #include @@ -44,7 +45,7 @@ public: void update_knots(); - void knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state); + void knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state); void knot_clicked_handler(SPKnot *knot, guint state); void knot_ungrabbed_handler(SPKnot *knot); diff --git a/src/live_effects/parameter/pointparam-knotholder.cpp b/src/live_effects/parameter/pointparam-knotholder.cpp index d92532e32..42601c170 100644 --- a/src/live_effects/parameter/pointparam-knotholder.cpp +++ b/src/live_effects/parameter/pointparam-knotholder.cpp @@ -93,7 +93,7 @@ PointParamKnotHolder::add_knot ( // Move to current point. NR::Point dp = p * from_2geom(sp_item_i2d_affine(item)); - sp_knot_set_position(e->knot, &dp, SP_KNOT_STATE_NORMAL); + sp_knot_set_position(e->knot, dp, SP_KNOT_STATE_NORMAL); e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), this); e->_click_handler_id = g_signal_connect(e->knot, "clicked", G_CALLBACK(pointparam_knot_clicked_handler), this); diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 337731e57..ec9920815 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1705,11 +1705,11 @@ static void sp_node_update_handle(Inkscape::NodePath::Node *node, gint which, gb sp_ctrlline_set_coords(SP_CTRLLINE(side->line), node->pos, side->pos); sp_knot_show(side->knot); } else { - if (side->knot->pos != side->pos) { // only if it's really moved + if (side->knot->pos != to_2geom(side->pos)) { // only if it's really moved if (fire_move_signals) { - sp_knot_set_position(side->knot, &side->pos, 0); // this will set coords of the line as well + sp_knot_set_position(side->knot, side->pos, 0); // this will set coords of the line as well } else { - sp_knot_moveto(side->knot, &side->pos); + sp_knot_moveto(side->knot, side->pos); sp_ctrlline_set_coords(SP_CTRLLINE(side->line), node->pos, side->pos); } } @@ -1744,11 +1744,11 @@ static void sp_node_update_handles(Inkscape::NodePath::Node *node, bool fire_mov sp_knot_show(node->knot); } - if (node->knot->pos != node->pos) { // visible knot is in a different position, need to update + if (node->knot->pos != to_2geom(node->pos)) { // visible knot is in a different position, need to update if (fire_move_signals) - sp_knot_set_position(node->knot, &node->pos, 0); + sp_knot_set_position(node->knot, node->pos, 0); else - sp_knot_moveto(node->knot, &node->pos); + sp_knot_moveto(node->knot, node->pos); } gboolean show_handles = node->selected; @@ -3757,10 +3757,10 @@ static void node_handle_ungrabbed(SPKnot *knot, guint state, gpointer data) // forget origin and set knot position once more (because it can be wrong now due to restrictions) if (n->p.knot == knot) { n->p.origin_radial.a = 0; - sp_knot_set_position(knot, &n->p.pos, state); + sp_knot_set_position(knot, n->p.pos, state); } else if (n->n.knot == knot) { n->n.origin_radial.a = 0; - sp_knot_set_position(knot, &n->n.pos, state); + sp_knot_set_position(knot, n->n.pos, state); } else { g_assert_not_reached(); } @@ -3916,7 +3916,7 @@ static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer other->pos = NR::Point(rother) + n->pos; if (other->knot) { sp_ctrlline_set_coords(SP_CTRLLINE(other->line), n->pos, other->pos); - sp_knot_moveto(other->knot, &other->pos); + sp_knot_moveto(other->knot, other->pos); } } @@ -3925,7 +3925,7 @@ static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer // move knot, but without emitting the signal: // we cannot emit a "moved" signal because we're now processing it - sp_knot_moveto(me->knot, &(me->pos)); + sp_knot_moveto(me->knot, me->pos); update_object(n->subpath->nodepath); @@ -4485,7 +4485,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node * n->n.other = next; n->knot = sp_knot_new(sp->nodepath->desktop, _("Node: drag to edit the path; with Ctrl to snap to horizontal/vertical; with Ctrl+Alt to snap to handles' directions")); - sp_knot_set_position(n->knot, pos, 0); + sp_knot_set_position(n->knot, *pos, 0); n->knot->setShape ((n->type == Inkscape::NodePath::NODE_CUSP)? SP_KNOT_SHAPE_DIAMOND : SP_KNOT_SHAPE_SQUARE); n->knot->setSize ((n->type == Inkscape::NodePath::NODE_CUSP)? 9 : 7); diff --git a/src/proj_pt.h b/src/proj_pt.h index f27719c83..b14dea50e 100644 --- a/src/proj_pt.h +++ b/src/proj_pt.h @@ -12,6 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <2geom/point.h> #include "libnr/nr-point.h" #include "libnr/nr-values.h" #include @@ -26,6 +27,7 @@ public: Pt2 () { pt[0] = 0; pt[1] = 0; pt[2] = 1.0; } // we default to (0 : 0 : 1) Pt2 (double x, double y, double w) { pt[0] = x; pt[1] = y; pt[2] = w; } Pt2 (NR::Point const &point) { pt[0] = point[NR::X]; pt[1] = point[NR::Y]; pt[2] = 1; } + Pt2 (Geom::Point const &point) { pt[0] = point[Geom::X]; pt[1] = point[Geom::Y]; pt[2] = 1; } Pt2 (const gchar *coord_str); inline double operator[] (unsigned int index) const { diff --git a/src/seltrans.cpp b/src/seltrans.cpp index a3e0c9f0b..c478036c7 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -610,7 +610,7 @@ void Inkscape::SelTrans::_updateHandles() sp_knot_hide(_chandle); } else { sp_knot_show(_chandle); - sp_knot_moveto(_chandle, &*_center); + sp_knot_moveto(_chandle, *_center); } } @@ -681,7 +681,7 @@ void Inkscape::SelTrans::_showHandles(SPKnot *knot[], SPSelTransHandle const han + ( _bbox->dimensions() * NR::scale(handle_pt) ) ); - sp_knot_moveto(knot[i], &p); + sp_knot_moveto(knot[i], p); } } @@ -807,7 +807,7 @@ gboolean Inkscape::SelTrans::handleRequest(SPKnot *knot, NR::Point *position, gu return TRUE; } if (handle.request(this, handle, *position, state)) { - sp_knot_set_position(knot, position, state); + sp_knot_set_position(knot, *position, state); SP_CTRL(_grip)->moveto(*position); SP_CTRL(_norm)->moveto(_origin); } diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 9688b8501..dcf8d6e71 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -266,7 +266,7 @@ VPDragger::VPDragger(VPDrag *parent, NR::Point p, VanishingPoint &vp) sp_knot_update_ctrl(this->knot); // move knot to the given point - sp_knot_set_position (this->knot, &this->point, SP_KNOT_STATE_NORMAL); + sp_knot_set_position (this->knot, this->point, SP_KNOT_STATE_NORMAL); sp_knot_show (this->knot); // connect knot's signals