summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1db439a)
raw | patch | inline | side by side (parent: 1db439a)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 19 Aug 2007 20:34:48 +0000 (20:34 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 19 Aug 2007 20:34:48 +0000 (20:34 +0000) |
index 901b80fccd0c1e70fc4d673406cd8c57ad575cbf..1e86ab479be37adc0108183c738527e262054081 100644 (file)
Effect::doEffect (std::vector<Geom::Path> & path_in)\r
{\r
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in;\r
- // FIXME: find standard function to convert std::vector<Geom::Path> ==> Piecewise< D2<SBasis> >\r
+\r
for (unsigned int i=0; i < path_in.size(); i++) {\r
pwd2_in.concat( path_in[i].toPwSb() );\r
}\r
@@ -169,11 +169,18 @@ Effect::setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar
\r
param_map_type::iterator it = param_map.find(stringkey);\r
if (it != param_map.end()) {\r
- bool accepted = it->second->param_readSVGValue(new_value);\r
- /* think: can this backfire and create infinite loop when started with unacceptable old_value?\r
- if (!accepted) { // change was not accepted, so change it back.\r
- repr->setAttribute(key, old_value);\r
- } */\r
+ if (new_value) {\r
+ bool accepted = it->second->param_readSVGValue(new_value);\r
+ if (!accepted) { \r
+ g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key);\r
+ // change was not accepted, so change it back.\r
+ // think: can this backfire and create infinite loop when started with unacceptable old_value?\r
+ // repr->setAttribute(key, old_value);\r
+ }\r
+ } else {\r
+ // set default value\r
+ it->second->param_set_default();\r
+ }\r
}\r
}\r
\r
index bfc9fd35206fbac4b5bed31d2ed56390a5336707..9b8c0f91ebca320aaae7817864fe0c02ecc1d5d5 100644 (file)
const Util::EnumDataConverter<E>& c,\r
Inkscape::UI::Widget::Registry* wr,\r
Effect* effect,\r
- E defvalue)\r
+ E default_value)\r
: Parameter(label, tip, key, wr, effect)\r
{\r
regenum = NULL;\r
enumdataconv = &c;\r
+ defvalue = default_value;\r
value = defvalue;\r
};\r
~EnumParam() {\r
};\r
\r
bool param_readSVGValue(const gchar * strvalue) {\r
- if (!strvalue) return false;\r
+ if (!strvalue) {\r
+ param_set_default();\r
+ return true;\r
+ }\r
\r
- value = enumdataconv->get_id_from_key(Glib::ustring(strvalue));\r
-\r
- if (regenum)\r
- regenum->combobox()->set_active_by_id(value);\r
+ param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );\r
\r
return true;\r
};\r
return value;\r
}\r
\r
+ void param_set_default() {\r
+ param_set_value(defvalue);\r
+ }\r
+\r
+ void param_set_value(E val) {\r
+ value = val;\r
+ if (regenum)\r
+ regenum->combobox()->set_active_by_id(value);\r
+ }\r
+\r
private:\r
EnumParam(const EnumParam&);\r
EnumParam& operator=(const EnumParam&);\r
\r
UI::Widget::RegisteredEnum<E> * regenum;\r
E value;\r
+ E defvalue;\r
\r
const Util::EnumDataConverter<E> * enumdataconv;\r
};\r
index beaafcc22a156a2cba179faa4d132e7a625caafc..91df62e810e72a9ac94d90ede4d44c3ba86e6ded 100644 (file)
*/\r
RealParam::RealParam( const Glib::ustring& label, const Glib::ustring& tip,\r
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
- Effect* effect, gdouble initial_value)\r
+ Effect* effect, gdouble default_value)\r
: Parameter(label, tip, key, wr, effect)\r
{\r
- value = initial_value;\r
+ defvalue = default_value;\r
+ value = defvalue;\r
rsu = NULL;\r
}\r
\r
double newval;\r
unsigned int success = sp_svg_number_read_d(strvalue, &newval);\r
if (success == 1) {\r
- value = newval;\r
- if (rsu)\r
- rsu->setValue(value);\r
+ param_set_value(newval);\r
return true;\r
}\r
return false;\r
return str;\r
}\r
\r
+void\r
+RealParam::param_set_default() \r
+{\r
+ param_set_value(defvalue);\r
+}\r
+\r
+void\r
+RealParam::param_set_value(gdouble val) \r
+{\r
+ value = val;\r
+ if (rsu)\r
+ rsu->setValue(value);\r
+}\r
+\r
+\r
Gtk::Widget *\r
RealParam::param_getWidget()\r
{\r
index 93cdc94ee03a312983f4a47b08bdafbc0865397e..942def5b86d8b4f1f24c9f5f42c279da3060ebc1 100644 (file)
virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.\r
virtual gchar * param_writeSVGValue() const = 0;\r
\r
+ virtual void param_set_default() = 0;\r
+\r
// This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the\r
// necessary widget if it does not exist yet.\r
virtual Gtk::Widget * param_getWidget() = 0;\r
const Glib::ustring& key, \r
Inkscape::UI::Widget::Registry* wr,\r
Effect* effect,\r
- gdouble initial_value = 1.0);\r
+ gdouble default_value = 1.0);\r
~RealParam();\r
\r
bool param_readSVGValue(const gchar * strvalue);\r
gchar * param_writeSVGValue() const;\r
\r
+ void param_set_default();\r
+ void param_set_value(gdouble val);\r
+\r
Gtk::Widget * param_getWidget();\r
\r
inline operator gdouble()\r
RealParam& operator=(const RealParam&);\r
\r
gdouble value;\r
+ gdouble defvalue;\r
Inkscape::UI::Widget::RegisteredScalar * rsu;\r
};\r
\r
index d2615901f170eb4ff22abd15c104388fe951d4c0..f24fa933a053da5736ec95fca3742b7bb8abdf4e 100644 (file)
\r
PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,\r
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
- Effect* effect, const gchar * defvalue)\r
+ Effect* effect, const gchar * default_value)\r
: Parameter(label, tip, key, wr, effect)\r
{\r
_widget = NULL;\r
_tooltips = NULL;\r
+ defvalue = g_strdup(default_value);\r
param_readSVGValue(defvalue);\r
}\r
\r
if (_tooltips)\r
delete _tooltips;\r
// _widget is managed by GTK so do not delete!\r
+\r
+ g_free(defvalue);\r
+}\r
+\r
+void\r
+PathParam::param_set_default()\r
+{\r
+ param_readSVGValue(defvalue);\r
}\r
\r
bool\r
index 18ffe5321d7e6480281910d3c55fbcbc2dd0d143..0b0d5f633e19a0528746bc5706086eb74ff60328 100644 (file)
const Glib::ustring& key,\r
Inkscape::UI::Widget::Registry* wr,\r
Effect* effect,\r
- const gchar * defvalue = "M0,0 L1,1");\r
+ const gchar * default_value = "M0,0 L1,1");\r
~PathParam();\r
\r
Gtk::Widget * param_getWidget();\r
bool param_readSVGValue(const gchar * strvalue);\r
gchar * param_writeSVGValue() const;\r
\r
+ void param_set_default();\r
+\r
sigc::signal <void> signal_path_pasted;\r
\r
private:\r
\r
void on_edit_button_click();\r
void on_paste_button_click();\r
+\r
+ gchar * defvalue;\r
};\r
\r
\r
index 39208ad620f223ab7001c80ee50b87f2ecf6ebc2..3c42dcbfecc8d85539fd00e656bae036e4aa87ce 100644 (file)
\r
PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,\r
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
- Effect* effect, Geom::Point defvalue )\r
- : Geom::Point(defvalue), Parameter(label, tip, key, wr, effect)\r
+ Effect* effect, Geom::Point default_value )\r
+ : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)\r
{\r
_widget = NULL;\r
pointwdg = NULL;\r
g_object_unref (G_OBJECT (knot));\r
}\r
\r
+void\r
+PointParam::param_set_default()\r
+{\r
+ param_setValue(defvalue);\r
+}\r
+\r
bool\r
PointParam::param_readSVGValue(const gchar * strvalue)\r
{\r
index 368ab63ed4abcafd5039e5be54b31a4206d6bc8e..c1d6681a255df10e12e72272897165f0e0c07fe4 100644 (file)
const Glib::ustring& key,\r
Inkscape::UI::Widget::Registry* wr,\r
Effect* effect,\r
- Geom::Point defvalue = Geom::Point(0,0));\r
+ Geom::Point default_value = Geom::Point(0,0));\r
~PointParam();\r
\r
Gtk::Widget * param_getWidget();\r
gchar * param_writeSVGValue() const;\r
\r
void param_setValue(Geom::Point newpoint);\r
+ void param_set_default();\r
\r
private:\r
PointParam(const PointParam&);\r
void on_button_click();\r
\r
SPKnot *knot;\r
+\r
+ Geom::Point defvalue;\r
};\r
\r
\r