diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 1239f961bc2f399f149b650b34f36bb5852dc4cd..e03484d7a383033b8af80f7499e5b8040ad11f62 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
#include "display/bezier-utils.h"
#include <vector>
#include <algorithm>
+#include <cstring>
+#include <string>
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
#include "util/mathfns.h"
np->local_change = 0;
np->show_handles = show_handles;
np->helper_path = NULL;
+ np->helperpath_rgba = 0xff0000ff;
+ np->helperpath_width = 1.0;
np->curve = sp_curve_copy(curve);
np->show_helperpath = false;
np->straight_path = false;
np->repr_nodetypes_key = g_strconcat(np->repr_key, "-nodetypes", NULL);
Inkscape::LivePathEffect::Parameter *lpeparam = LIVEPATHEFFECT(object)->lpe->getParameter(repr_key_in);
if (lpeparam) {
- lpeparam->param_setup_notepath(np);
+ lpeparam->param_setup_nodepath(np);
}
} else {
np->repr_nodetypes_key = g_strdup("sodipodi:nodetypes");
LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(np->object));
if (lpeobj && lpeobj->lpe) {
- lpeobj->lpe->setup_notepath(np);
+ lpeobj->lpe->setup_nodepath(np);
}
} else {
np->repr_key = g_strdup("d");
@@ -1372,6 +1376,51 @@ sp_node_selected_move_screen(Inkscape::NodePath::Path *nodepath, gdouble dx, gdo
}
}
+/**
+ * Move selected nodes to the absolute position given
+ */
+void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, NR::Coord val, NR::Dim2 axis)
+{
+ for (GList *l = nodepath->selected; l != NULL; l = l->next) {
+ Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
+ NR::Point npos(axis == NR::X ? val : n->pos[NR::X], axis == NR::Y ? val : n->pos[NR::Y]);
+ sp_node_moveto(n, npos);
+ }
+
+ sp_nodepath_update_repr(nodepath, _("Move nodes"));
+}
+
+/**
+ * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return NR::Nothing
+ */
+NR::Maybe<NR::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis)
+{
+ NR::Maybe<NR::Coord> no_coord = NR::Nothing();
+ g_return_val_if_fail(nodepath->selected, no_coord);
+
+ // determine coordinate of first selected node
+ GList *nsel = nodepath->selected;
+ Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nsel->data;
+ NR::Coord coord = n->pos[axis];
+ bool coincide = true;
+
+ // compare it to the coordinates of all the other selected nodes
+ for (GList *l = nsel->next; l != NULL; l = l->next) {
+ n = (Inkscape::NodePath::Node *) l->data;
+ if (n->pos[axis] != coord) {
+ coincide = false;
+ }
+ }
+ if (coincide) {
+ return coord;
+ } else {
+ NR::Rect bbox = sp_node_selected_bbox(nodepath);
+ // currently we return the coordinate of the bounding box midpoint because I don't know how
+ // to erase the spin button entry field :), but maybe this can be useful behaviour anyway
+ return bbox.midpoint()[axis];
+ }
+}
+
/** If they don't yet exist, creates knot and line for the given side of the node */
static void sp_node_ensure_knot_exists (SPDesktop *desktop, Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeSide *side)
{
@@ -3933,13 +3982,7 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, NR::Ma
} else {
// scale nodes as an "object":
- Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
- NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node
- for (GList *l = nodepath->selected; l != NULL; l = l->next) {
- Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
- box.expandTo (n->pos); // contain all selected nodes
- }
-
+ NR::Rect box = sp_node_selected_bbox (nodepath);
if (!center) {
center = box.midpoint();
}
@@ -3960,6 +4003,19 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, NR::Ma
sp_nodepath_update_repr(nodepath, _("Flip nodes"));
}
+NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath)
+{
+ g_assert (nodepath->selected);
+
+ Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
+ NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node
+ for (GList *l = nodepath->selected; l != NULL; l = l->next) {
+ Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
+ box.expandTo (n->pos); // contain all selected nodes
+ }
+ return box;
+}
+
//-----------------------------------------------
/**
* Return new subpath under given nodepath.
@@ -4392,6 +4448,8 @@ sp_nodepath_update_statusbar(Inkscape::NodePath::Path *nodepath)//!!!move to Sha
Inkscape::MessageContext *mc = SP_NODE_CONTEXT (ec)->_node_message_context;
if (!mc) return;
+ inkscape_active_desktop()->emitToolSubselectionChanged(NULL);
+
if (selected_nodes == 0) {
Inkscape::Selection *sel = desktop->selection;
if (!sel || sel->isEmpty()) {
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
np->show_helperpath = show;
+
+ if (show) {
+ SPCurve *helper_curve = sp_curve_copy(np->curve);
+ sp_curve_transform(helper_curve, np->i2d );
+ if (!np->helper_path) {
+ np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(np->desktop), helper_curve);
+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(np->helper_path), np->helperpath_rgba, np->helperpath_width, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(np->helper_path), 0, SP_WIND_RULE_NONZERO);
+ sp_canvas_item_show(np->helper_path);
+ } else {
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(np->helper_path), helper_curve);
+ }
+ sp_curve_unref(helper_curve);
+ } else {
+ if (np->helper_path) {
+ GtkObject *temp = np->helper_path;
+ np->helper_path = NULL;
+ gtk_object_destroy(temp);
+ }
+ }
}
/* this function does not work yet */