summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp44
-rw-r--r--src/live_effects/effect.h11
-rw-r--r--src/live_effects/lpe-gears.cpp4
-rw-r--r--src/live_effects/lpe-skeletalstrokes.cpp15
-rw-r--r--src/live_effects/lpe-test-doEffect-stack.cpp4
-rw-r--r--src/live_effects/lpeobject-reference.cpp4
-rw-r--r--src/live_effects/lpeobject-reference.h4
-rw-r--r--src/live_effects/lpeobject.cpp1
-rw-r--r--src/live_effects/parameter/enum.h32
-rw-r--r--src/live_effects/parameter/parameter.cpp8
-rw-r--r--src/live_effects/parameter/parameter.h18
-rw-r--r--src/live_effects/parameter/path.cpp7
-rw-r--r--src/live_effects/parameter/path.h11
-rw-r--r--src/live_effects/parameter/point.cpp17
-rw-r--r--src/live_effects/parameter/point.h11
15 files changed, 110 insertions, 81 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index a0a8f3db9..404db61fb 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -35,35 +35,42 @@ namespace Inkscape {
namespace LivePathEffect {
-const Util::EnumData<EffectType> LPETypeData[ENDTYPE_LPE] = {
- {INVALID_LPE, _("Invalid effect"), "invalid"},
+const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
{SKELETAL_STROKES, _("Skeletal Strokes"), "skeletal"},
{SLANT, _("Slant"), "slant"},
{DOEFFECTSTACK_TEST, _("doEffect stack test"), "doeffectstacktest"},
{GEARS, _("Gears"), "gears"}
};
-const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, ENDTYPE_LPE);
+const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
Effect*
Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
{
+ Effect* neweffect = NULL;
switch (lpenr) {
- case INVALID_LPE:
- g_warning("LivePathEffect::Effect::New called with invalid patheffect type");
- return NULL;
case SKELETAL_STROKES:
- return (Effect*) new LPESkeletalStrokes(lpeobj);
+ neweffect = (Effect*) new LPESkeletalStrokes(lpeobj);
+ break;
case SLANT:
- return (Effect*) new LPESlant(lpeobj);
+ neweffect = (Effect*) new LPESlant(lpeobj);
+ break;
case DOEFFECTSTACK_TEST:
- return (Effect*) new LPEdoEffectStackTest(lpeobj);
+ neweffect = (Effect*) new LPEdoEffectStackTest(lpeobj);
+ break;
case GEARS:
- return (Effect*) new LPEGears(lpeobj);
- case ENDTYPE_LPE:
- return NULL;
+ neweffect = (Effect*) new LPEGears(lpeobj);
+ break;
+ default:
+ g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
+ neweffect = NULL;
+ break;
}
- return NULL;
+ if (neweffect) {
+ neweffect->readallParameters(SP_OBJECT_REPR(lpeobj));
+ }
+
+ return neweffect;
}
Effect::Effect(LivePathEffectObject *lpeobject)
@@ -83,7 +90,10 @@ Effect::~Effect()
Glib::ustring
Effect::getName()
{
- return Glib::ustring( LPETypeConverter.get_label(lpeobj->effecttype) );
+ if (lpeobj->effecttype_set && lpeobj->effecttype < INVALID_LPE)
+ return Glib::ustring( LPETypeConverter.get_label(lpeobj->effecttype) );
+ else
+ return Glib::ustring( _("No effect") );
}
/*
@@ -211,14 +221,14 @@ Effect::getRepr()
SPDocument *
Effect::getSPDoc()
{
- if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("oh crap");
+ if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("Effect::getSPDoc() returns NULL");
return SP_OBJECT_DOCUMENT(lpeobj);
}
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 0ebd5d5a5..714bcdcab 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -39,15 +39,14 @@ namespace XML {
namespace LivePathEffect {
enum EffectType {
- INVALID_LPE = 0,
- SKELETAL_STROKES,
+ SKELETAL_STROKES = 0,
SLANT,
DOEFFECTSTACK_TEST,
GEARS,
- ENDTYPE_LPE // This must be last
+ INVALID_LPE // This must be last
};
-extern const Util::EnumData<EffectType> LPETypeData[ENDTYPE_LPE];
+extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
class Parameter;
@@ -102,7 +101,7 @@ private:
};
-}; //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace LivePathEffect
+} //namespace Inkscape
#endif
diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp
index 8da819ef6..03e19f31c 100644
--- a/src/live_effects/lpe-gears.cpp
+++ b/src/live_effects/lpe-gears.cpp
@@ -251,8 +251,8 @@ LPEGears::doEffect (std::vector<Geom::Path> & path_in)
}
-}; // namespace LivePathEffect
-}; /* namespace Inkscape */
+} // namespace LivePathEffect
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/lpe-skeletalstrokes.cpp b/src/live_effects/lpe-skeletalstrokes.cpp
index 47c73a56b..e8cff9518 100644
--- a/src/live_effects/lpe-skeletalstrokes.cpp
+++ b/src/live_effects/lpe-skeletalstrokes.cpp
@@ -58,9 +58,9 @@ static const Util::EnumDataConverter<SkelCopyType> SkelCopyTypeConverter(SkelCop
LPESkeletalStrokes::LPESkeletalStrokes(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- pattern(_("Pattern"), _("Pattern to put along path"), "pattern", &wr, this),
- origin(_("Origin"), _("Origin of ?"), "origin", &wr, this),
- copytype(_("Copytype"), _("tooltip"), "copytype", SkelCopyTypeConverter, &wr, this)
+ pattern(_("Pattern"), _("Pattern to put along path"), "pattern", &wr, this, "M0,0 L1,1"),
+ origin(_("Origin"), _("Origin of ?"), "origin", &wr, this, Geom::Point(0,0)),
+ copytype(_("Copytype"), _("tooltip"), "copytype", SkelCopyTypeConverter, &wr, this, SSCT_SINGLE_STRETCHED)
{
registerParameter( dynamic_cast<Parameter *>(&origin) );
registerParameter( dynamic_cast<Parameter *>(&pattern) );
@@ -83,10 +83,7 @@ LPESkeletalStrokes::doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in
/* LOTS OF CODE COPIED FROM 2geom/src/toys/path-along-path.cpp
* All credits should go to jfb and mgsloan of lib2geom development! */
- const Util::EnumData<SkelCopyType> * data = copytype.get_selected_data();
- if (!data)
- return pwd2_in;
- SkelCopyType type = data->id;
+ SkelCopyType type = copytype.get_value();
Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(pwd2_in),2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
@@ -146,8 +143,8 @@ LPESkeletalStrokes::on_pattern_pasted()
-}; // namespace LivePathEffect
-}; /* namespace Inkscape */
+} // namespace LivePathEffect
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp
index 2e3d12725..346d79c9d 100644
--- a/src/live_effects/lpe-test-doEffect-stack.cpp
+++ b/src/live_effects/lpe-test-doEffect-stack.cpp
@@ -81,8 +81,8 @@ LPEdoEffectStackTest::doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_
}
-}; // namespace LivePathEffect
-}; /* namespace Inkscape */
+} // namespace LivePathEffect
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp
index a5392ef90..e4def4301 100644
--- a/src/live_effects/lpeobject-reference.cpp
+++ b/src/live_effects/lpeobject-reference.cpp
@@ -145,9 +145,9 @@ lpeobjectreference_source_modified(SPObject *iSource, guint flags, LPEObjectRefe
lpeobjref->owner->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; // namespace inkscape
+} // namespace inkscape
/*
Local Variables:
diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h
index 7aaa5f691..ff7556d50 100644
--- a/src/live_effects/lpeobject-reference.h
+++ b/src/live_effects/lpeobject-reference.h
@@ -53,9 +53,9 @@ protected:
};
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; // namespace inkscape
+} // namespace inkscape
#endif /* !SEEN_LPEOBJECT_REFERENCE_H */
diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp
index 0ce2ce283..de2baa470 100644
--- a/src/live_effects/lpeobject.cpp
+++ b/src/live_effects/lpeobject.cpp
@@ -179,7 +179,6 @@ livepatheffect_set(SPObject *object, unsigned key, gchar const *value)
lpeobj->effecttype = Inkscape::LivePathEffect::LPETypeConverter.get_id_from_key(value);
if (lpeobj->effecttype != Inkscape::LivePathEffect::INVALID_LPE) {
lpeobj->lpe = Inkscape::LivePathEffect::Effect::New(lpeobj->effecttype, lpeobj);
- lpeobj->lpe->readallParameters(SP_OBJECT_REPR(object));
}
lpeobj->effecttype_set = true;
} else {
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h
index d70360a24..bfc9fd352 100644
--- a/src/live_effects/parameter/enum.h
+++ b/src/live_effects/parameter/enum.h
@@ -28,11 +28,14 @@ public:
const Glib::ustring& tip,
const Glib::ustring& key,
const Util::EnumDataConverter<E>& c,
- Inkscape::UI::Widget::Registry* wr, Effect* effect)
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ E defvalue)
: Parameter(label, tip, key, wr, effect)
{
regenum = NULL;
enumdataconv = &c;
+ value = defvalue;
};
~EnumParam() {
if (regenum)
@@ -44,37 +47,36 @@ public:
regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();
regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
+ regenum->combobox()->set_active_by_id(value);
}
return dynamic_cast<Gtk::Widget *> (regenum->labelled);
};
bool param_readSVGValue(const gchar * strvalue) {
+ if (!strvalue) return false;
+
+ value = enumdataconv->get_id_from_key(Glib::ustring(strvalue));
+
if (regenum)
- regenum->combobox()->set_active_by_key(Glib::ustring(strvalue));
+ regenum->combobox()->set_active_by_id(value);
+
return true;
};
gchar * param_writeSVGValue() const {
- if (regenum) {
- gchar * str = g_strdup(regenum->combobox()->get_active_data()->key.c_str());
- return str;
- } else {
- return NULL;
- }
+ gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
+ return str;
};
- const Util::EnumData<E>* get_selected_data() {
- if (regenum) {
- return regenum->combobox()->get_active_data();
- } else {
- return NULL;
- }
- };
+ E get_value() const {
+ return value;
+ }
private:
EnumParam(const EnumParam&);
EnumParam& operator=(const EnumParam&);
UI::Widget::RegisteredEnum<E> * regenum;
+ E value;
const Util::EnumDataConverter<E> * enumdataconv;
};
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index 6806a1d49..beaafcc22 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -62,6 +62,8 @@ RealParam::param_readSVGValue(const gchar * strvalue)
unsigned int success = sp_svg_number_read_d(strvalue, &newval);
if (success == 1) {
value = newval;
+ if (rsu)
+ rsu->setValue(value);
return true;
}
return false;
@@ -71,7 +73,7 @@ gchar *
RealParam::param_writeSVGValue() const
{
Inkscape::SVGOStringStream os;
- os << rsu->getS()->getValue();
+ os << value;
gchar * str = g_strdup(os.str().c_str());
return str;
}
@@ -89,9 +91,9 @@ RealParam::param_getWidget()
}
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 327d3d153..93cdc94ee 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -28,7 +28,11 @@ class Effect;
class Parameter {
public:
- Parameter(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);
+ Parameter( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect);
virtual ~Parameter() {};
virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
@@ -56,8 +60,12 @@ private:
class RealParam : public Parameter {
public:
- RealParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr, Effect* effect, gdouble initial_value = 1.0);
+ RealParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ gdouble initial_value = 1.0);
~RealParam();
bool param_readSVGValue(const gchar * strvalue);
@@ -77,8 +85,8 @@ private:
};
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 90974f686..d2615901f 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -33,11 +33,12 @@ namespace LivePathEffect {
PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect )
+ Effect* effect, const gchar * defvalue)
: Parameter(label, tip, key, wr, effect)
{
_widget = NULL;
_tooltips = NULL;
+ param_readSVGValue(defvalue);
}
PathParam::~PathParam()
@@ -150,9 +151,9 @@ PathParam::param_write_to_repr(const char * svgd)
}
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index 39ea9e2d8..18ffe5321 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -25,7 +25,12 @@ namespace LivePathEffect {
class PathParam : public Geom::Piecewise<Geom::D2<Geom::SBasis> >, public Parameter {
public:
- PathParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ PathParam ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const gchar * defvalue = "M0,0 L1,1");
~PathParam();
Gtk::Widget * param_getWidget();
@@ -49,8 +54,8 @@ private:
};
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 8079f54eb..39208ad62 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -29,8 +29,8 @@ namespace LivePathEffect {
PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect )
- : Geom::Point(0,0), Parameter(label, tip, key, wr, effect)
+ Effect* effect, Geom::Point defvalue )
+ : Geom::Point(defvalue), Parameter(label, tip, key, wr, effect)
{
_widget = NULL;
pointwdg = NULL;
@@ -58,7 +58,7 @@ PointParam::param_readSVGValue(const gchar * strvalue)
success += sp_svg_number_read_d(strarray[1], &newy);
g_strfreev (strarray);
if (success == 2) {
- *dynamic_cast<Geom::Point *>( this ) = Geom::Point(newx, newy);
+ param_setValue( Geom::Point(newx, newy) );
return true;
}
return false;
@@ -68,7 +68,7 @@ gchar *
PointParam::param_writeSVGValue() const
{
Inkscape::SVGOStringStream os;
- os << pointwdg->getPoint()->getXValue() << "," << pointwdg->getPoint()->getYValue();
+ os << (*this)[0] << "," << (*this)[1];
gchar * str = g_strdup(os.str().c_str());
return str;
}
@@ -79,7 +79,7 @@ PointParam::param_getWidget()
if (!_widget) {
pointwdg = new Inkscape::UI::Widget::RegisteredPoint();
pointwdg->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
- pointwdg->setValue(0.1, 0.2);
+ pointwdg->setValue( (*this)[0], (*this)[1] );
pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
@@ -108,7 +108,8 @@ void
PointParam::param_setValue(Geom::Point newpoint)
{
*dynamic_cast<Geom::Point *>( this ) = newpoint;
- pointwdg->setValue(newpoint[0], newpoint[1]);
+ if (pointwdg)
+ pointwdg->setValue(newpoint[0], newpoint[1]);
}
@@ -150,9 +151,9 @@ PointParam::on_button_click()
}
}
-}; /* namespace LivePathEffect */
+} /* namespace LivePathEffect */
-}; /* namespace Inkscape */
+} /* namespace Inkscape */
/*
Local Variables:
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index 1240ea3d1..368ab63ed 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -27,7 +27,12 @@ namespace LivePathEffect {
class PointParam : public Geom::Point, public Parameter {
public:
- PointParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ PointParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ Geom::Point defvalue = Geom::Point(0,0));
~PointParam();
Gtk::Widget * param_getWidget();
@@ -50,8 +55,8 @@ private:
};
-}; //namespace LivePathEffect
+} //namespace LivePathEffect
-}; //namespace Inkscape
+} //namespace Inkscape
#endif