summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-02-08 15:40:25 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-02-08 15:40:25 +0000
commit86891a9e442c81435c6d197cb09b3dc210643bc0 (patch)
tree4952411fd6e526907d4241e8965e93c4f185500a /src/live_effects/parameter
parentrefactor of pointwise base (diff)
downloadinkscape-86891a9e442c81435c6d197cb09b3dc210643bc0.tar.gz
inkscape-86891a9e442c81435c6d197cb09b3dc210643bc0.zip
starting whith pointwise
(bzr r13645.1.7)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/Makefile_insert2
-rw-r--r--src/live_effects/parameter/array.cpp32
-rw-r--r--src/live_effects/parameter/array.h9
-rw-r--r--src/live_effects/parameter/pointwise.cpp104
-rw-r--r--src/live_effects/parameter/pointwise.h88
5 files changed, 234 insertions, 1 deletions
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert
index f990f41c7..d78b1e22f 100644
--- a/src/live_effects/parameter/Makefile_insert
+++ b/src/live_effects/parameter/Makefile_insert
@@ -26,6 +26,8 @@ ink_common_sources += \
live_effects/parameter/powerstrokepointarray.h \
live_effects/parameter/filletchamferpointarray.cpp \
live_effects/parameter/filletchamferpointarray.h \
+ live_effects/parameter/pointwise.cpp \
+ live_effects/parameter/pointwise.h \
live_effects/parameter/text.cpp \
live_effects/parameter/text.h \
live_effects/parameter/transformedpoint.cpp \
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index 1b8f742da..bd2bf1870 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -48,6 +48,38 @@ ArrayParam<Geom::Point>::readsvg(const gchar * str)
}
return Geom::Point(Geom::infinity(),Geom::infinity());
}
+void
+sp_svg_satellite_read_d(gchar const *str, satellite *sat){
+ gchar ** strarray = g_strsplit(str, "*", 0);
+ if(strarray.size() != 6){
+ g_strfreev (strarray);
+ return NULL;
+ }
+ sat->setSatelliteType(SatelliteTypeMap[strarray[0]]);
+ sat->setActive(helperfns_read_bool(strarray[1], true));
+ sat->sethasMirror(helperfns_read_bool(strarray[2], false));
+ sat->setHidden(helperfns_read_bool(strarray[3], false));
+ sat->setHidden(helperfns_read_bool(strarray[3], false));
+ sat->setTime(sp_svg_number_read_d(strarray[4], 0.0));
+ sat->setSize(sp_svg_number_read_d(strarray[5], 0.0));
+ g_strfreev (strarray);
+}
+
+template <>
+std::pair<int, satellite>
+ArrayParam<Geom::Point>::readsvg(const gchar * str)
+{
+ gchar ** strarray = g_strsplit(str, ",", 2);
+ int index;
+ Geom::satellite sat = NULL;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &index);
+ success += sp_svg_satellite_read_d(strarray[1], &sat);
+ g_strfreev (strarray);
+ if (success == 2) {
+ return std::pair<index, sat>;
+ }
+ return std::pair<Geom::infinity(),NULL>;
+}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index a600f0257..b93c7a617 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -93,7 +93,14 @@ protected:
// separate items with pipe symbol
str << " | ";
}
- str << vector[i];
+ std::pair<int,Geom::satellite> pointwiseElement = dynamic_cast<std::pair<int,Geom::satellite> ><(_vector[i]);
+ if(pointwiseElement){
+ str << vector[i].first;
+ str << " , ";
+ str << vector[i].second;
+ } else {
+ str << vector[i];
+ }
}
}
diff --git a/src/live_effects/parameter/pointwise.cpp b/src/live_effects/parameter/pointwise.cpp
new file mode 100644
index 000000000..ec83eb6c7
--- /dev/null
+++ b/src/live_effects/parameter/pointwise.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ * Special thanks to Johan Engelen for the base of the effect -powerstroke-
+ * Also to ScislaC for point me to the idea
+ * Also su_v for his construvtive feedback and time
+ * and finaly to Liam P. White for his big help on coding, that save me a lot of
+ * hours
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "knotholder.h"
+
+// TODO due to internal breakage in glibmm headers,
+// this has to be included last.
+#include <glibmm/i18n.h>
+
+
+using namespace Geom;
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+PointwiseParam::PointwiseParam(
+ const Glib::ustring &label, const Glib::ustring &tip,
+ const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr,
+ Effect *effect)
+ : ArrayParam<Pointwise>(label, tip, key, wr, effect, 0)
+{
+ knot_shape = SP_KNOT_SHAPE_DIAMOND;
+ knot_mode = SP_KNOT_MODE_XOR;
+ knot_color = 0x00ff0000;
+}
+
+PointwiseParam::~PointwiseParam() {}
+
+Gtk::Widget *PointwiseParam::param_newWidget()
+{
+ return NULL;
+}
+
+void PointwiseParam::set_oncanvas_looks(SPKnotShapeType shape,
+ SPKnotModeType mode,
+ guint32 color)
+{
+ knot_shape = shape;
+ knot_mode = mode;
+ knot_color = color;
+}
+
+PointwiseParamKnotHolderEntity::
+PointwiseParamKnotHolderEntity(
+ PointwiseParam *p)
+ : _pparam(p) {}
+
+void PointwiseParamKnotHolderEntity::knot_set(Point const &p,
+ Point const &/*origin*/,
+ guint state)
+{
+ Geom::Point const s = snap_knot_position(p, state);
+ _pparam->_vector.at(_index).second.setPosition(s,_pparam->_pointwise.pwd2[_pparam->_vector.at(_index).first]);
+ sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+}
+
+Point PointwiseParamKnotHolderEntity::knot_get() const
+{
+ Geom::Point const canvas_point = _pparam->_vector.at(_index).second.getPosition(_pparam->_pointwise.pwd2[_pparam->_vector.at(_index).first]);
+ _pparam->updateCanvasIndicators();
+ return canvas_point;
+}
+
+
+void PointwiseParam::addKnotHolderEntities(KnotHolder *knotholder,
+ SPDesktop *desktop,
+ SPItem *item)
+{
+ for (unsigned int i = 0; i < _pointwise.satellites.size(); ++i) {
+ const gchar *tip;
+ tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ PointwiseParamKnotHolderEntity *e =
+ new PointwiseParamKnotHolderEntity(this, i);
+ e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
+ knot_shape, knot_mode, knot_color);
+ knotholder->add(e);
+ }
+ updateCanvasIndicators();
+}
+
+} /* 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/pointwise.h b/src/live_effects/parameter/pointwise.h
new file mode 100644
index 000000000..59f1b4ff4
--- /dev/null
+++ b/src/live_effects/parameter/pointwise.h
@@ -0,0 +1,88 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_POINTWISE_H
+#define INKSCAPE_LIVEPATHEFFECT_POINTWISE_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ * Special thanks to Johan Engelen for the base of the effect -powerstroke-
+ * Also to ScislaC for point me to the idea
+ * Also su_v for his construvtive feedback and time
+ * To Nathan Hurst for his review and help on refactor
+ * and finaly to Liam P. White for his big help on coding, that save me a lot of
+ * hours
+ *
+ *
+ * This parameter act as bridge from pointwise class to serialize it as a LPE
+ * parameter
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib.h>
+#include "knot-holder-entity.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class PointwiseParamKnotHolderEntity;
+
+class PointwiseParam : public ArrayParam<Geom::Pointwise> {
+public:
+ PointwiseParam(const Glib::ustring &label,
+ const Glib::ustring &tip,
+ const Glib::ustring &key,
+ Inkscape::UI::Widget::Registry *wr,
+ Effect *effect);
+ virtual ~PointwiseParam();
+
+ virtual Gtk::Widget * param_newWidget() {
+ return NULL;
+ }
+
+ void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode,
+ guint32 color);
+ virtual bool providesKnotHolderEntities() const {
+ return true;
+ }
+ friend class PointwiseParamKnotHolderEntity;
+
+protected:
+
+ StorageType readsvg(const gchar * str);
+
+private:
+ PointwiseParam(const PointwiseParam &);
+ PointwiseParam &operator=(const PointwiseParam &);
+
+ SPKnotShapeType knot_shape;
+ SPKnotModeType knot_mode;
+ guint32 knot_color;
+};
+
+class PointwiseParamKnotHolderEntity : public KnotHolderEntity {
+public:
+ PointwiseParamKnotHolderEntity(PointwiseParam *p,
+ unsigned int index);
+ virtual ~PointwiseParamKnotHolderEntity() {}
+
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin,
+ guint state);
+ virtual Geom::Point knot_get() const;
+
+ /*Checks whether the index falls within the size of the parameter's vector*/
+ bool valid_index(unsigned int index) const {
+ return (_pparam->_vector.size() > index);
+ }
+ ;
+
+private:
+ PointwiseParam *_pparam;
+ unsigned int _index;
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif