summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44cbde9)
raw | patch | inline | side by side (parent: 44cbde9)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 1 Apr 2006 03:09:42 +0000 (03:09 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 1 Apr 2006 03:09:42 +0000 (03:09 +0000) |
src/nodepath.cpp | patch | blob | history | |
src/nodepath.h | patch | blob | history |
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 26078ea92d30bb6accf1d635ffc9c42c658d8ae8..0a66ff85be99e3af2397e2deec04f2719f580a83 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
np->subpaths = NULL;
np->selected = NULL;
np->nodeContext = NULL; //Let the context that makes this set it
+ np->livarot_path = NULL;
// we need to update item's transform from the repr here,
// because they may be out of sync when we respond
g_free(typestr);
sp_curve_unref(curve);
+ np->livarot_path = Path_for_item(item, true, true);
+ if (np->livarot_path)
+ np->livarot_path->ConvertWithBackData(0.01);
+
return np;
}
g_assert(!np->selected);
+ if (np->livarot_path) {
+ delete np->livarot_path;
+ np->livarot_path = NULL;
+ }
+
np->desktop = NULL;
g_free(np);
}
/**
- * Make curve out of path and associate it with it.
+ * Make curve out of nodepath, write it into that nodepath's SPShape item so that display is
+ * updated but repr is not (for speed). Used during curve and node drag.
*/
static void update_object(Inkscape::NodePath::Path *np)
{
/**
* Update XML path node with data from path object, commit changes forever.
*/
-static void update_repr(Inkscape::NodePath::Path *np)
+void sp_nodepath_update_repr(Inkscape::NodePath::Path *np)
{
update_repr_internal(np);
sp_document_done(SP_DT_DOCUMENT(np->desktop));
+
+ if (np->livarot_path) {
+ delete np->livarot_path;
+ np->livarot_path = NULL;
+ }
+
+ if (np->path && SP_IS_ITEM(np->path)) {
+ np->livarot_path = Path_for_item (np->path, true, true);
+ if (np->livarot_path)
+ np->livarot_path->ConvertWithBackData(0.01);
+ }
}
/**
* Update XML path node with data from path object, commit changes with undo.
*/
-static void update_repr_keyed(Inkscape::NodePath::Path *np, gchar const *key)
+static void sp_nodepath_update_repr_keyed(Inkscape::NodePath::Path *np, gchar const *key)
{
update_repr_internal(np);
sp_document_maybe_done(SP_DT_DOCUMENT(np->desktop), key);
+
+ if (np->livarot_path) {
+ delete np->livarot_path;
+ np->livarot_path = NULL;
+ }
+
+ if (np->path && SP_IS_ITEM(np->path)) {
+ np->livarot_path = Path_for_item (np->path, true, true);
+ if (np->livarot_path)
+ np->livarot_path->ConvertWithBackData(0.01);
+ }
}
/**
sp_nodepath_selected_nodes_move(nodepath, dx, dy, false);
if (dx == 0) {
- update_repr_keyed(nodepath, "node:move:vertical");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:vertical");
} else if (dy == 0) {
- update_repr_keyed(nodepath, "node:move:horizontal");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:horizontal");
} else {
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
}
sp_nodepath_selected_nodes_move(nodepath, zdx, zdy, false);
if (dx == 0) {
- update_repr_keyed(nodepath, "node:move:vertical");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:vertical");
} else if (dy == 0) {
- update_repr_keyed(nodepath, "node:move:horizontal");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:horizontal");
} else {
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
}
@@ -1144,9 +1177,9 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axi
}
}
if (axis == NR::X) {
- update_repr_keyed(nodepath, "node:move:vertical");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:vertical");
} else {
- update_repr_keyed(nodepath, "node:move:horizontal");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:horizontal");
}
}
@@ -1210,9 +1243,9 @@ void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim
}
if (axis == NR::X) {
- update_repr_keyed(nodepath, "node:move:horizontal");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:horizontal");
} else {
- update_repr_keyed(nodepath, "node:move:vertical");
+ sp_nodepath_update_repr_keyed(nodepath, "node:move:vertical");
}
}
/** \todo fixme: adjust ? */
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
}
* Select segment nearest to point
*/
void
-sp_nodepath_select_segment_near_point(SPItem * item, NR::Point p, bool toggle)
+sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) {
return;
}
- Path::cut_position position = get_nearest_position_on_Path(item, p);
+ Path::cut_position position = get_nearest_position_on_Path(nodepath->livarot_path, p);
//find segment to segment
Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(position.piece);
@@ -1286,14 +1318,13 @@ sp_nodepath_select_segment_near_point(SPItem * item, NR::Point p, bool toggle)
* Add a node nearest to point
*/
void
-sp_nodepath_add_node_near_point(SPItem * item, NR::Point p)
+sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) {
return;
}
- Path::cut_position position = get_nearest_position_on_Path(item, p);
+ Path::cut_position position = get_nearest_position_on_Path(nodepath->livarot_path, p);
//find segment to split
Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(position.piece);
/* fixme: adjust ? */
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
}
* cf. app/vectors/gimpbezierstroke.c, gimp_bezier_stroke_point_move_relative()
*/
void
-sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta, char * key)
+sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta)
{
/* feel good is an arbitrary parameter that distributes the delta between handles
* if t of the drag point is less than 1/6 distance form the endpoint only
@@ -1353,7 +1384,7 @@ sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta,
sp_nodepath_ensure_ctrls(e->subpath->nodepath);
- update_repr_keyed(e->subpath->nodepath, key);
+ update_object(e->subpath->nodepath);
sp_nodepath_update_statusbar(e->subpath->nodepath);
}
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
sp_nodepath_ensure_ctrls(sp->nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
return;
}
sp_nodepath_ensure_ctrls(sa->nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
}
sp_nodepath_ensure_ctrls(sp->nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
return;
}
sp_nodepath_ensure_ctrls(sa->nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
return;
}
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
}
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
// if the entire nodepath is removed, delete the selected object.
if (nodepath->subpaths == NULL ||
}
}
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
sp_nodepath_convert_node_type((Inkscape::NodePath::Node *) l->data, type);
}
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
case GDK_BackSpace:
np = active_node->subpath->nodepath;
sp_nodepath_node_destroy(active_node);
- update_repr(np);
+ sp_nodepath_update_repr(np);
active_node = NULL;
ret = TRUE;
break;
} else {
sp_nodepath_convert_node_type (n,Inkscape::NodePath::NODE_CUSP);
}
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
} else { //ctrl+alt+click: delete node
} else {
sp_nodepath_ensure_ctrls(nodepath);
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
}
}
n->dragging_out = NULL;
- update_repr(n->subpath->nodepath);
+ sp_nodepath_update_repr(n->subpath->nodepath);
}
/**
}
sp_node_ensure_ctrls(n);
Inkscape::NodePath::Path *nodepath = n->subpath->nodepath;
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
sp_nodepath_update_statusbar(nodepath);
} else { // just select or add to selection, depending in Shift
g_assert_not_reached();
}
- update_repr(n->subpath->nodepath);
+ sp_nodepath_update_repr(n->subpath->nodepath);
}
/**
@@ -3021,7 +3052,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub
update_object(nodepath);
/// \todo fixme: use _keyed
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
/**
@@ -3146,7 +3177,7 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl
update_object(nodepath);
/// \todo fixme: use _keyed
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
void sp_nodepath_selected_nodes_scale_screen(Inkscape::NodePath::Path *nodepath, gdouble const grow, int const which)
update_object(nodepath);
/// \todo fixme: use _keyed
- update_repr(nodepath);
+ sp_nodepath_update_repr(nodepath);
}
//-----------------------------------------------
diff --git a/src/nodepath.h b/src/nodepath.h
index 84c83be53881c8f523701f5c3871cd8fb955440f..aaa488cf3ff6f58c9d78a3c36599a1cc49d4bf66 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
//#include "sp-path.h"
//#include "desktop-handles.h"
#include "libnr/nr-path-code.h"
+#include "livarot/Path.h"
#include <list>
Inkscape::XML::Node *repr;
//STL compliant method to get the selected nodes
void selection(std::list<Node *> &l);
+
+ /// livarot library is used for "point on path" and "nearest position on path", so we need to maintain its path representation as well
+ ::Path *livarot_path;
};
@@ -235,12 +239,13 @@ void restore_nodepath_selection (Inkscape::NodePath::Path *nodepath, GList *r);
gboolean nodepath_repr_d_changed (Inkscape::NodePath::Path * np, const char *newd);
gboolean nodepath_repr_typestr_changed (Inkscape::NodePath::Path * np, const char *newtypestr);
gboolean node_key (GdkEvent * event);
+void sp_nodepath_update_repr(Inkscape::NodePath::Path *np);
void sp_nodepath_update_statusbar (Inkscape::NodePath::Path *nodepath);
void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
-void sp_nodepath_select_segment_near_point(SPItem * item, NR::Point p, bool toggle);
-void sp_nodepath_add_node_near_point(SPItem * item, NR::Point p);
-void sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta, char * key);
+void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle);
+void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p);
+void sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta);
Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index);
/* possibly private functions */