summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f97d0e)
raw | patch | inline | side by side (parent: 4f97d0e)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 30 Oct 2007 22:37:20 +0000 (22:37 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 30 Oct 2007 22:37:20 +0000 (22:37 +0000) |
index 3802066ec7549efec3d71b40eb25b52ec6083661..859bf8230785c5b1a2b4167606215d9ca4f0daef 100644 (file)
// include effects:
#include "live_effects/lpe-skeletalstrokes.h"
+#include "live_effects/lpe-pathalongpath.h"
#include "live_effects/lpe-slant.h"
#include "live_effects/lpe-test-doEffect-stack.h"
#include "live_effects/lpe-gears.h"
const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
// {constant defined in effect.h, N_("name of your effect"), "name of your effect in SVG"}
- {SKELETAL_STROKES, N_("Path along path"), "skeletal"},
+ {PATH_ALONG_PATH, N_("Path along path"), "path_along_path"},
+ {SKELETAL_STROKES, N_("[obsolete?] Pattern along path"), "skeletal"},
#ifdef LPE_ENABLE_TEST_EFFECTS
{SLANT, N_("Slant"), "slant"},
{DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"},
case SKELETAL_STROKES:
neweffect = (Effect*) new LPESkeletalStrokes(lpeobj);
break;
+ case PATH_ALONG_PATH:
+ neweffect = (Effect*) new LPEPathAlongPath(lpeobj);
+ break;
#ifdef LPE_ENABLE_TEST_EFFECTS
case SLANT:
neweffect = (Effect*) new LPESlant(lpeobj);
tooltips = NULL;
lpeobj = lpeobject;
oncanvasedit_it = param_map.begin();
+ straight_original_path = false;
}
Effect::~Effect()
}
}
+/* This function should reset the defaults and is used for example to initialize an effect right after it has been applied to a path
+* The nice thing about this is that this function can use knowledge of the original path and set things accordingly for example to the size or origin of the original path!
+*/
+void
+Effect::resetDefaults(SPItem * /*item*/)
+{
+ // do nothing for simple effects
+}
+
+
} /* namespace LivePathEffect */
} /* namespace Inkscape */
index 844a158b59ca9e59ccf1f2aa1b62b2c7386d9e69..07dd72e47ebb9299057593ce060393a150ccc85e 100644 (file)
namespace LivePathEffect {
enum EffectType {
- SKELETAL_STROKES = 0,
+ PATH_ALONG_PATH = 0,
+ SKELETAL_STROKES,
#ifdef LPE_ENABLE_TEST_EFFECTS
SLANT,
DOEFFECTSTACK_TEST,
class Effect {
public:
- virtual ~Effect();
+ static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
- Glib::ustring getName();
+ virtual ~Effect();
virtual void doEffect (SPCurve * curve);
- static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
-
virtual Gtk::Widget * getWidget();
- Inkscape::XML::Node * getRepr();
- SPDocument * getSPDoc();
+ virtual void resetDefaults(SPItem * item);
+
+ Glib::ustring getName();
+ Inkscape::XML::Node * getRepr();
+ SPDocument * getSPDoc();
LivePathEffectObject * getLPEObj() {return lpeobj;};
void readallParameters(Inkscape::XML::Node * repr);
void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
+ bool straight_original_path;
+
protected:
Effect(LivePathEffectObject *lpeobject);
index 2176f3ba7881fea3c9e56b7de591a8a8bf1bcf86..30500e3ab28582457e20b6a1bac1e18612d7e021 100644 (file)
{
registerParameter( dynamic_cast<Parameter *>(&teeth) );
registerParameter( dynamic_cast<Parameter *>(&phi) );
+
+ straight_original_path = true;
}
LPEGears::~LPEGears()
index 2b558d2dda59a93858a5e62211aa15687df1d393..68f7be4a946a05a79bc2d962ea91ece3e5362c0f 100644 (file)
}
+void
+PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath)
+{
+ const std::vector<Geom::Path> temppath = Geom::path_from_piecewise(newpath, LPE_CONVERSION_TOLERANCE);
+ gchar * svgd = SVGD_from_2GeomPath( temppath );
+ param_write_to_repr(svgd);
+ g_free(svgd);
+}
+
/* CALLBACK FUNCTIONS FOR THE BUTTONS */
void
PathParam::on_edit_button_click()
index 6ba6e7e4b77417326f4e11aa13ca4317ec00b270..23f168c48c88775fea95894e54d9132f7c62c467 100644 (file)
void param_set_default();
+ void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath);
+
void param_editOncanvas(SPItem * item, SPDesktop * dt);
sigc::signal <void> signal_path_pasted;
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index fa80f3baad0b579078c32c1168e854c95751230b..02b91eab06d863a27745f35a4c865171c7fede17 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -224,6 +224,12 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
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;
+ }
} else {
np->repr_key = g_strdup("d");
}
@@ -2372,6 +2378,8 @@ sp_node_selected_set_type(Inkscape::NodePath::Path *nodepath, Inkscape::NodePath
{
if (nodepath == NULL) return;
+ if (nodepath->straight_path) return; // don't change type when it is a straight path!
+
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
sp_nodepath_convert_node_type((Inkscape::NodePath::Node *) l->data, type);
}
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
// If either (Shift and some handle retracted), or (we're already dragging out a handle)
- if (((state & GDK_SHIFT_MASK) && ((n->n.other && n->n.pos == n->pos) || (n->p.other && n->p.pos == n->pos))) || n->dragging_out) {
-
+ if ( (!n->subpath->nodepath->straight_path) &&
+ ( ((state & GDK_SHIFT_MASK) && ((n->n.other && n->n.pos == n->pos) || (n->p.other && n->p.pos == n->pos)))
+ || n->dragging_out ) )
+ {
NR::Point mouse = (*p);
if (!n->dragging_out) {
np->show_helperpath = show;
}
+/* this function does not work yet */
void sp_nodepath_make_straight_path(Inkscape::NodePath::Path *np) {
np->straight_path = true;
np->show_handles = false;
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 55f3183e53dc027b8a0a25a7478a83f0e168c252..508d2228d3cdec2f551f8d2c0ec23d0955a0c83c 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
}
void ShapeEditor::show_handles (bool show) {
- if (this->nodepath)
+ if (this->nodepath && !this->nodepath->straight_path)
sp_nodepath_show_handles (this->nodepath, show);
}
index ec6c5c6ee7457cec187376f9488c7e00851916cc..b60d7e35774807b1d5945231d9f3a2eacecd9676 100644 (file)
@@ -108,7 +108,8 @@ LivePathEffectEditor::LivePathEffectEditor(Behavior::BehaviorFactory behavior_fa
setDesktop(SP_ACTIVE_DESKTOP);
show_all_children();
- button_remove.hide();
+
+ button_remove.hide();
}
LivePathEffectEditor::~LivePathEffectEditor()
}
}
+ LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(item));
+ if (lpeobj && lpeobj->lpe) {
+ lpeobj->lpe->resetDefaults(item);
+ }
+
sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Create and apply path effect"));
}