diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-02-15 18:31:04 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-02-15 18:31:04 +0000 |
| commit | 3ff9b36f48101c62c460622dd683a582e5dc17ca (patch) | |
| tree | b3d56f7269ddec66552f5913c779aebf6398a324 /src | |
| parent | first steps (diff) | |
| download | inkscape-3ff9b36f48101c62c460622dd683a582e5dc17ca.tar.gz inkscape-3ff9b36f48101c62c460622dd683a582e5dc17ca.zip | |
first steps
(bzr r13645.1.10)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.cpp | 114 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.h | 95 |
2 files changed, 209 insertions, 0 deletions
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp new file mode 100644 index 000000000..f4f79b485 --- /dev/null +++ b/src/live_effects/parameter/satellitepairarray.cpp @@ -0,0 +1,114 @@ +/* + * 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" +#include "live_effects/parameter/satellitepairarray.h" +#include "sp-lpe-item.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 { + +SatellitePairArrayParam::SatellitePairArrayParam( + const Glib::ustring &label, const Glib::ustring &tip, + const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, + Effect *effect) + : ArrayParam<std::pair<int,Geom::Satellite> >(label, tip, key, wr, effect, 0) +{ + knot_shape = SP_KNOT_SHAPE_DIAMOND; + knot_mode = SP_KNOT_MODE_XOR; + knot_color = 0x00ff0000; +} + +SatellitePairArrayParam::~SatellitePairArrayParam() {} + +void SatellitePairArrayParam::set_oncanvas_looks(SPKnotShapeType shape, + SPKnotModeType mode, + guint32 color) +{ + knot_shape = shape; + knot_mode = mode; + knot_color = color; +} + +void SatellitePairArrayParam::set_pwd2( + Piecewise<D2<SBasis> > const &pwd2_in, + Piecewise<D2<SBasis> > const &pwd2_normal_in) +{ + last_pwd2 = pwd2_in; + last_pwd2_normal = pwd2_normal_in; +} + +void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPDesktop *desktop, + SPItem *item) +{ + for (unsigned int i = 0; i < _vector.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"); + SatellitePairArrayParamKnotHolderEntity *e = + new SatellitePairArrayParamKnotHolderEntity(this, i); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), + knot_shape, knot_mode, knot_color); + knotholder->add(e); + } +} + + +SatellitePairArrayParamKnotHolderEntity::SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index) + : _pparam(p), + _index(index) +{ +} + + + +void SatellitePairArrayParamKnotHolderEntity::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->last_pwd2[_pparam->_vector.at(_index).first]); + SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item); + if(splpeitem){ + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + +Geom::Point +SatellitePairArrayParamKnotHolderEntity::knot_get() const +{ + Geom::Point const canvas_point = _pparam->_vector.at(_index).second.getPosition(_pparam->last_pwd2[_pparam->_vector.at(_index).second]); + return canvas_point; +} + + +} /* 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/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h new file mode 100644 index 000000000..82d04c790 --- /dev/null +++ b/src/live_effects/parameter/satellitepairarray.h @@ -0,0 +1,95 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_H +#define INKSCAPE_LIVEPATHEFFECT_SATELLITE_PAIR_ARRAY_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 "live_effects/parameter/array.h" +#include "knot-holder-entity.h" + +namespace Inkscape { + +namespace LivePathEffect { + +class SatellitePairArrayParamKnotHolderEntity; + +class SatellitePairArrayParam : public ArrayParam<std::pair<int, Geom::Satellite> > { +public: + SatellitePairArrayParam(const Glib::ustring &label, + const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, + Effect *effect); + virtual ~SatellitePairArrayParam(); + + virtual Gtk::Widget * param_newWidget() { + return NULL; + } + + void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, + guint32 color); + virtual bool providesKnotHolderEntities() const { + return true; + } + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + void set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in, + Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_normal_in); + Geom::Piecewise<Geom::D2<Geom::SBasis> > const &get_pwd2() const { + return last_pwd2; + } + Geom::Piecewise<Geom::D2<Geom::SBasis> > const &get_pwd2_normal() const { + return last_pwd2_normal; + } + friend class SatellitePairArrayParamKnotHolderEntity; + +private: + SatellitePairArrayParam(const SatellitePairArrayParam &); + SatellitePairArrayParam &operator=(const SatellitePairArrayParam &); + + SPKnotShapeType knot_shape; + SPKnotModeType knot_mode; + guint32 knot_color; + + Geom::Piecewise<Geom::D2<Geom::SBasis> > last_pwd2; + Geom::Piecewise<Geom::D2<Geom::SBasis> > last_pwd2_normal; + +}; + +class SatellitePairArrayParamKnotHolderEntity : public KnotHolderEntity { +public: + SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index); + virtual ~SatellitePairArrayParamKnotHolderEntity() {} + + 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: + SatellitePairArrayParam *_pparam; + unsigned int _index; +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif |
