summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorPeter Moulder <peter.moulder@monash.edu>2007-10-11 14:30:52 +0000
committerpjrm <pjrm@users.sourceforge.net>2007-10-11 14:30:52 +0000
commitb7403d737c0549e540393bfe92160a5fc7b407a1 (patch)
tree784c7cbfd26a14f67679376a700dce1d61262bb1 /src/live_effects/parameter
parenttrivial: ui/widget/*, ui/dialog/*: svn propset svn:eol-style native *.h *.cpp. (diff)
downloadinkscape-b7403d737c0549e540393bfe92160a5fc7b407a1.tar.gz
inkscape-b7403d737c0549e540393bfe92160a5fc7b407a1.zip
trivial: live_effects/**: svn propset svn:eol-style native *.h *.cpp.
(bzr r3884)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/bool.cpp186
-rw-r--r--src/live_effects/parameter/bool.h118
-rw-r--r--src/live_effects/parameter/enum.h202
-rw-r--r--src/live_effects/parameter/parameter.cpp362
-rw-r--r--src/live_effects/parameter/parameter.h216
-rw-r--r--src/live_effects/parameter/path.cpp364
-rw-r--r--src/live_effects/parameter/path.h132
-rw-r--r--src/live_effects/parameter/point.cpp346
-rw-r--r--src/live_effects/parameter/point.h130
-rw-r--r--src/live_effects/parameter/random.cpp388
-rw-r--r--src/live_effects/parameter/random.h152
11 files changed, 1298 insertions, 1298 deletions
diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp
index 36806242f..78ce17939 100644
--- a/src/live_effects/parameter/bool.cpp
+++ b/src/live_effects/parameter/bool.cpp
@@ -1,93 +1,93 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_CPP
-
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/bool.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "svg/stringstream.h"
-#include <gtkmm.h>
-#include "widgets/icon.h"
-
-#include "inkscape.h"
-#include "verbs.h"
-#include "helper-fns.h"
-
-#define noLPEBOOLPARAM_DEBUG
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, bool default_value )
- : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
-{
- checkwdg = NULL;
-}
-
-BoolParam::~BoolParam()
-{
- if (checkwdg)
- delete checkwdg;
-}
-
-void
-BoolParam::param_set_default()
-{
- param_setValue(defvalue);
-}
-
-bool
-BoolParam::param_readSVGValue(const gchar * strvalue)
-{
- param_setValue(helperfns_read_bool(strvalue, defvalue));
- return true; // not correct: if value is unacceptable, should return false!
-}
-
-gchar *
-BoolParam::param_writeSVGValue() const
-{
- gchar * str = g_strdup(value ? "true" : "false");
- return str;
-}
-
-Gtk::Widget *
-BoolParam::param_getWidget()
-{
- if (!checkwdg) {
- checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
- checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
- checkwdg->setActive(value);
- checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
- }
- return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
-}
-
-void
-BoolParam::param_setValue(bool newvalue)
-{
- value = newvalue;
- if (checkwdg)
- checkwdg->setActive(newvalue);
-}
-
-} /* namespace LivePathEffect */
-
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/bool.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include <gtkmm.h>
+#include "widgets/icon.h"
+
+#include "inkscape.h"
+#include "verbs.h"
+#include "helper-fns.h"
+
+#define noLPEBOOLPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, bool default_value )
+ : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
+{
+ checkwdg = NULL;
+}
+
+BoolParam::~BoolParam()
+{
+ if (checkwdg)
+ delete checkwdg;
+}
+
+void
+BoolParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+
+bool
+BoolParam::param_readSVGValue(const gchar * strvalue)
+{
+ param_setValue(helperfns_read_bool(strvalue, defvalue));
+ return true; // not correct: if value is unacceptable, should return false!
+}
+
+gchar *
+BoolParam::param_writeSVGValue() const
+{
+ gchar * str = g_strdup(value ? "true" : "false");
+ return str;
+}
+
+Gtk::Widget *
+BoolParam::param_getWidget()
+{
+ if (!checkwdg) {
+ checkwdg = new Inkscape::UI::Widget::RegisteredCheckButton();
+ checkwdg->init(param_label, param_tooltip, param_key, *param_wr, false, param_effect->getRepr(), param_effect->getSPDoc());
+ checkwdg->setActive(value);
+ checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (checkwdg->_button);
+}
+
+void
+BoolParam::param_setValue(bool newvalue)
+{
+ value = newvalue;
+ if (checkwdg)
+ checkwdg->setActive(newvalue);
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h
index 0a29a9439..13dc57b6c 100644
--- a/src/live_effects/parameter/bool.h
+++ b/src/live_effects/parameter/bool.h
@@ -1,59 +1,59 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib/gtypes.h>
-
-#include "ui/widget/registry.h"
-#include "ui/widget/registered-widget.h"
-
-#include "live_effects/parameter/parameter.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-
-class BoolParam : public Parameter {
-public:
- BoolParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- bool default_value = false);
- virtual ~BoolParam();
-
- virtual Gtk::Widget * param_getWidget();
-
- virtual bool param_readSVGValue(const gchar * strvalue);
- virtual gchar * param_writeSVGValue() const;
-
- void param_setValue(bool newvalue);
- virtual void param_set_default();
-
- bool get_value() { return value; };
-
-private:
- BoolParam(const BoolParam&);
- BoolParam& operator=(const BoolParam&);
-
- Inkscape::UI::Widget::RegisteredCheckButton * checkwdg;
-
- bool value;
- bool defvalue;
-};
-
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+
+#include "live_effects/parameter/parameter.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+
+class BoolParam : public Parameter {
+public:
+ BoolParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ bool default_value = false);
+ virtual ~BoolParam();
+
+ virtual Gtk::Widget * param_getWidget();
+
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_writeSVGValue() const;
+
+ void param_setValue(bool newvalue);
+ virtual void param_set_default();
+
+ bool get_value() { return value; };
+
+private:
+ BoolParam(const BoolParam&);
+ BoolParam& operator=(const BoolParam&);
+
+ Inkscape::UI::Widget::RegisteredCheckButton * checkwdg;
+
+ bool value;
+ bool defvalue;
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h
index 4fd948ee6..4ee28f895 100644
--- a/src/live_effects/parameter/enum.h
+++ b/src/live_effects/parameter/enum.h
@@ -1,101 +1,101 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib/gtypes.h>
-
-#include "ui/widget/registry.h"
-#include "ui/widget/registered-enums.h"
-#include <gtkmm/tooltips.h>
-
-#include "live_effects/parameter/parameter.h"
-#include "verbs.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-template<typename E> class EnumParam : public Parameter {
-public:
- EnumParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- const Util::EnumDataConverter<E>& c,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- E default_value)
- : Parameter(label, tip, key, wr, effect)
- {
- regenum = NULL;
- enumdataconv = &c;
- defvalue = default_value;
- value = defvalue;
- };
- ~EnumParam() {
- if (regenum)
- delete regenum;
- };
-
- Gtk::Widget * param_getWidget() {
- if (!regenum) {
- 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->combobox()->set_active_by_id(value);
- regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
- }
- return dynamic_cast<Gtk::Widget *> (regenum->labelled);
- };
-
- bool param_readSVGValue(const gchar * strvalue) {
- if (!strvalue) {
- param_set_default();
- return true;
- }
-
- param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );
-
- return true;
- };
- gchar * param_writeSVGValue() const {
- gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
- return str;
- };
-
- E get_value() const {
- return value;
- }
-
- void param_set_default() {
- param_set_value(defvalue);
- }
-
- void param_set_value(E val) {
- value = val;
- if (regenum)
- regenum->combobox()->set_active_by_id(value);
- }
-
-private:
- EnumParam(const EnumParam&);
- EnumParam& operator=(const EnumParam&);
-
- UI::Widget::RegisteredEnum<E> * regenum;
- E value;
- E defvalue;
-
- const Util::EnumDataConverter<E> * enumdataconv;
-};
-
-
-}; //namespace LivePathEffect
-
-}; //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-enums.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+#include "verbs.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+template<typename E> class EnumParam : public Parameter {
+public:
+ EnumParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ const Util::EnumDataConverter<E>& c,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ E default_value)
+ : Parameter(label, tip, key, wr, effect)
+ {
+ regenum = NULL;
+ enumdataconv = &c;
+ defvalue = default_value;
+ value = defvalue;
+ };
+ ~EnumParam() {
+ if (regenum)
+ delete regenum;
+ };
+
+ Gtk::Widget * param_getWidget() {
+ if (!regenum) {
+ 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->combobox()->set_active_by_id(value);
+ regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (regenum->labelled);
+ };
+
+ bool param_readSVGValue(const gchar * strvalue) {
+ if (!strvalue) {
+ param_set_default();
+ return true;
+ }
+
+ param_set_value( enumdataconv->get_id_from_key(Glib::ustring(strvalue)) );
+
+ return true;
+ };
+ gchar * param_writeSVGValue() const {
+ gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
+ return str;
+ };
+
+ E get_value() const {
+ return value;
+ }
+
+ void param_set_default() {
+ param_set_value(defvalue);
+ }
+
+ void param_set_value(E val) {
+ value = val;
+ if (regenum)
+ regenum->combobox()->set_active_by_id(value);
+ }
+
+private:
+ EnumParam(const EnumParam&);
+ EnumParam& operator=(const EnumParam&);
+
+ UI::Widget::RegisteredEnum<E> * regenum;
+ E value;
+ E defvalue;
+
+ const Util::EnumDataConverter<E> * enumdataconv;
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index faed7c389..efca9908d 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -1,181 +1,181 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_CPP
-
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/parameter.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "libnr/nr-values.h"
-
-#include <gtkmm.h>
-#include "ui/widget/scalar.h"
-
-#include "svg/stringstream.h"
-
-#include "verbs.h"
-
-#define noLPEREALPARAM_DEBUG
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-
-Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect )
-{
- param_label = label;
- param_tooltip = tip;
- param_key = key;
- param_wr = wr;
- param_effect = effect;
-}
-
-
-
-/*###########################################
- * REAL PARAM
- */
-ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, gdouble default_value)
- : Parameter(label, tip, key, wr, effect)
-{
- defvalue = default_value;
- value = defvalue;
- min = -NR_HUGE;
- max = NR_HUGE;
- integer = false;
- rsu = NULL;
- inc_step = 0.1;
- inc_page = 1;
- digits = 2;
-}
-
-ScalarParam::~ScalarParam()
-{
- if (rsu)
- delete rsu;
-}
-
-bool
-ScalarParam::param_readSVGValue(const gchar * strvalue)
-{
- double newval;
- unsigned int success = sp_svg_number_read_d(strvalue, &newval);
- if (success == 1) {
- param_set_value(newval);
- return true;
- }
- return false;
-}
-
-gchar *
-ScalarParam::param_writeSVGValue() const
-{
- Inkscape::SVGOStringStream os;
- os << value;
- gchar * str = g_strdup(os.str().c_str());
- return str;
-}
-
-void
-ScalarParam::param_set_default()
-{
- param_set_value(defvalue);
-}
-
-void
-ScalarParam::param_set_value(gdouble val)
-{
- value = val;
- if (integer)
- value = round(value);
- if (value > max)
- value = max;
- if (value < min)
- value = min;
-
- if (rsu && !rsu->is_updating())
- rsu->setValue(value);
-}
-
-void
-ScalarParam::param_set_range(gdouble min, gdouble max)
-{
- this->min = min;
- this->max = max;
- if (rsu)
- rsu->getS()->setRange(min, max);
-
- param_set_value(value); // reset value to see whether it is in ranges
-}
-
-void
-ScalarParam::param_make_integer(bool yes)
-{
- integer = yes;
- digits = 0;
- inc_step = 1;
- inc_page = 10;
- if (rsu) {
- rsu->getS()->setDigits(digits);
- rsu->getS()->setIncrements(inc_step, inc_page);
- }
-}
-
-Gtk::Widget *
-ScalarParam::param_getWidget()
-{
- if (!rsu) {
- rsu = new Inkscape::UI::Widget::RegisteredScalar();
- rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
- rsu->setValue(value);
- rsu->getS()->setDigits(digits);
- rsu->getS()->setIncrements(inc_step, inc_page);
-
- rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
- }
- return dynamic_cast<Gtk::Widget *> (rsu->getS());
-}
-
-void
-ScalarParam::param_set_digits(unsigned digits)
-{
- this->digits = digits;
- if (rsu) {
- rsu->getS()->setDigits(digits);
- }
-}
-
-void
-ScalarParam::param_set_increments(double step, double page)
-{
- inc_step = step;
- inc_page = page;
- if (rsu) {
- rsu->getS()->setIncrements(inc_step, inc_page);
- }
-}
-
-
-
-
-} /* namespace LivePathEffect */
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "libnr/nr-values.h"
+
+#include <gtkmm.h>
+#include "ui/widget/scalar.h"
+
+#include "svg/stringstream.h"
+
+#include "verbs.h"
+
+#define noLPEREALPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+
+Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect )
+{
+ param_label = label;
+ param_tooltip = tip;
+ param_key = key;
+ param_wr = wr;
+ param_effect = effect;
+}
+
+
+
+/*###########################################
+ * REAL PARAM
+ */
+ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, gdouble default_value)
+ : Parameter(label, tip, key, wr, effect)
+{
+ defvalue = default_value;
+ value = defvalue;
+ min = -NR_HUGE;
+ max = NR_HUGE;
+ integer = false;
+ rsu = NULL;
+ inc_step = 0.1;
+ inc_page = 1;
+ digits = 2;
+}
+
+ScalarParam::~ScalarParam()
+{
+ if (rsu)
+ delete rsu;
+}
+
+bool
+ScalarParam::param_readSVGValue(const gchar * strvalue)
+{
+ double newval;
+ unsigned int success = sp_svg_number_read_d(strvalue, &newval);
+ if (success == 1) {
+ param_set_value(newval);
+ return true;
+ }
+ return false;
+}
+
+gchar *
+ScalarParam::param_writeSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << value;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+void
+ScalarParam::param_set_default()
+{
+ param_set_value(defvalue);
+}
+
+void
+ScalarParam::param_set_value(gdouble val)
+{
+ value = val;
+ if (integer)
+ value = round(value);
+ if (value > max)
+ value = max;
+ if (value < min)
+ value = min;
+
+ if (rsu && !rsu->is_updating())
+ rsu->setValue(value);
+}
+
+void
+ScalarParam::param_set_range(gdouble min, gdouble max)
+{
+ this->min = min;
+ this->max = max;
+ if (rsu)
+ rsu->getS()->setRange(min, max);
+
+ param_set_value(value); // reset value to see whether it is in ranges
+}
+
+void
+ScalarParam::param_make_integer(bool yes)
+{
+ integer = yes;
+ digits = 0;
+ inc_step = 1;
+ inc_page = 10;
+ if (rsu) {
+ rsu->getS()->setDigits(digits);
+ rsu->getS()->setIncrements(inc_step, inc_page);
+ }
+}
+
+Gtk::Widget *
+ScalarParam::param_getWidget()
+{
+ if (!rsu) {
+ rsu = new Inkscape::UI::Widget::RegisteredScalar();
+ rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ rsu->setValue(value);
+ rsu->getS()->setDigits(digits);
+ rsu->getS()->setIncrements(inc_step, inc_page);
+
+ rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (rsu->getS());
+}
+
+void
+ScalarParam::param_set_digits(unsigned digits)
+{
+ this->digits = digits;
+ if (rsu) {
+ rsu->getS()->setDigits(digits);
+ }
+}
+
+void
+ScalarParam::param_set_increments(double step, double page)
+{
+ inc_step = step;
+ inc_page = page;
+ if (rsu) {
+ rsu->getS()->setIncrements(inc_step, inc_page);
+ }
+}
+
+
+
+
+} /* namespace LivePathEffect */
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index fb0bb7103..a6b05bf36 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -1,108 +1,108 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glibmm/ustring.h>
-#include <2geom/point.h>
-#include <2geom/path.h>
-
-#include "ui/widget/registry.h"
-#include "ui/widget/registered-widget.h"
-
-namespace Gtk {
- class Widget;
-}
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-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);
- virtual ~Parameter() {};
-
- virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
- virtual gchar * param_writeSVGValue() const = 0;
-
- virtual void param_set_default() = 0;
-
- // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
- // necessary widget if it does not exist yet.
- virtual Gtk::Widget * param_getWidget() = 0;
- virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
-
- Glib::ustring param_key;
- Inkscape::UI::Widget::Registry * param_wr;
- Glib::ustring param_label;
-
-protected:
- Glib::ustring param_tooltip;
-
- Effect* param_effect;
-
-private:
- Parameter(const Parameter&);
- Parameter& operator=(const Parameter&);
-};
-
-
-class ScalarParam : public Parameter {
-public:
- ScalarParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- gdouble default_value = 1.0);
- virtual ~ScalarParam();
-
- virtual bool param_readSVGValue(const gchar * strvalue);
- virtual gchar * param_writeSVGValue() const;
-
- virtual void param_set_default();
- void param_set_value(gdouble val);
- void param_make_integer(bool yes = true);
- void param_set_range(gdouble min, gdouble max);
- void param_set_digits(unsigned digits);
- void param_set_increments(double step, double page);
-
- virtual Gtk::Widget * param_getWidget();
-
- inline operator gdouble()
- { return value; };
-
-protected:
- gdouble value;
- gdouble min;
- gdouble max;
- bool integer;
- gdouble defvalue;
- Inkscape::UI::Widget::RegisteredScalar * rsu;
- unsigned digits;
- double inc_step;
- double inc_page;
-
-private:
- ScalarParam(const ScalarParam&);
- ScalarParam& operator=(const ScalarParam&);
-};
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glibmm/ustring.h>
+#include <2geom/point.h>
+#include <2geom/path.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+
+namespace Gtk {
+ class Widget;
+}
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+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);
+ virtual ~Parameter() {};
+
+ virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
+ virtual gchar * param_writeSVGValue() const = 0;
+
+ virtual void param_set_default() = 0;
+
+ // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
+ // necessary widget if it does not exist yet.
+ virtual Gtk::Widget * param_getWidget() = 0;
+ virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
+
+ Glib::ustring param_key;
+ Inkscape::UI::Widget::Registry * param_wr;
+ Glib::ustring param_label;
+
+protected:
+ Glib::ustring param_tooltip;
+
+ Effect* param_effect;
+
+private:
+ Parameter(const Parameter&);
+ Parameter& operator=(const Parameter&);
+};
+
+
+class ScalarParam : public Parameter {
+public:
+ ScalarParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ gdouble default_value = 1.0);
+ virtual ~ScalarParam();
+
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_writeSVGValue() const;
+
+ virtual void param_set_default();
+ void param_set_value(gdouble val);
+ void param_make_integer(bool yes = true);
+ void param_set_range(gdouble min, gdouble max);
+ void param_set_digits(unsigned digits);
+ void param_set_increments(double step, double page);
+
+ virtual Gtk::Widget * param_getWidget();
+
+ inline operator gdouble()
+ { return value; };
+
+protected:
+ gdouble value;
+ gdouble min;
+ gdouble max;
+ bool integer;
+ gdouble defvalue;
+ Inkscape::UI::Widget::RegisteredScalar * rsu;
+ unsigned digits;
+ double inc_step;
+ double inc_page;
+
+private:
+ ScalarParam(const ScalarParam&);
+ ScalarParam& operator=(const ScalarParam&);
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 4c73f0aee..ff596bfc6 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -1,182 +1,182 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP
-
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/path.h"
-#include "live_effects/effect.h"
-#include "live_effects/n-art-bpath-2geom.h"
-#include "svg/svg.h"
-#include <2geom/svg-path-parser.h>
-#include <2geom/sbasis-to-bezier.h>
-#include <2geom/d2.h>
-
-#include "ui/widget/point.h"
-#include "widgets/icon.h"
-#include <gtk/gtkstock.h>
-#include "selection-chemistry.h"
-
-#include "desktop.h"
-#include "inkscape.h"
-#include "message-stack.h"
-#include "verbs.h"
-#include "document.h"
-
-#define noLPEPATHPARAM_DEBUG
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, const gchar * default_value)
- : Parameter(label, tip, key, wr, effect)
-{
- _widget = NULL;
- _tooltips = NULL;
- defvalue = g_strdup(default_value);
- param_readSVGValue(defvalue);
-}
-
-PathParam::~PathParam()
-{
- if (_tooltips)
- delete _tooltips;
- // _widget is managed by GTK so do not delete!
-
- g_free(defvalue);
-}
-
-void
-PathParam::param_set_default()
-{
- param_readSVGValue(defvalue);
-}
-
-bool
-PathParam::param_readSVGValue(const gchar * strvalue)
-{
- if (strvalue) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath;
- std::vector<Geom::Path> temppath = SVGD_to_2GeomPath(strvalue);
- for (unsigned int i=0; i < temppath.size(); i++) {
- newpath.concat( temppath[i].toPwSb() );
- }
- *( dynamic_cast<Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this) ) = newpath;
- signal_path_changed.emit();
- return true;
- }
-
- return false;
-}
-
-gchar *
-PathParam::param_writeSVGValue() const
-{
- const std::vector<Geom::Path> temppath =
- Geom::path_from_piecewise(* dynamic_cast<const Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this), LPE_CONVERSION_TOLERANCE);
- gchar * svgd = SVGD_from_2GeomPath( temppath );
- return svgd;
-}
-
-Gtk::Widget *
-PathParam::param_getWidget()
-{
- if (!_widget) {
- _widget = Gtk::manage(new Gtk::HBox());
- _tooltips = new Gtk::Tooltips();
-
- Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
- _tooltips->set_tip(*pLabel, param_tooltip);
-
- Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
- Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- _tooltips->set_tip(*pButton, _("Edit on-canvas"));
-#ifndef LPEPATHPARAM_DEBUG
- pButton->set_sensitive(false);
-#endif
-
- pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) );
- pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- _tooltips->set_tip(*pButton, _("Paste path"));
-
- static_cast<Gtk::HBox*>(_widget)->show_all_children();
-
- }
- return dynamic_cast<Gtk::Widget *> (_widget);
-}
-
-void
-PathParam::on_edit_button_click()
-{
- g_message("give this path to edit on canvas!");
-}
-
-void
-PathParam::on_paste_button_click()
-{
- // check if something is in the clipboard
- GSList * clipboard = sp_selection_get_clipboard();
- if (clipboard == NULL || clipboard->data == NULL) {
- SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
- return;
- }
-
- Inkscape::XML::Node *repr = (Inkscape::XML::Node *) clipboard->data;
- if (!strcmp (repr->name(), "svg:path")) {
- const char * svgd = repr->attribute("d");
- if (svgd) {
- if (strchr(svgd,'A')) { // FIXME: temporary hack until 2Geom supports arcs in SVGD
- SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
- _("This effect does not support arcs yet, try to convert to path.") );
- } else {
- param_write_to_repr(svgd);
- signal_path_pasted.emit();
- sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
- _("Paste path parameter"));
- }
- }
- } else {
- SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Clipboard does not contain a path."));
- }
-
-}
-
-void
-PathParam::param_write_to_repr(const char * svgd)
-{
- param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
-}
-
-
-} /* namespace LivePathEffect */
-
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/path.h"
+#include "live_effects/effect.h"
+#include "live_effects/n-art-bpath-2geom.h"
+#include "svg/svg.h"
+#include <2geom/svg-path-parser.h>
+#include <2geom/sbasis-to-bezier.h>
+#include <2geom/d2.h>
+
+#include "ui/widget/point.h"
+#include "widgets/icon.h"
+#include <gtk/gtkstock.h>
+#include "selection-chemistry.h"
+
+#include "desktop.h"
+#include "inkscape.h"
+#include "message-stack.h"
+#include "verbs.h"
+#include "document.h"
+
+#define noLPEPATHPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const gchar * default_value)
+ : Parameter(label, tip, key, wr, effect)
+{
+ _widget = NULL;
+ _tooltips = NULL;
+ defvalue = g_strdup(default_value);
+ param_readSVGValue(defvalue);
+}
+
+PathParam::~PathParam()
+{
+ if (_tooltips)
+ delete _tooltips;
+ // _widget is managed by GTK so do not delete!
+
+ g_free(defvalue);
+}
+
+void
+PathParam::param_set_default()
+{
+ param_readSVGValue(defvalue);
+}
+
+bool
+PathParam::param_readSVGValue(const gchar * strvalue)
+{
+ if (strvalue) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath;
+ std::vector<Geom::Path> temppath = SVGD_to_2GeomPath(strvalue);
+ for (unsigned int i=0; i < temppath.size(); i++) {
+ newpath.concat( temppath[i].toPwSb() );
+ }
+ *( dynamic_cast<Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this) ) = newpath;
+ signal_path_changed.emit();
+ return true;
+ }
+
+ return false;
+}
+
+gchar *
+PathParam::param_writeSVGValue() const
+{
+ const std::vector<Geom::Path> temppath =
+ Geom::path_from_piecewise(* dynamic_cast<const Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this), LPE_CONVERSION_TOLERANCE);
+ gchar * svgd = SVGD_from_2GeomPath( temppath );
+ return svgd;
+}
+
+Gtk::Widget *
+PathParam::param_getWidget()
+{
+ if (!_widget) {
+ _widget = Gtk::manage(new Gtk::HBox());
+ _tooltips = new Gtk::Tooltips();
+
+ Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
+ _tooltips->set_tip(*pLabel, param_tooltip);
+
+ Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ _tooltips->set_tip(*pButton, _("Edit on-canvas"));
+#ifndef LPEPATHPARAM_DEBUG
+ pButton->set_sensitive(false);
+#endif
+
+ pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ _tooltips->set_tip(*pButton, _("Paste path"));
+
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ }
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+PathParam::on_edit_button_click()
+{
+ g_message("give this path to edit on canvas!");
+}
+
+void
+PathParam::on_paste_button_click()
+{
+ // check if something is in the clipboard
+ GSList * clipboard = sp_selection_get_clipboard();
+ if (clipboard == NULL || clipboard->data == NULL) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ Inkscape::XML::Node *repr = (Inkscape::XML::Node *) clipboard->data;
+ if (!strcmp (repr->name(), "svg:path")) {
+ const char * svgd = repr->attribute("d");
+ if (svgd) {
+ if (strchr(svgd,'A')) { // FIXME: temporary hack until 2Geom supports arcs in SVGD
+ SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE,
+ _("This effect does not support arcs yet, try to convert to path.") );
+ } else {
+ param_write_to_repr(svgd);
+ signal_path_pasted.emit();
+ sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Paste path parameter"));
+ }
+ }
+ } else {
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Clipboard does not contain a path."));
+ }
+
+}
+
+void
+PathParam::param_write_to_repr(const char * svgd)
+{
+ param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
+}
+
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index e26611b85..e966b7ebd 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -1,66 +1,66 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib/gtypes.h>
-#include <2geom/path.h>
-
-#include "ui/widget/registry.h"
-#include <gtkmm/tooltips.h>
-
-#include "live_effects/parameter/parameter.h"
-
-#include <sigc++/sigc++.h>
-
-namespace Inkscape {
-
-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,
- const gchar * default_value = "M0,0 L1,1");
- ~PathParam();
-
- Gtk::Widget * param_getWidget();
-
- bool param_readSVGValue(const gchar * strvalue);
- gchar * param_writeSVGValue() const;
-
- void param_set_default();
-
- sigc::signal <void> signal_path_pasted;
- sigc::signal <void> signal_path_changed;
-
-private:
- PathParam(const PathParam&);
- PathParam& operator=(const PathParam&);
-
- Gtk::Widget * _widget;
- Gtk::Tooltips * _tooltips;
-
- void param_write_to_repr(const char * svgd);
-
- void on_edit_button_click();
- void on_paste_button_click();
-
- gchar * defvalue;
-};
-
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+#include <2geom/path.h>
+
+#include "ui/widget/registry.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+
+#include <sigc++/sigc++.h>
+
+namespace Inkscape {
+
+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,
+ const gchar * default_value = "M0,0 L1,1");
+ ~PathParam();
+
+ Gtk::Widget * param_getWidget();
+
+ bool param_readSVGValue(const gchar * strvalue);
+ gchar * param_writeSVGValue() const;
+
+ void param_set_default();
+
+ sigc::signal <void> signal_path_pasted;
+ sigc::signal <void> signal_path_changed;
+
+private:
+ PathParam(const PathParam&);
+ PathParam& operator=(const PathParam&);
+
+ Gtk::Widget * _widget;
+ Gtk::Tooltips * _tooltips;
+
+ void param_write_to_repr(const char * svgd);
+
+ void on_edit_button_click();
+ void on_paste_button_click();
+
+ gchar * defvalue;
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 3c42dcbfe..caa81692f 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -1,173 +1,173 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_CPP
-
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/point.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "svg/stringstream.h"
-#include <gtkmm.h>
-#include "ui/widget/point.h"
-#include "widgets/icon.h"
-
-#include "knot.h"
-#include "inkscape.h"
-#include "verbs.h"
-
-#define noLPEPOINTPARAM_DEBUG
-
-#define PRM_KNOT_COLOR_NORMAL 0xffffff00
-#define PRM_KNOT_COLOR_SELECTED 0x0000ff00
-
-namespace Inkscape {
-
-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 default_value )
- : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
-{
- _widget = NULL;
- pointwdg = NULL;
- knot = NULL;
- _tooltips = NULL;
-}
-
-PointParam::~PointParam()
-{
- if (pointwdg)
- delete pointwdg;
- if (_tooltips)
- delete _tooltips;
-
- if (knot)
- g_object_unref (G_OBJECT (knot));
-}
-
-void
-PointParam::param_set_default()
-{
- param_setValue(defvalue);
-}
-
-bool
-PointParam::param_readSVGValue(const gchar * strvalue)
-{
- gchar ** strarray = g_strsplit(strvalue, ",", 2);
- double newx, newy;
- unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
- success += sp_svg_number_read_d(strarray[1], &newy);
- g_strfreev (strarray);
- if (success == 2) {
- param_setValue( Geom::Point(newx, newy) );
- return true;
- }
- return false;
-}
-
-gchar *
-PointParam::param_writeSVGValue() const
-{
- Inkscape::SVGOStringStream os;
- os << (*this)[0] << "," << (*this)[1];
- gchar * str = g_strdup(os.str().c_str());
- return str;
-}
-
-Gtk::Widget *
-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( (*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) );
- Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
-#ifndef LPEPOINTPARAM_DEBUG
- pButton->set_sensitive(false);
-#endif
-
- _widget = Gtk::manage( new Gtk::HBox() );
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- static_cast<Gtk::HBox*>(_widget)->pack_start(*(pointwdg->getPoint()), true, true);
- static_cast<Gtk::HBox*>(_widget)->show_all_children();
-
- _tooltips = new Gtk::Tooltips();
- _tooltips->set_tip(*pButton, _("Edit on-canvas"));
- }
- return dynamic_cast<Gtk::Widget *> (_widget);
-}
-
-void
-PointParam::param_setValue(Geom::Point newpoint)
-{
- *dynamic_cast<Geom::Point *>( this ) = newpoint;
- if (pointwdg)
- pointwdg->setValue(newpoint[0], newpoint[1]);
-}
-
-
-// CALLBACKS:
-
-void
-PointParam::on_button_click()
-{
- g_message("add knot to canvas on correct location :S");
-
- if (!knot) {
- // create the knot
- knot = sp_knot_new (SP_ACTIVE_DESKTOP, NULL);
- knot->setMode(SP_KNOT_MODE_XOR);
- knot->setFill(PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL);
- knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
- sp_knot_update_ctrl(knot);
-
- // move knot to the given point
- sp_knot_set_position (knot, &NR::Point((*this)[0], (*this)[1]), SP_KNOT_STATE_NORMAL);
- sp_knot_show (knot);
-/*
- // connect knot's signals
- if ( (draggable) // it can be NULL if a node in unsnapped (eg. focus point unsnapped from center)
- // luckily, midstops never snap to other nodes so are never unsnapped...
- && ( (draggable->point_type == POINT_LG_MID)
- || (draggable->point_type == POINT_RG_MID1)
- || (draggable->point_type == POINT_RG_MID2) ) )
- {
- this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_midpoint_handler), this);
- } else {
- this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_handler), this);
- }
- g_signal_connect (G_OBJECT (this->knot), "clicked", G_CALLBACK (gr_knot_clicked_handler), this);
- g_signal_connect (G_OBJECT (this->knot), "doubleclicked", G_CALLBACK (gr_knot_doubleclicked_handler), this);
- g_signal_connect (G_OBJECT (this->knot), "grabbed", G_CALLBACK (gr_knot_grabbed_handler), this);
- g_signal_connect (G_OBJECT (this->knot), "ungrabbed", G_CALLBACK (gr_knot_ungrabbed_handler), this);
-*/
- }
-}
-
-} /* namespace LivePathEffect */
-
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/point.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include <gtkmm.h>
+#include "ui/widget/point.h"
+#include "widgets/icon.h"
+
+#include "knot.h"
+#include "inkscape.h"
+#include "verbs.h"
+
+#define noLPEPOINTPARAM_DEBUG
+
+#define PRM_KNOT_COLOR_NORMAL 0xffffff00
+#define PRM_KNOT_COLOR_SELECTED 0x0000ff00
+
+namespace Inkscape {
+
+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 default_value )
+ : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
+{
+ _widget = NULL;
+ pointwdg = NULL;
+ knot = NULL;
+ _tooltips = NULL;
+}
+
+PointParam::~PointParam()
+{
+ if (pointwdg)
+ delete pointwdg;
+ if (_tooltips)
+ delete _tooltips;
+
+ if (knot)
+ g_object_unref (G_OBJECT (knot));
+}
+
+void
+PointParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+
+bool
+PointParam::param_readSVGValue(const gchar * strvalue)
+{
+ gchar ** strarray = g_strsplit(strvalue, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ param_setValue( Geom::Point(newx, newy) );
+ return true;
+ }
+ return false;
+}
+
+gchar *
+PointParam::param_writeSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << (*this)[0] << "," << (*this)[1];
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+Gtk::Widget *
+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( (*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) );
+ Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
+#ifndef LPEPOINTPARAM_DEBUG
+ pButton->set_sensitive(false);
+#endif
+
+ _widget = Gtk::manage( new Gtk::HBox() );
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*(pointwdg->getPoint()), true, true);
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ _tooltips = new Gtk::Tooltips();
+ _tooltips->set_tip(*pButton, _("Edit on-canvas"));
+ }
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+PointParam::param_setValue(Geom::Point newpoint)
+{
+ *dynamic_cast<Geom::Point *>( this ) = newpoint;
+ if (pointwdg)
+ pointwdg->setValue(newpoint[0], newpoint[1]);
+}
+
+
+// CALLBACKS:
+
+void
+PointParam::on_button_click()
+{
+ g_message("add knot to canvas on correct location :S");
+
+ if (!knot) {
+ // create the knot
+ knot = sp_knot_new (SP_ACTIVE_DESKTOP, NULL);
+ knot->setMode(SP_KNOT_MODE_XOR);
+ knot->setFill(PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL);
+ knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
+ sp_knot_update_ctrl(knot);
+
+ // move knot to the given point
+ sp_knot_set_position (knot, &NR::Point((*this)[0], (*this)[1]), SP_KNOT_STATE_NORMAL);
+ sp_knot_show (knot);
+/*
+ // connect knot's signals
+ if ( (draggable) // it can be NULL if a node in unsnapped (eg. focus point unsnapped from center)
+ // luckily, midstops never snap to other nodes so are never unsnapped...
+ && ( (draggable->point_type == POINT_LG_MID)
+ || (draggable->point_type == POINT_RG_MID1)
+ || (draggable->point_type == POINT_RG_MID2) ) )
+ {
+ this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_midpoint_handler), this);
+ } else {
+ this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_handler), this);
+ }
+ g_signal_connect (G_OBJECT (this->knot), "clicked", G_CALLBACK (gr_knot_clicked_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "doubleclicked", G_CALLBACK (gr_knot_doubleclicked_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "grabbed", G_CALLBACK (gr_knot_grabbed_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "ungrabbed", G_CALLBACK (gr_knot_ungrabbed_handler), this);
+*/
+ }
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index c1d6681a2..c3ed876f7 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -1,65 +1,65 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib/gtypes.h>
-#include <2geom/point.h>
-
-#include "ui/widget/registry.h"
-#include "ui/widget/registered-widget.h"
-#include <gtkmm/tooltips.h>
-
-#include "live_effects/parameter/parameter.h"
-
-struct SPKnot;
-
-namespace Inkscape {
-
-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,
- Geom::Point default_value = Geom::Point(0,0));
- ~PointParam();
-
- Gtk::Widget * param_getWidget();
-
- bool param_readSVGValue(const gchar * strvalue);
- gchar * param_writeSVGValue() const;
-
- void param_setValue(Geom::Point newpoint);
- void param_set_default();
-
-private:
- PointParam(const PointParam&);
- PointParam& operator=(const PointParam&);
-
- Gtk::Widget * _widget;
- Gtk::Tooltips * _tooltips;
- Inkscape::UI::Widget::RegisteredPoint * pointwdg;
- void on_button_click();
-
- SPKnot *knot;
-
- Geom::Point defvalue;
-};
-
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+#include <2geom/point.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+
+struct SPKnot;
+
+namespace Inkscape {
+
+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,
+ Geom::Point default_value = Geom::Point(0,0));
+ ~PointParam();
+
+ Gtk::Widget * param_getWidget();
+
+ bool param_readSVGValue(const gchar * strvalue);
+ gchar * param_writeSVGValue() const;
+
+ void param_setValue(Geom::Point newpoint);
+ void param_set_default();
+
+private:
+ PointParam(const PointParam&);
+ PointParam& operator=(const PointParam&);
+
+ Gtk::Widget * _widget;
+ Gtk::Tooltips * _tooltips;
+ Inkscape::UI::Widget::RegisteredPoint * pointwdg;
+ void on_button_click();
+
+ SPKnot *knot;
+
+ Geom::Point defvalue;
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp
index 846c2f9e8..959b21114 100644
--- a/src/live_effects/parameter/random.cpp
+++ b/src/live_effects/parameter/random.cpp
@@ -1,194 +1,194 @@
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_CPP
-
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/random.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "libnr/nr-values.h"
-
-#include <gtkmm.h>
-#include "ui/widget/random.h"
-
-#include "svg/stringstream.h"
-
-#include "verbs.h"
-
-#define noLPERANDOMPARAM_DEBUG
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-
-RandomParam::RandomParam( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, gdouble default_value, long default_seed)
- : Parameter(label, tip, key, wr, effect)
-{
- defvalue = default_value;
- value = defvalue;
- min = -NR_HUGE;
- max = NR_HUGE;
- integer = false;
- regrandom = NULL;
-
- defseed = default_seed;
- startseed = defseed;
- seed = startseed;
-}
-
-RandomParam::~RandomParam()
-{
- if (regrandom)
- delete regrandom;
-}
-
-bool
-RandomParam::param_readSVGValue(const gchar * strvalue)
-{
- double newval, newstartseed;
- gchar** stringarray = g_strsplit (strvalue, ";", 2);
- unsigned int success = sp_svg_number_read_d(stringarray[0], &newval);
- if (success == 1) {
- success += sp_svg_number_read_d(stringarray[1], &newstartseed);
- if (success == 2) {
- param_set_value(newval, newstartseed);
- } else {
- param_set_value(newval, defseed);
- }
- g_strfreev(stringarray);
- return true;
- }
- g_strfreev(stringarray);
- return false;
-}
-
-gchar *
-RandomParam::param_writeSVGValue() const
-{
- Inkscape::SVGOStringStream os;
- os << value << ';' << startseed;
- gchar * str = g_strdup(os.str().c_str());
- return str;
-}
-
-void
-RandomParam::param_set_default()
-{
- param_set_value(defvalue, defseed);
-}
-
-void
-RandomParam::param_set_value(gdouble val, long newseed)
-{
- value = val;
- if (integer)
- value = round(value);
- if (value > max)
- value = max;
- if (value < min)
- value = min;
-
- startseed = setup_seed(newseed);
- seed = startseed;
-
- if (regrandom)
- regrandom->setValue(value, startseed);
-}
-
-void
-RandomParam::param_set_range(gdouble min, gdouble max)
-{
- this->min = min;
- this->max = max;
- if (regrandom)
- regrandom->getR()->setRange(min, max);
-
- param_set_value(value, startseed); // reset value, to check whether it is in range
-}
-
-void
-RandomParam::param_make_integer(bool yes)
-{
- integer = yes;
- if (regrandom) {
- regrandom->getR()->setDigits(0);
- regrandom->getR()->setIncrements(1, 10);
- }
-}
-
-void
-RandomParam::resetRandomizer()
-{
- seed = startseed;
-}
-
-
-Gtk::Widget *
-RandomParam::param_getWidget()
-{
- // TODO: add a button to set a different startseed
- if (!regrandom) {
- regrandom = new Inkscape::UI::Widget::RegisteredRandom();
- regrandom->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
- regrandom->setValue(value, startseed);
- if (integer)
- param_make_integer();
-
- regrandom->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change random parameter"));
- }
- return dynamic_cast<Gtk::Widget *> (regrandom->getR());
-}
-
-RandomParam::operator gdouble()
-{
- return rand() * value;
-};
-
-/* RNG stolen from /display/nr-filter-turbulence.cpp */
-#define RAND_m 2147483647 /* 2**31 - 1 */
-#define RAND_a 16807 /* 7**5; primitive root of m */
-#define RAND_q 127773 /* m / a */
-#define RAND_r 2836 /* m % a */
-#define BSize 0x100
-
-long
-RandomParam::setup_seed(long lSeed)
-{
- if (lSeed <= 0) lSeed = -(lSeed % (RAND_m - 1)) + 1;
- if (lSeed > RAND_m - 1) lSeed = RAND_m - 1;
- return lSeed;
-}
-
-// generates random number between 0 and 1
-gdouble
-RandomParam::rand()
-{
- long result;
- result = RAND_a * (seed % RAND_q) - RAND_r * (seed / RAND_q);
- if (result <= 0) result += RAND_m;
- seed = result;
-
- gdouble dresult = (gdouble)(result % BSize) / BSize;
- return dresult;
-}
-
-
-} /* namespace LivePathEffect */
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/random.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "libnr/nr-values.h"
+
+#include <gtkmm.h>
+#include "ui/widget/random.h"
+
+#include "svg/stringstream.h"
+
+#include "verbs.h"
+
+#define noLPERANDOMPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+
+RandomParam::RandomParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, gdouble default_value, long default_seed)
+ : Parameter(label, tip, key, wr, effect)
+{
+ defvalue = default_value;
+ value = defvalue;
+ min = -NR_HUGE;
+ max = NR_HUGE;
+ integer = false;
+ regrandom = NULL;
+
+ defseed = default_seed;
+ startseed = defseed;
+ seed = startseed;
+}
+
+RandomParam::~RandomParam()
+{
+ if (regrandom)
+ delete regrandom;
+}
+
+bool
+RandomParam::param_readSVGValue(const gchar * strvalue)
+{
+ double newval, newstartseed;
+ gchar** stringarray = g_strsplit (strvalue, ";", 2);
+ unsigned int success = sp_svg_number_read_d(stringarray[0], &newval);
+ if (success == 1) {
+ success += sp_svg_number_read_d(stringarray[1], &newstartseed);
+ if (success == 2) {
+ param_set_value(newval, newstartseed);
+ } else {
+ param_set_value(newval, defseed);
+ }
+ g_strfreev(stringarray);
+ return true;
+ }
+ g_strfreev(stringarray);
+ return false;
+}
+
+gchar *
+RandomParam::param_writeSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << value << ';' << startseed;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+void
+RandomParam::param_set_default()
+{
+ param_set_value(defvalue, defseed);
+}
+
+void
+RandomParam::param_set_value(gdouble val, long newseed)
+{
+ value = val;
+ if (integer)
+ value = round(value);
+ if (value > max)
+ value = max;
+ if (value < min)
+ value = min;
+
+ startseed = setup_seed(newseed);
+ seed = startseed;
+
+ if (regrandom)
+ regrandom->setValue(value, startseed);
+}
+
+void
+RandomParam::param_set_range(gdouble min, gdouble max)
+{
+ this->min = min;
+ this->max = max;
+ if (regrandom)
+ regrandom->getR()->setRange(min, max);
+
+ param_set_value(value, startseed); // reset value, to check whether it is in range
+}
+
+void
+RandomParam::param_make_integer(bool yes)
+{
+ integer = yes;
+ if (regrandom) {
+ regrandom->getR()->setDigits(0);
+ regrandom->getR()->setIncrements(1, 10);
+ }
+}
+
+void
+RandomParam::resetRandomizer()
+{
+ seed = startseed;
+}
+
+
+Gtk::Widget *
+RandomParam::param_getWidget()
+{
+ // TODO: add a button to set a different startseed
+ if (!regrandom) {
+ regrandom = new Inkscape::UI::Widget::RegisteredRandom();
+ regrandom->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ regrandom->setValue(value, startseed);
+ if (integer)
+ param_make_integer();
+
+ regrandom->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change random parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (regrandom->getR());
+}
+
+RandomParam::operator gdouble()
+{
+ return rand() * value;
+};
+
+/* RNG stolen from /display/nr-filter-turbulence.cpp */
+#define RAND_m 2147483647 /* 2**31 - 1 */
+#define RAND_a 16807 /* 7**5; primitive root of m */
+#define RAND_q 127773 /* m / a */
+#define RAND_r 2836 /* m % a */
+#define BSize 0x100
+
+long
+RandomParam::setup_seed(long lSeed)
+{
+ if (lSeed <= 0) lSeed = -(lSeed % (RAND_m - 1)) + 1;
+ if (lSeed > RAND_m - 1) lSeed = RAND_m - 1;
+ return lSeed;
+}
+
+// generates random number between 0 and 1
+gdouble
+RandomParam::rand()
+{
+ long result;
+ result = RAND_a * (seed % RAND_q) - RAND_r * (seed / RAND_q);
+ if (result <= 0) result += RAND_m;
+ seed = result;
+
+ gdouble dresult = (gdouble)(result % BSize) / BSize;
+ return dresult;
+}
+
+
+} /* namespace LivePathEffect */
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h
index 772f46ac6..55171c973 100644
--- a/src/live_effects/parameter/random.h
+++ b/src/live_effects/parameter/random.h
@@ -1,76 +1,76 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/parameter/parameter.h"
-#include <glibmm/ustring.h>
-#include <2geom/point.h>
-#include <2geom/path.h>
-
-#include "ui/widget/registry.h"
-#include "ui/widget/registered-widget.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-class RandomParam : public Parameter {
-public:
- RandomParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- gdouble default_value = 1.0,
- long default_seed = 0);
- virtual ~RandomParam();
-
- virtual bool param_readSVGValue(const gchar * strvalue);
- virtual gchar * param_writeSVGValue() const;
- virtual void param_set_default();
-
- virtual Gtk::Widget * param_getWidget();
-
- void param_set_value(gdouble val, long newseed);
- void param_make_integer(bool yes = true);
- void param_set_range(gdouble min, gdouble max);
-
- void resetRandomizer();
-
- operator gdouble();
- inline gdouble get_value()
- { return value; } ;
-
-protected:
- long startseed;
- long seed;
- long defseed;
-
- gdouble value;
- gdouble min;
- gdouble max;
- bool integer;
- gdouble defvalue;
-
- Inkscape::UI::Widget::RegisteredRandom * regrandom;
-
-private:
- long setup_seed(long);
- gdouble rand();
-
- RandomParam(const RandomParam&);
- RandomParam& operator=(const RandomParam&);
-};
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_RANDOM_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/parameter.h"
+#include <glibmm/ustring.h>
+#include <2geom/point.h>
+#include <2geom/path.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class RandomParam : public Parameter {
+public:
+ RandomParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ gdouble default_value = 1.0,
+ long default_seed = 0);
+ virtual ~RandomParam();
+
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_writeSVGValue() const;
+ virtual void param_set_default();
+
+ virtual Gtk::Widget * param_getWidget();
+
+ void param_set_value(gdouble val, long newseed);
+ void param_make_integer(bool yes = true);
+ void param_set_range(gdouble min, gdouble max);
+
+ void resetRandomizer();
+
+ operator gdouble();
+ inline gdouble get_value()
+ { return value; } ;
+
+protected:
+ long startseed;
+ long seed;
+ long defseed;
+
+ gdouble value;
+ gdouble min;
+ gdouble max;
+ bool integer;
+ gdouble defvalue;
+
+ Inkscape::UI::Widget::RegisteredRandom * regrandom;
+
+private:
+ long setup_seed(long);
+ gdouble rand();
+
+ RandomParam(const RandomParam&);
+ RandomParam& operator=(const RandomParam&);
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif