summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-11-03 17:38:18 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-11-03 17:38:18 +0000
commit9b91f5d8683af39ec035e7116154a91d5d2ae4da (patch)
tree1de2839b488b4bf0d77a52979062ebab058c5a48 /src
parentfix compilation. added #include "libnr/nr-values.h" to snapped-line.cpp (diff)
downloadinkscape-9b91f5d8683af39ec035e7116154a91d5d2ae4da.tar.gz
inkscape-9b91f5d8683af39ec035e7116154a91d5d2ae4da.zip
make setup_notepath function for LPE's and LPE parameters.
(bzr r4018)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp28
-rw-r--r--src/live_effects/effect.h7
-rw-r--r--src/live_effects/lpe-gears.cpp10
-rw-r--r--src/live_effects/lpe-gears.h2
-rw-r--r--src/live_effects/parameter/parameter.h5
-rw-r--r--src/live_effects/parameter/path.cpp9
-rw-r--r--src/live_effects/parameter/path.h1
-rw-r--r--src/nodepath.cpp14
-rw-r--r--src/nodepath.h4
9 files changed, 67 insertions, 13 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 859bf8230..03a27b6da 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -35,6 +35,8 @@
#include "live_effects/lpe-gears.h"
#include "live_effects/lpe-curvestitch.h"
+#include "nodepath.h"
+
namespace Inkscape {
namespace LivePathEffect {
@@ -96,7 +98,6 @@ Effect::Effect(LivePathEffectObject *lpeobject)
tooltips = NULL;
lpeobj = lpeobject;
oncanvasedit_it = param_map.begin();
- straight_original_path = false;
}
Effect::~Effect()
@@ -255,13 +256,13 @@ Effect::getWidget()
}
-Inkscape::XML::Node *
+Inkscape::XML::Node *
Effect::getRepr()
{
return SP_OBJECT_REPR(lpeobj);
}
-SPDocument *
+SPDocument *
Effect::getSPDoc()
{
if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("Effect::getSPDoc() returns NULL");
@@ -269,6 +270,19 @@ Effect::getSPDoc()
}
Parameter *
+Effect::getParameter(const char * key)
+{
+ Glib::ustring stringkey(key);
+
+ param_map_type::iterator it = param_map.find(stringkey);
+ if (it != param_map.end()) {
+ return it->second;
+ } else {
+ return NULL;
+ }
+}
+
+Parameter *
Effect::getNextOncanvasEditableParam()
{
oncanvasedit_it++;
@@ -318,6 +332,14 @@ Effect::resetDefaults(SPItem * /*item*/)
// do nothing for simple effects
}
+void
+Effect::setup_notepath(Inkscape::NodePath::Path *np)
+{
+ np->show_helperpath = true;
+ np->helperpath_rgba = 0xff0000ff;
+ np->helperpath_width = 1.0;
+}
+
} /* namespace LivePathEffect */
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 07dd72e47..221f94b40 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -39,6 +39,10 @@ namespace XML {
class Node;
}
+namespace NodePath {
+ class Path ;
+}
+
namespace LivePathEffect {
enum EffectType {
@@ -74,13 +78,14 @@ public:
Inkscape::XML::Node * getRepr();
SPDocument * getSPDoc();
LivePathEffectObject * getLPEObj() {return lpeobj;};
+ Parameter * getParameter(const char * key);
void readallParameters(Inkscape::XML::Node * repr);
void setParameter(const gchar * key, const gchar * new_value);
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
- bool straight_original_path;
+ virtual void setup_notepath(Inkscape::NodePath::Path *np);
protected:
Effect(LivePathEffectObject *lpeobject);
diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp
index 30500e3ab..d5bb8e5ef 100644
--- a/src/live_effects/lpe-gears.cpp
+++ b/src/live_effects/lpe-gears.cpp
@@ -14,6 +14,8 @@
#include <2geom/bezier-to-sbasis.h>
#include <2geom/path.h>
+#include "nodepath.h"
+
using std::vector;
using namespace Geom;
@@ -212,8 +214,6 @@ LPEGears::LPEGears(LivePathEffectObject *lpeobject) :
{
registerParameter( dynamic_cast<Parameter *>(&teeth) );
registerParameter( dynamic_cast<Parameter *>(&phi) );
-
- straight_original_path = true;
}
LPEGears::~LPEGears()
@@ -252,6 +252,12 @@ LPEGears::doEffect (std::vector<Geom::Path> & path_in)
return path_out;
}
+void
+LPEGears::setup_notepath(Inkscape::NodePath::Path *np)
+{
+ Effect::setup_notepath(np);
+ np->straight_path = true;
+}
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-gears.h b/src/live_effects/lpe-gears.h
index c3cea9230..4109c2ed0 100644
--- a/src/live_effects/lpe-gears.h
+++ b/src/live_effects/lpe-gears.h
@@ -24,6 +24,8 @@ public:
std::vector<Geom::Path> doEffect (std::vector<Geom::Path> & path_in);
+ void setup_notepath(Inkscape::NodePath::Path *np);
+
private:
ScalarParam teeth;
ScalarParam phi;
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index a41d5f7c6..614f799c0 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -25,6 +25,10 @@ namespace Gtk {
namespace Inkscape {
+namespace NodePath {
+ class Path ;
+}
+
namespace LivePathEffect {
class Effect;
@@ -49,6 +53,7 @@ public:
virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
virtual void param_editOncanvas(SPItem * item, SPDesktop * dt) { return; };
+ virtual void param_setup_notepath(Inkscape::NodePath::Path *np) { return; };
Glib::ustring param_key;
Inkscape::UI::Widget::Registry * param_wr;
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 68f7be4a9..53e15c9a5 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -31,6 +31,7 @@
#include "node-context.h"
#include "desktop-handles.h"
#include "selection.h"
+#include "nodepath.h"
namespace Inkscape {
@@ -141,6 +142,14 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
}
void
+PathParam::param_setup_notepath(Inkscape::NodePath::Path *np)
+{
+ np->show_helperpath = true;
+ np->helperpath_rgba = 0x009000ff;
+ np->helperpath_width = 1.0;
+}
+
+void
PathParam::param_write_to_repr(const char * svgd)
{
param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index 23f168c48..2f8c766bd 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -47,6 +47,7 @@ public:
void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath);
void param_editOncanvas(SPItem * item, SPDesktop * dt);
+ void param_setup_notepath(Inkscape::NodePath::Path *np);
sigc::signal <void> signal_path_pasted;
sigc::signal <void> signal_path_changed;
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 02b91eab0..5b7565195 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -48,6 +48,7 @@
#include <vector>
#include <algorithm>
#include "live_effects/lpeobject.h"
+#include "live_effects/parameter/parameter.h"
class NR::Matrix;
@@ -218,17 +219,18 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
if (repr_key_in) { // apparantly the object is an LPEObject
np->repr_key = g_strdup(repr_key_in);
np->repr_nodetypes_key = g_strconcat(np->repr_key, "-nodetypes", NULL);
- np->show_helperpath = true;
+ Inkscape::LivePathEffect::Parameter *lpeparam = LIVEPATHEFFECT(object)->lpe->getParameter(repr_key_in);
+ if (lpeparam) {
+ lpeparam->param_setup_notepath(np);
+ }
} else {
np->repr_nodetypes_key = g_strdup("sodipodi:nodetypes");
if ( SP_SHAPE(np->object)->path_effect_href ) {
np->repr_key = g_strdup("inkscape:original-d");
- np->show_helperpath = true;
+
LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(np->object));
- // ENHANCE THIS. Probably it is much nicer to have a virtual method in Effect class that modifies nodepath to its likings.
- // so something like: "lpe->adjust_nodepath(np);"
if (lpeobj && lpeobj->lpe) {
- np->straight_path = lpeobj->lpe->straight_original_path;
+ lpeobj->lpe->setup_notepath(np);
}
} else {
np->repr_key = g_strdup("d");
@@ -258,7 +260,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
SPCurve *helper_curve = sp_curve_copy(np->curve);
sp_curve_transform(helper_curve, np->i2d );
np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(desktop), helper_curve);
- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(np->helper_path), 0xff0000ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ 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);
sp_curve_unref(helper_curve);
diff --git a/src/nodepath.h b/src/nodepath.h
index 6ed9e2225..ee828f4ac 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -21,6 +21,7 @@
#include <list>
+class SPObject;
class SPDesktop;
class SPPath;
class SPKnot;
@@ -237,6 +238,8 @@ class Path {
SPCanvasItem *helper_path;
SPCurve *curve;
bool show_helperpath;
+ guint32 helperpath_rgba;
+ gdouble helperpath_width;
/// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop
unsigned int local_change;
@@ -245,7 +248,6 @@ class Path {
bool show_handles;
/// true if the path cannot contain curves, just straight lines
- // FIXME: NOT IMPLEMENTED YET
bool straight_path;
/// active_node points to the node that is currently mouseovered (= NULL if