diff options
| author | Martin Owens <doctormo@gmail.com> | 2014-03-27 01:33:44 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2014-03-27 01:33:44 +0000 |
| commit | 5a4fb2325f60d292b47330f540b26a3279341c90 (patch) | |
| tree | d2aa7967be25450b83e625025366c618101ae49f /src/live_effects | |
| parent | The Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff) | |
| parent | Remove Snap menu item and improve grid menu item text (diff) | |
| download | inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip | |
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/live_effects')
85 files changed, 820 insertions, 739 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 44e57addf..12990ee24 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -7,14 +7,13 @@ //#define LPE_ENABLE_TEST_EFFECTS -#include "live_effects/effect.h" - #ifdef HAVE_CONFIG_H # include "config.h" #endif // include effects: #include "live_effects/lpe-patternalongpath.h" +#include "live_effects/effect.h" #include "live_effects/lpe-bendpath.h" #include "live_effects/lpe-sketch.h" #include "live_effects/lpe-vonkoch.h" @@ -59,7 +58,7 @@ #include "document-private.h" #include "xml/document.h" #include <glibmm/i18n.h> -#include "pen-context.h" +#include "ui/tools/pen-tool.h" #include "tools-switch.h" #include "message-stack.h" #include "desktop.h" @@ -120,9 +119,9 @@ const Util::EnumData<EffectType> LPETypeData[] = { {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, {SKETCH, N_("Sketch"), "sketch"}, {RULER, N_("Ruler"), "ruler"}, -/* 0.49 ?*/ - {POWERSTROKE, N_("[Unstable!] Power stroke"), "powerstroke"}, - {CLONE_ORIGINAL, N_("[Unstable!] Clone original path"), "clone_original"}, +/* 0.49 */ + {POWERSTROKE, N_("Power stroke"), "powerstroke"}, + {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, }; const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -271,7 +270,7 @@ void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) Inkscape::GC::release(repr); gchar *href = g_strdup_printf("#%s", repr_id); - sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); + SP_LPE_ITEM(item)->addPathEffect(href, true); g_free(href); } @@ -300,7 +299,7 @@ Effect::~Effect() } Glib::ustring -Effect::getName() +Effect::getName() const { if (lpeobj->effecttype_set && LPETypeConverter.is_valid_id(lpeobj->effecttype) ) return Glib::ustring( _(LPETypeConverter.get_label(lpeobj->effecttype).c_str()) ); @@ -309,7 +308,7 @@ Effect::getName() } EffectType -Effect::effectType() { +Effect::effectType() const { return lpeobj->effecttype; } @@ -317,7 +316,7 @@ Effect::effectType() { * Is performed a single time when the effect is freshly applied to a path */ void -Effect::doOnApply (SPLPEItem */*lpeitem*/) +Effect::doOnApply (SPLPEItem const*/*lpeitem*/) { } @@ -325,7 +324,7 @@ Effect::doOnApply (SPLPEItem */*lpeitem*/) * Is performed each time before the effect is updated. */ void -Effect::doBeforeEffect (SPLPEItem */*lpeitem*/) +Effect::doBeforeEffect (SPLPEItem const*/*lpeitem*/) { //Do nothing for simple effects } @@ -344,8 +343,8 @@ Effect::doAcceptPathPreparations(SPLPEItem *lpeitem) tools_switch(desktop, TOOLS_FREEHAND_PEN); } - SPEventContext *ec = desktop->event_context; - SPPenContext *pc = SP_PEN_CONTEXT(ec); + Inkscape::UI::Tools::ToolBase *ec = desktop->event_context; + Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(ec); pc->expecting_clicks_for_LPE = this->acceptsNumClicks(); pc->waiting_LPE = this; pc->waiting_item = lpeitem; @@ -370,7 +369,7 @@ Effect::writeParamsToSVG() { * your LPE. But don't forget to call the parent method so that is_ready is set to true! */ void -Effect::acceptParamPath (SPPath */*param_path*/) { +Effect::acceptParamPath (SPPath const*/*param_path*/) { setReady(); } @@ -424,7 +423,7 @@ Effect::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) } void -Effect::readallParameters(Inkscape::XML::Node * repr) +Effect::readallParameters(Inkscape::XML::Node const* repr) { std::vector<Parameter *>::iterator it = param_vector.begin(); while (it != param_vector.end()) { @@ -487,11 +486,13 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { } /** - * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect. - * This is the function called by external code like SPLPEItem. + * Return a vector of PathVectors which contain all canvas indicators for this effect. + * This is the function called by external code to get all canvas indicators (effect and its parameters) + * lpeitem = the item onto which this effect is applied + * @todo change return type to one pathvector, add all paths to one pathvector instead of maintaining a vector of pathvectors */ std::vector<Geom::PathVector> -Effect::getHelperPaths(SPLPEItem *lpeitem) +Effect::getCanvasIndicators(SPLPEItem const* lpeitem) { std::vector<Geom::PathVector> hp_vec; @@ -500,18 +501,10 @@ Effect::getHelperPaths(SPLPEItem *lpeitem) return hp_vec; } - // TODO: we can probably optimize this by using a lot more references - // rather than copying PathVectors all over the place - if (show_orig_path) { - // add original path to helperpaths - SPCurve* curve = SP_SHAPE(lpeitem)->getCurve (); - hp_vec.push_back(curve->get_pathvector()); - } - - // add other helperpaths provided by the effect itself + // add indicators provided by the effect itself addCanvasIndicators(lpeitem, hp_vec); - // add helperpaths provided by the effect's parameters + // add indicators provided by the effect's parameters for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { (*p)->addCanvasIndicators(lpeitem, hp_vec); } @@ -524,7 +517,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem) * This function should be overwritten by derived effects if they want to provide their own helperpaths. */ void -Effect::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) +Effect::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) { } @@ -643,7 +636,7 @@ Effect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop) * The nice thing about this is that this function can use knowledge of the original path and set things accordingly for example to the size or origin of the original path! */ void -Effect::resetDefaults(SPItem * /*item*/) +Effect::resetDefaults(SPItem const* /*item*/) { std::vector<Inkscape::LivePathEffect::Parameter *>::iterator p; for (p = param_vector.begin(); p != param_vector.end(); ++p) { @@ -663,7 +656,7 @@ Effect::transform_multiply(Geom::Affine const& postmul, bool set) } bool -Effect::providesKnotholder() +Effect::providesKnotholder() const { // does the effect actively provide any knotholder entities of its own? if (_provides_knotholder_entities) { @@ -671,7 +664,7 @@ Effect::providesKnotholder() } // otherwise: are there any parameters that have knotholderentities? - for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { + for (std::vector<Parameter *>::const_iterator p = param_vector.begin(); p != param_vector.end(); ++p) { if ((*p)->providesKnotHolderEntities()) { return true; } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 008de5ea8..1da9b4cc9 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -51,24 +51,24 @@ public: virtual ~Effect(); - EffectType effectType (); + EffectType effectType() const; - virtual void doOnApply (SPLPEItem *lpeitem); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); void writeParamsToSVG(); - virtual void acceptParamPath (SPPath *param_path); + virtual void acceptParamPath (SPPath const* param_path); static int acceptsNumClicks(EffectType type); - int acceptsNumClicks() { return acceptsNumClicks(effectType()); } + int acceptsNumClicks() const { return acceptsNumClicks(effectType()); } void doAcceptPathPreparations(SPLPEItem *lpeitem); /* * isReady() indicates whether all preparations which are necessary to apply the LPE are done, * e.g., waiting for a parameter path either before the effect is created or when it needs a - * path as argument. This is set in sp_lpe_item_add_path_effect(). + * path as argument. This is set in SPLPEItem::addPathEffect(). */ - inline bool isReady() { return is_ready; } + inline bool isReady() const { return is_ready; } inline void setReady(bool ready = true) { is_ready = ready; } virtual void doEffect (SPCurve * curve); @@ -78,35 +78,35 @@ public: /** * Sets all parameters to their default values and writes them to SVG. */ - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); /// /todo: is this method really necessary? it causes UI inconsistensies... (johan) virtual void transform_multiply(Geom::Affine const& postmul, bool set); // /TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is // created for an item or not. When we allow both at the same time, this needs rethinking! - bool providesKnotholder(); + bool providesKnotholder() const; // /TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant // (but spiro lpe still needs it!) - virtual LPEPathFlashType pathFlashType() { return DEFAULT; } + virtual LPEPathFlashType pathFlashType() const { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - std::vector<Geom::PathVector> getHelperPaths(SPLPEItem *lpeitem); + std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem const* lpeitem); - inline bool providesOwnFlashPaths() { + inline bool providesOwnFlashPaths() const { return provides_own_flash_paths || show_orig_path; } - inline bool showOrigPath() { return show_orig_path; } + inline bool showOrigPath() const { return show_orig_path; } - Glib::ustring getName(); + Glib::ustring getName() const; Inkscape::XML::Node * getRepr(); SPDocument * getSPDoc(); LivePathEffectObject * getLPEObj() {return lpeobj;}; Parameter * getParameter(const char * key); - void readallParameters(Inkscape::XML::Node * repr); + void readallParameters(Inkscape::XML::Node const* repr); void setParameter(const gchar * key, const gchar * new_value); - inline bool isVisible() { return is_visible; } + inline bool isVisible() const { return is_visible; } void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); @@ -128,7 +128,7 @@ protected: virtual void addKnotHolderEntities(KnotHolder * /*knotholder*/, SPDesktop * /*desktop*/, SPItem * /*item*/) {}; - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec); std::vector<Parameter *> param_vector; bool _provides_knotholder_entities; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index b337f71d8..1acf9605f 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_ANGLE_BISECTOR_CPP /* * Authors: * Maximilian Albert <maximilian.albert@gmail.com> @@ -9,6 +8,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-angle_bisector.h" #include <2geom/path.h> @@ -27,22 +28,22 @@ class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: KnotHolderEntityLeftEnd(LPEAngleBisector* effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityRightEnd : public LPEKnotHolderEntity { public: KnotHolderEntityRightEnd(LPEAngleBisector* effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; } // namespace TtC LPEAngleBisector::LPEAngleBisector(LivePathEffectObject *lpeobject) : Effect(lpeobject), - length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0), - length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250) + length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 0), + length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 250) { show_orig_path = true; _provides_knotholder_entities = true; @@ -60,8 +61,6 @@ LPEAngleBisector::doEffect_path (std::vector<Geom::Path> const & path_in) { using namespace Geom; - std::vector<Geom::Path> path_out; - // we assume that the path has >= 3 nodes ptA = path_in[0].pointAt(1); Point B = path_in[0].initialPoint(); @@ -90,7 +89,7 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt { KnotHolderEntity *e = new AB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the \"right\" of the bisector") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; @@ -98,11 +97,11 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt namespace AB { void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); lpe->length_left.param_set_value(-lambda); @@ -111,11 +110,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->dir); lpe->length_right.param_set_value(lambda); @@ -124,16 +123,16 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or } Geom::Point -KnotHolderEntityLeftEnd::knot_get() +KnotHolderEntityLeftEnd::knot_get() const { - LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect); + LPEAngleBisector const* lpe = dynamic_cast<LPEAngleBisector const*>(_effect); return lpe->ptA - lpe->dir * lpe->length_left; } Geom::Point -KnotHolderEntityRightEnd::knot_get() +KnotHolderEntityRightEnd::knot_get() const { - LPEAngleBisector *lpe = dynamic_cast<LPEAngleBisector *>(_effect); + LPEAngleBisector const* lpe = dynamic_cast<LPEAngleBisector const*>(_effect); return lpe->ptA + lpe->dir * lpe->length_right; } diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 2d6bbeb22..eaf9fe4a6 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_BENDPATH_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com> @@ -74,7 +72,7 @@ LPEBendPath::~LPEBendPath() } void -LPEBendPath::doBeforeEffect (SPLPEItem *lpeitem) +LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) { // get the item bounding box original_bbox(lpeitem); @@ -96,6 +94,10 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd bend_path.changed = false; } + if (uskeleton.empty()) { + return pwd2_in; /// \todo or throw an exception instead? might be better to throw an exception so that the UI can display an error message or smth + } + D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(pwd2_in); Piecewise<SBasis> x = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[1]) : Piecewise<SBasis>(patternd2[0]); Piecewise<SBasis> y = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]); @@ -107,9 +109,9 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd x-= bboxHorizontal.min(); y-= bboxVertical.middle(); - double scaling = uskeleton.cuts.back()/bboxHorizontal.extent(); + double scaling = uskeleton.cuts.back()/bboxHorizontal.extent(); - if (scaling != 1.0) { + if (scaling != 1.0) { x*=scaling; } @@ -119,13 +121,12 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd if (prop_scale != 1.0) y *= prop_scale; } - Piecewise<D2<SBasis> > output = compose(uskeleton,x) + y*compose(n,x); return output; } void -LPEBendPath::resetDefaults(SPItem * item) +LPEBendPath::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 98421df88..16b8c6137 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -10,9 +10,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "live_effects/parameter/enum.h" #include "live_effects/effect.h" #include "live_effects/parameter/path.h" -#include "live_effects/parameter/enum.h" #include "live_effects/parameter/bool.h" #include <2geom/sbasis.h> @@ -33,11 +33,11 @@ public: LPEBendPath(LivePathEffectObject *lpeobject); virtual ~LPEBendPath(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); private: diff --git a/src/live_effects/lpe-boolops.cpp b/src/live_effects/lpe-boolops.cpp index 1198df6c9..641cf5d50 100644 --- a/src/live_effects/lpe-boolops.cpp +++ b/src/live_effects/lpe-boolops.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_BOOLOPS_CPP /** \file * LPE boolops implementation */ @@ -33,8 +32,8 @@ static const Util::EnumDataConverter<unsigned> BoolopTypeConverter(BoolopTypeDat LPEBoolops::LPEBoolops(LivePathEffectObject *lpeobject) : Effect(lpeobject), - bool_path(_("2nd path"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"), - boolop_type(_("Boolop type"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION) + bool_path(_("2nd path:"), _("Path to which the original path will be boolop'ed."), "path_2nd", &wr, this, "M0,0 L1,0"), + boolop_type(_("Boolop type:"), _("Determines which kind of boolop will be performed."), "boolop_type", BoolopTypeConverter, &wr, this, Geom::BOOLOP_UNION) { show_orig_path = true; diff --git a/src/live_effects/lpe-boolops.h b/src/live_effects/lpe-boolops.h index 8040c1df6..3c8dc85c4 100644 --- a/src/live_effects/lpe-boolops.h +++ b/src/live_effects/lpe-boolops.h @@ -14,8 +14,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "live_effects/effect.h" #include "live_effects/parameter/enum.h" +#include "live_effects/effect.h" #include "live_effects/parameter/path.h" namespace Inkscape { diff --git a/src/live_effects/lpe-circle_3pts.cpp b/src/live_effects/lpe-circle_3pts.cpp index 951a3b7c8..fb7496f58 100644 --- a/src/live_effects/lpe-circle_3pts.cpp +++ b/src/live_effects/lpe-circle_3pts.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_CIRCLE_3PTS_CPP /** \file * LPE "Circle through 3 points" implementation */ diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index ce51f4aa2..d7cd6e19c 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -1,11 +1,11 @@ -#define INKSCAPE_LPE_CLONE_ORIGINAL_CPP - /* * Copyright (C) Johan Engelen 2012 <j.b.c.engelen@alumnus.utwente.nl> * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-clone-original.h" #include "display/curve.h" diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp index cb9c031aa..fbf9faf56 100644 --- a/src/live_effects/lpe-constructgrid.cpp +++ b/src/live_effects/lpe-constructgrid.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_CONSTRUCTGRID_CPP /** \file * LPE Construct Grid implementation */ @@ -11,6 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-constructgrid.h" #include <2geom/path.h> diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index bddd65be6..65bbcdad1 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_COPY_ROTATE_CPP /** \file * LPE <copy_rotate> implementation */ @@ -12,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-copy_rotate.h" #include "sp-shape.h" #include "display/curve.h" @@ -33,23 +34,23 @@ class KnotHolderEntityStartingAngle : public LPEKnotHolderEntity { public: KnotHolderEntityStartingAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity { public: KnotHolderEntityRotationAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; } // namespace CR LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : Effect(lpeobject), - starting_angle(_("Starting"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0), - rotation_angle(_("Rotation angle"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0), - num_copies(_("Number of copies"), _("Number of copies of the original path"), "num_copies", &wr, this, 5), + starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0), + rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0), + num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 5), origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"), dist_angle_handle(100) { @@ -72,9 +73,9 @@ LPECopyRotate::~LPECopyRotate() } void -LPECopyRotate::doOnApply(SPLPEItem *lpeitem) +LPECopyRotate::doOnApply(SPLPEItem const* lpeitem) { - SPCurve *curve = SP_SHAPE(lpeitem)->_curve; + SPCurve const *curve = SP_SHAPE(lpeitem)->_curve; A = *(curve->first_point()); B = *(curve->last_point()); @@ -114,7 +115,7 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p } void -LPECopyRotate::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { using namespace Geom; @@ -151,7 +152,7 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const { LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) @@ -171,7 +172,7 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const { LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) @@ -187,17 +188,17 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const } Geom::Point -KnotHolderEntityStartingAngle::knot_get() +KnotHolderEntityStartingAngle::knot_get() const { - LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect); - return snap_knot_position(lpe->start_pos); + LPECopyRotate const *lpe = dynamic_cast<LPECopyRotate const*>(_effect); + return lpe->start_pos; } Geom::Point -KnotHolderEntityRotationAngle::knot_get() +KnotHolderEntityRotationAngle::knot_get() const { - LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect); - return snap_knot_position(lpe->rot_pos); + LPECopyRotate const *lpe = dynamic_cast<LPECopyRotate const*>(_effect); + return lpe->rot_pos; } } // namespace CR diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h index b14bc4128..ca7aa269c 100644 --- a/src/live_effects/lpe-copy_rotate.h +++ b/src/live_effects/lpe-copy_rotate.h @@ -31,7 +31,7 @@ public: LPECopyRotate(LivePathEffectObject *lpeobject); virtual ~LPECopyRotate(); - virtual void doOnApply (SPLPEItem *lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); @@ -41,7 +41,7 @@ public: void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: ScalarParam starting_angle; diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 9bac3b860..854cc0734 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_CURVESTITCH_CPP /** \file * LPE Curve Stitching implementation, used as an example for a base starting class * when implementing new LivePathEffects. @@ -13,6 +12,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "ui/widget/scalar.h" +#include <glibmm/i18n.h> + #include "live_effects/lpe-curvestitch.h" #include "sp-item.h" @@ -29,8 +31,6 @@ #include <2geom/d2.h> #include <2geom/affine.h> -#include "ui/widget/scalar.h" - namespace Inkscape { namespace LivePathEffect { @@ -150,7 +150,7 @@ LPECurveStitch::doEffect_path (std::vector<Geom::Path> const & path_in) } void -LPECurveStitch::resetDefaults(SPItem * item) +LPECurveStitch::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-curvestitch.h b/src/live_effects/lpe-curvestitch.h index f46f2a5d2..38a11b4af 100644 --- a/src/live_effects/lpe-curvestitch.h +++ b/src/live_effects/lpe-curvestitch.h @@ -30,7 +30,7 @@ public: virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); virtual void transform_multiply(Geom::Affine const& postmul, bool set); diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 0fd31dccf..c60db4fc4 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_DYNASTROKE_CPP /** \file * LPE <dynastroke> implementation */ @@ -27,30 +26,6 @@ namespace Inkscape { namespace LivePathEffect { - -//---------------------------------------------------------- -//--- TODO: Test this and move to 2Geom -------------------- -//---------------------------------------------------------- - -static -std::vector<double> -find_corners (Geom::Piecewise<Geom::D2<Geom::SBasis> > const &m){ - using namespace Geom; - std::vector<double> output = std::vector<double>(); - Piecewise<D2<SBasis> > v = derivative(m); - for (unsigned i=0; i<m.size()-1; i++){ - if ( m.segs[i].at1() == m.segs[i+1].at0() && - v.segs[i].at1() != v.segs[i+1].at0()){ - output.push_back(m.cuts[i+1]); - } - } - return output; -} - -//---------------------------------------------------------- -//---------------------------------------------------------- -//---------------------------------------------------------- - //TODO: growfor/fadefor can be expressed in unit of width. //TODO: make round/sharp end choices independant for start and end. //TODO: define more styles like in calligtool. @@ -72,17 +47,17 @@ static const Util::EnumDataConverter<DynastrokeCappingType> DSCTConverter(Dynast LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - method(_("Method"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST), - width(_("Pen width"), _("Maximal stroke width"), "width", &wr, this, 25), - roundness(_("Pen roundness"), _("Min/Max width ratio"), "roundness", &wr, this, .2), - angle(_("angle"), _("direction of thickest strokes (opposite = thinest)"), "angle", &wr, this, 45), + method(_("Method:"), _("Choose pen type"), "method", DSMethodConverter, &wr, this, DSM_THICKTHIN_FAST), + width(_("Pen width:"), _("Maximal stroke width"), "width", &wr, this, 25), + roundness(_("Pen roundness:"), _("Min/Max width ratio"), "roundness", &wr, this, .2), + angle(_("Angle:"), _("direction of thickest strokes (opposite = thinnest)"), "angle", &wr, this, 45), // modulo_pi(_("modulo pi"), _("Give forward and backward moves in one direction the same thickness "), "modulo_pi", &wr, this, false), - start_cap(_("Start"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP), - end_cap(_("End"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP), - growfor(_("Grow for"), _("Make the stroke thiner near it's start"), "growfor", &wr, this, 100), - fadefor(_("Fade for"), _("Make the stroke thiner near it's end"), "fadefor", &wr, this, 100), + start_cap(_("Start:"), _("Choose start capping type"), "start_cap", DSCTConverter, &wr, this, DSCT_SHARP), + end_cap(_("End:"), _("Choose end capping type"), "end_cap", DSCTConverter, &wr, this, DSCT_SHARP), + growfor(_("Grow for:"), _("Make the stroke thinner near it's start"), "growfor", &wr, this, 100), + fadefor(_("Fade for:"), _("Make the stroke thinner near it's end"), "fadefor", &wr, this, 100), round_ends(_("Round ends"), _("Strokes end with a round end"), "round_ends", &wr, this, false), - capping(_("Capping"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") + capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") { registerParameter( dynamic_cast<Parameter *>(& method) ); @@ -116,7 +91,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p { using namespace Geom; - std::cout<<"do effect: debut\n"; +// std::cout<<"do effect: debut\n"; Piecewise<D2<SBasis> > output; Piecewise<D2<SBasis> > m = pwd2_in; @@ -153,17 +128,17 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p double angle_rad = angle*M_PI/180.;//TODO: revert orientation?... Piecewise<SBasis> w; - std::vector<double> corners = find_corners(m); + // std::vector<double> corners = find_corners(m); DynastrokeMethod stroke_method = method.get_value(); if (roundness==1.) { - std::cout<<"round pen.\n"; +// std::cout<<"round pen.\n"; n1 = n*double(width); n2 =-n1; }else{ switch(stroke_method) { case DSM_ELLIPTIC_PEN:{ - std::cout<<"ellptic pen\n"; +// std::cout<<"ellptic pen\n"; //FIXME: roundness=0??? double c = cos(angle_rad), s = sin(angle_rad); Affine rot,slant; @@ -179,7 +154,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p break; } case DSM_THICKTHIN_FAST:{ - std::cout<<"fast thick thin pen\n"; +// std::cout<<"fast thick thin pen\n"; D2<Piecewise<SBasis> > n_xy = make_cuts_independent(n); w = n_xy[X]*sin(angle_rad) - n_xy[Y]*cos(angle_rad); w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.); @@ -188,7 +163,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p break; } case DSM_THICKTHIN_SLOW:{ - std::cout<<"slow thick thin pen\n"; +// std::cout<<"slow thick thin pen\n"; D2<Piecewise<SBasis> > n_xy = make_cuts_independent(n); w = n_xy[X]*cos(angle_rad)+ n_xy[Y]*sin(angle_rad); w = w * ((1 - roundness)*width/2.) + ((1 + roundness)*width/2.); @@ -197,12 +172,12 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p Piecewise<SBasis> dw = derivative(w); Piecewise<SBasis> ncomp = sqrt(dot(v,v)-dw*dw,.1,3); //FIXME: is force continuity usefull? compatible with corners? - std::cout<<"ici\n"; +// std::cout<<"ici\n"; n1 = -dw*v + ncomp*rot90(v); n1 = w*force_continuity(unitVector(n1),.1); n2 = -dw*v - ncomp*rot90(v); n2 = w*force_continuity(unitVector(n2),.1); - std::cout<<"ici2\n"; +// std::cout<<"ici2\n"; break; } default:{ @@ -220,13 +195,13 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p Piecewise<D2<SBasis> > left, right; if ( m.segs.front().at0() == m.segs.back().at1()){ // if closed: - std::cout<<"closed input.\n"; +// std::cout<<"closed input.\n"; left = m + n1;//+ n; right = m + n2;//- n; } else { //if not closed, shape the ends: //TODO: allow fancy ends... - std::cout<<"shaping the ends\n"; +// std::cout<<"shaping the ends\n"; double grow_length = growfor;// * width; double fade_length = fadefor;// * width; Piecewise<SBasis > s = arcLengthSb(m); @@ -241,7 +216,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p factor_in.concat(Piecewise<SBasis >(Linear(1))); factor_in.cuts[2]=totlength; } - std::cout<<"shaping the ends ici\n"; +// std::cout<<"shaping the ends ici\n"; //scale factor for a sharp end join[0] = Linear(1,0); join[1] = Linear(1,1); @@ -255,7 +230,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p factor_out = Piecewise<SBasis >(join); factor_out.setDomain(Interval(totlength-fade_length,totlength)); } - std::cout<<"shaping the ends ici ici\n"; +// std::cout<<"shaping the ends ici ici\n"; Piecewise<SBasis > factor = factor_in*factor_out; n1 = compose(factor,s)*n1; @@ -263,10 +238,10 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p left = m + n1; right = m + n2; - std::cout<<"shaping the ends ici ici ici\n"; +// std::cout<<"shaping the ends ici ici ici\n"; if (start_cap.get_value() == DSCT_ROUND){ - std::cout<<"shaping round start\n"; +// std::cout<<"shaping round start\n"; SBasis tau(2,Linear(0)); tau[1] = Linear(-1,0); Piecewise<SBasis > hbump; @@ -281,7 +256,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p right += - hbump * rot90(n); } if (end_cap.get_value() == DSCT_ROUND){ - std::cout<<"shaping round end\n"; +// std::cout<<"shaping round end\n"; SBasis tau(2,Linear(0)); tau[1] = Linear(0,1); Piecewise<SBasis > hbump; @@ -300,11 +275,11 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p left = force_continuity(left); right = force_continuity(right); - std::cout<<"gathering result: left"; +// std::cout<<"gathering result: left"; output = left; - std::cout<<" + reverse(right)"; +// std::cout<<" + reverse(right)"; output.concat(reverse(right)); - std::cout<<". done\n"; +// std::cout<<". done\n"; //----------- return output; diff --git a/src/live_effects/lpe-dynastroke.h b/src/live_effects/lpe-dynastroke.h index ced376515..816cb60a6 100644 --- a/src/live_effects/lpe-dynastroke.h +++ b/src/live_effects/lpe-dynastroke.h @@ -14,9 +14,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "live_effects/parameter/enum.h" #include "live_effects/effect.h" #include "live_effects/parameter/parameter.h" -#include "live_effects/parameter/enum.h" #include "live_effects/parameter/path.h" #include "live_effects/parameter/bool.h" diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 49f294498..4f5623fba 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_ENVELOPE_CPP - /* * Copyright (C) Steren Giannini 2008 <steren.giannini@gmail.com> * @@ -52,7 +50,7 @@ LPEEnvelope::~LPEEnvelope() } void -LPEEnvelope::doBeforeEffect (SPLPEItem *lpeitem) +LPEEnvelope::doBeforeEffect (SPLPEItem const* lpeitem) { // get the item bounding box original_bbox(lpeitem); @@ -227,7 +225,7 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd } void -LPEEnvelope::resetDefaults(SPItem * item) +LPEEnvelope::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-envelope.h b/src/live_effects/lpe-envelope.h index fe1d9561d..64f6a4c0c 100644 --- a/src/live_effects/lpe-envelope.h +++ b/src/live_effects/lpe-envelope.h @@ -9,9 +9,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "live_effects/parameter/enum.h" #include "live_effects/effect.h" #include "live_effects/parameter/path.h" -#include "live_effects/parameter/enum.h" #include "live_effects/parameter/bool.h" #include <2geom/sbasis.h> @@ -31,11 +31,11 @@ public: LPEEnvelope(LivePathEffectObject *lpeobject); virtual ~LPEEnvelope(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); private: PathParam bend_path1; diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 61b61f7bf..8b3f4714a 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -13,6 +13,8 @@ #include "live_effects/lpe-extrude.h" +#include <glibmm/i18n.h> + #include <2geom/path.h> #include <2geom/piecewise.h> #include <2geom/transforms.h> @@ -122,9 +124,9 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2 } std::vector<double> connector_pts; - if (rts.size() < 1) { + if (rts.empty()) { connector_pts = cusps; - } else if (cusps.size() < 1) { + } else if (cusps.empty()) { connector_pts = rts; } else { connector_pts = rts; @@ -168,7 +170,7 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2 } void -LPEExtrude::resetDefaults(SPItem * item) +LPEExtrude::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-extrude.h b/src/live_effects/lpe-extrude.h index 0c9f11444..491fe4959 100644 --- a/src/live_effects/lpe-extrude.h +++ b/src/live_effects/lpe-extrude.h @@ -26,7 +26,7 @@ public: virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); private: VectorParam extrude_vector; diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index ac2db1716..003e22567 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_DOEFFECT_STACK_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * Copyright 2006 Michael G. Sloan <mgsloan@gmail.com> @@ -11,6 +9,9 @@ #include "live_effects/lpe-gears.h" #include <vector> + +#include <glibmm/i18n.h> + #include <2geom/d2.h> #include <2geom/sbasis.h> #include <2geom/bezier-to-sbasis.h> @@ -111,7 +112,8 @@ private: } }; -void makeContinuous(D2<SBasis> &a, Point const b) { +static void +makeContinuous(D2<SBasis> &a, Point const b) { for(unsigned d=0;d<2;d++) a[d][0][0] = b[d]; } diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index 83c41d3e9..e41bc6f0e 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_INTERPOLATE_CPP /** \file * LPE interpolate implementation */ @@ -11,6 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-interpolate.h" #include <2geom/path.h> @@ -98,7 +99,7 @@ LPEInterpolate::doEffect_path (Geom::PathVector const & path_in) } void -LPEInterpolate::resetDefaults(SPItem * item) +LPEInterpolate::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-interpolate.h b/src/live_effects/lpe-interpolate.h index 3091537f3..679001a81 100644 --- a/src/live_effects/lpe-interpolate.h +++ b/src/live_effects/lpe-interpolate.h @@ -29,7 +29,7 @@ public: virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); private: PathParam trajectory_path; ScalarParam number_of_steps; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 3a9b036d8..e91677e18 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -21,6 +21,8 @@ #include "knot-holder-entity.h" #include "knotholder.h" +#include <glibmm/i18n.h> + #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis.h> #include <2geom/d2.h> @@ -44,12 +46,12 @@ class KnotHolderEntityCrossingSwitcher : public LPEKnotHolderEntity { public: KnotHolderEntityCrossingSwitcher(LPEKnot *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; virtual void knot_click(guint state); }; -Geom::Path::size_type size_nondegenerate(Geom::Path const &path) { +static Geom::Path::size_type size_nondegenerate(Geom::Path const &path) { Geom::Path::size_type retval = path.size_open(); // if path is closed and closing segment is not degenerate @@ -159,14 +161,14 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect for( unsigned j=i; j<paths.size(); j++){ for( unsigned jj=(i==j?ii:0); jj < size_nondegenerate(paths[j]); jj++){ std::vector<std::pair<double,double> > times; - if ( i==j && ii==jj){ + if ( (i==j) && (ii==jj) ) { // std::cout<<"--(self int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; find_self_intersections( times, paths[i][ii].toSBasis() ); - }else{ + } else { // std::cout<<"--(pair int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; @@ -178,15 +180,17 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } for (unsigned k=0; k<times.size(); k++){ //std::cout<<"intersection "<<i<<"["<<ii<<"]("<<times[k].first<<")= "<<j<<"["<<jj<<"]("<<times[k].second<<")\n"; - if (times[k].first == times[k].first && times[k].second == times[k].second ){//is this the way to test NaN? + if ( !IS_NAN(times[k].first) && !IS_NAN(times[k].second) ){ double zero = 1e-4; - if ( i==j && fabs(times[k].first+ii - times[k].second-jj)<=zero ){//this is just end=start of successive curves in a path. + if ( (i==j) && (fabs(times[k].first+ii - times[k].second-jj) <= zero) ) + { //this is just end=start of successive curves in a path. continue; } - if ( i==j && ii == 0 && jj == size_nondegenerate(paths[i])-1 && - paths[i].closed() && - fabs(times[k].first) <= zero && - fabs(times[k].second - 1) <= zero ){//this is just end=start of a closed path. + if ( (i==j) && (ii == 0) && (jj == size_nondegenerate(paths[i])-1) + && paths[i].closed() + && (fabs(times[k].first) <= zero) + && (fabs(times[k].second - 1) <= zero) ) + {//this is just end=start of a closed path. continue; } CrossingPoint cp; @@ -216,7 +220,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } unsigned count = 0; for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ - if ( (*this)[m->second].i == i && (*this)[m->second].ti == m->first ){ + if ( ((*this)[m->second].i == i) && ((*this)[m->second].ti == m->first) ){ (*this)[m->second].ni = count; }else{ (*this)[m->second].nj = count; @@ -228,7 +232,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect CrossingPoints::CrossingPoints(std::vector<double> const &input) : std::vector<CrossingPoint>() { - if (input.size()>0 && input.size()%9 ==0){ + if ( (input.size() > 0) && (input.size()%9 == 0) ){ using namespace Geom; for( unsigned n=0; n<input.size(); ){ CrossingPoint cp; @@ -271,24 +275,25 @@ CrossingPoint CrossingPoints::get(unsigned const i, unsigned const ni) { for (unsigned k=0; k<size(); k++){ - if ( - ((*this)[k].i==i && (*this)[k].ni==ni) || - ((*this)[k].j==i && (*this)[k].nj==ni) - ) return (*this)[k]; + if ( ( ((*this)[k].i==i) && ((*this)[k].ni==ni) ) + || ( ((*this)[k].j==i) && ((*this)[k].nj==ni) ) ) + { + return (*this)[k]; + } } g_warning("LPEKnotNS::CrossingPoints::get error. %uth crossing along string %u not found.",ni,i); assert(false);//debug purpose... return CrossingPoint(); } -unsigned +static unsigned idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p) { double dist=-1; unsigned result = cpts.size(); for (unsigned k=0; k<cpts.size(); k++){ double dist_k = Geom::L2(p-cpts[k].pt); - if (dist<0 || dist>dist_k){ + if ( (dist < 0) || (dist > dist_k) ) { result = k; dist = dist_k; } @@ -302,28 +307,28 @@ void CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) { bool topo_changed = false; - for (unsigned n=0; n<size(); n++){ - if ( n<other.size() && - other[n].i == (*this)[n].i && - other[n].j == (*this)[n].j && - other[n].ni == (*this)[n].ni && - other[n].nj == (*this)[n].nj ) + for (unsigned n=0; n < size(); n++){ + if ( (n < other.size()) + && (other[n].i == (*this)[n].i) + && (other[n].j == (*this)[n].j) + && (other[n].ni == (*this)[n].ni) + && (other[n].nj == (*this)[n].nj) ) { (*this)[n].sign = other[n].sign; - }else{ + } else { topo_changed = true; break; } } - if (topo_changed){ + if (topo_changed) { //TODO: Find a way to warn the user!! // std::cout<<"knot topolgy changed!\n"; - for (unsigned n=0; n<size(); n++){ + for (unsigned n=0; n < size(); n++){ Geom::Point p = (*this)[n].pt; unsigned idx = idx_of_nearest(other,p); - if (idx<other.size()){ + if (idx < other.size()) { (*this)[n].sign = other[idx].sign; - }else{ + } else { (*this)[n].sign = default_value; } } @@ -410,7 +415,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) std::vector<Interval> dom; dom.push_back(Interval(0., size_nondegenerate(gpaths[i0]))); for (unsigned p = 0; p < crossing_points.size(); p++){ - if (crossing_points[p].i == i0 || crossing_points[p].j == i0){ + if ( (crossing_points[p].i == i0) || (crossing_points[p].j == i0) ) { unsigned i = crossing_points[p].i; unsigned j = crossing_points[p].j; double ti = crossing_points[p].ti; @@ -473,14 +478,14 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) //If the current path is closed and the last/first point is still there, glue first and last piece. unsigned beg_comp = 0, end_comp = dom.size(); - if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == size_nondegenerate(gpaths[i0]) ){ + if ( gpaths[i0].closed() && (dom.front().min() == 0) && (dom.back().max() == size_nondegenerate(gpaths[i0])) ) { if ( dom.size() == 1){ path_out.push_back(gpaths[i0]); continue; }else{ // std::cout<<"fusing first and last component\n"; - beg_comp++; - end_comp--; + ++beg_comp; + --end_comp; Path first = gpaths[i0].portion(dom.back()); //FIXME: STITCH_DISCONTINUOUS should not be necessary (?!?) first.append(gpaths[i0].portion(dom.front()), Path::STITCH_DISCONTINUOUS); @@ -498,7 +503,8 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) //recursively collect gpaths and stroke widths (stolen from "sp-lpe_item.cpp"). -void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ +static void +collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { @@ -528,7 +534,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &p void -LPEKnot::doBeforeEffect (SPLPEItem *lpeitem) +LPEKnot::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; original_bbox(lpeitem); @@ -585,25 +591,25 @@ LPEKnot::doBeforeEffect (SPLPEItem *lpeitem) } void -LPEKnot::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +LPEKnot::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { using namespace Geom; double r = switcher_size*.1; char const * svgd; //TODO: use a nice path! - if (selectedCrossing >= crossing_points.size()||crossing_points[selectedCrossing].sign > 0){ + if ( (selectedCrossing >= crossing_points.size()) || (crossing_points[selectedCrossing].sign > 0) ) { //svgd = "M -10,0 A 10 10 0 1 0 0,-10 l 5,-1 -1,2"; svgd = "m -7.07,7.07 c 3.9,3.91 10.24,3.91 14.14,0 3.91,-3.9 3.91,-10.24 0,-14.14 -3.9,-3.91 -10.24,-3.91 -14.14,0 l 2.83,-4.24 0.7,2.12"; - }else if (crossing_points[selectedCrossing].sign < 0){ + } else if (crossing_points[selectedCrossing].sign < 0) { //svgd = "M 10,0 A 10 10 0 1 1 0,-10 l -5,-1 1,2"; svgd = "m 7.07,7.07 c -3.9,3.91 -10.24,3.91 -14.14,0 -3.91,-3.9 -3.91,-10.24 0,-14.14 3.9,-3.91 10.24,-3.91 14.14,0 l -2.83,-4.24 -0.7,2.12"; - }else{ + } else { //svgd = "M 10,0 A 10 10 0 1 0 -10,0 A 10 10 0 1 0 10,0 "; svgd = "M 10,0 C 10,5.52 5.52,10 0,10 -5.52,10 -10,5.52 -10,0 c 0,-5.52 4.48,-10 10,-10 5.52,0 10,4.48 10,10 z"; } PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Affine(r,0,0,r,0,0); - pathv+=switcher; + pathv += switcher; hp_vec.push_back(pathv); } @@ -628,10 +634,10 @@ KnotHolderEntityCrossingSwitcher::knot_set(Geom::Point const &p, Geom::Point con } Geom::Point -KnotHolderEntityCrossingSwitcher::knot_get() +KnotHolderEntityCrossingSwitcher::knot_get() const { - LPEKnot* lpe = dynamic_cast<LPEKnot *>(_effect); - return snap_knot_position(lpe->switcher); + LPEKnot const *lpe = dynamic_cast<LPEKnot const*>(_effect); + return lpe->switcher; } void diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index 14c61a4e5..b937f9021 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -56,7 +56,7 @@ public: LPEKnot(LivePathEffectObject *lpeobject); virtual ~LPEKnot(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & input_path); /* the knotholder entity classes must be declared friends */ @@ -64,7 +64,7 @@ public: void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: void updateSwitcher(); diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 473469c8a..8136569e8 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -42,22 +42,22 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - grid_point0(_("Control handle 0"), _("Control handle 0"), "gridpoint0", &wr, this), - grid_point1(_("Control handle 1"), _("Control handle 1"), "gridpoint1", &wr, this), - grid_point2(_("Control handle 2"), _("Control handle 2"), "gridpoint2", &wr, this), - grid_point3(_("Control handle 3"), _("Control handle 3"), "gridpoint3", &wr, this), - grid_point4(_("Control handle 4"), _("Control handle 4"), "gridpoint4", &wr, this), - grid_point5(_("Control handle 5"), _("Control handle 5"), "gridpoint5", &wr, this), - grid_point6(_("Control handle 6"), _("Control handle 6"), "gridpoint6", &wr, this), - grid_point7(_("Control handle 7"), _("Control handle 7"), "gridpoint7", &wr, this), - grid_point8(_("Control handle 8"), _("Control handle 8"), "gridpoint8", &wr, this), - grid_point9(_("Control handle 9"), _("Control handle 9"), "gridpoint9", &wr, this), - grid_point10(_("Control handle 10"), _("Control handle 10"), "gridpoint10", &wr, this), - grid_point11(_("Control handle 11"), _("Control handle 11"), "gridpoint11", &wr, this), - grid_point12(_("Control handle 12"), _("Control handle 12"), "gridpoint12", &wr, this), - grid_point13(_("Control handle 13"), _("Control handle 13"), "gridpoint13", &wr, this), - grid_point14(_("Control handle 14"), _("Control handle 14"), "gridpoint14", &wr, this), - grid_point15(_("Control handle 15"), _("Control handle 15"), "gridpoint15", &wr, this) + grid_point0(_("Control handle 0:"), _("Control handle 0"), "gridpoint0", &wr, this), + grid_point1(_("Control handle 1:"), _("Control handle 1"), "gridpoint1", &wr, this), + grid_point2(_("Control handle 2:"), _("Control handle 2"), "gridpoint2", &wr, this), + grid_point3(_("Control handle 3:"), _("Control handle 3"), "gridpoint3", &wr, this), + grid_point4(_("Control handle 4:"), _("Control handle 4"), "gridpoint4", &wr, this), + grid_point5(_("Control handle 5:"), _("Control handle 5"), "gridpoint5", &wr, this), + grid_point6(_("Control handle 6:"), _("Control handle 6"), "gridpoint6", &wr, this), + grid_point7(_("Control handle 7:"), _("Control handle 7"), "gridpoint7", &wr, this), + grid_point8(_("Control handle 8:"), _("Control handle 8"), "gridpoint8", &wr, this), + grid_point9(_("Control handle 9:"), _("Control handle 9"), "gridpoint9", &wr, this), + grid_point10(_("Control handle 10:"), _("Control handle 10"), "gridpoint10", &wr, this), + grid_point11(_("Control handle 11:"), _("Control handle 11"), "gridpoint11", &wr, this), + grid_point12(_("Control handle 12:"), _("Control handle 12"), "gridpoint12", &wr, this), + grid_point13(_("Control handle 13:"), _("Control handle 13"), "gridpoint13", &wr, this), + grid_point14(_("Control handle 14:"), _("Control handle 14"), "gridpoint14", &wr, this), + grid_point15(_("Control handle 15:"), _("Control handle 15"), "gridpoint15", &wr, this) { // register all your parameters here, so Inkscape knows which parameters this effect has: @@ -173,13 +173,13 @@ LPELattice::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2 } void -LPELattice::doBeforeEffect (SPLPEItem *lpeitem) +LPELattice::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); } void -LPELattice::resetDefaults(SPItem * item) +LPELattice::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-lattice.h b/src/live_effects/lpe-lattice.h index f95e33b0b..a44dda3fd 100644 --- a/src/live_effects/lpe-lattice.h +++ b/src/live_effects/lpe-lattice.h @@ -31,11 +31,11 @@ public: LPELattice(LivePathEffectObject *lpeobject); virtual ~LPELattice(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); protected: //virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop); diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp index da30cd32c..78d286143 100644 --- a/src/live_effects/lpe-line_segment.cpp +++ b/src/live_effects/lpe-line_segment.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_LINE_SEGMENT_CPP - /** \file * LPE <line_segment> implementation */ @@ -14,7 +12,7 @@ */ #include "live_effects/lpe-line_segment.h" -#include "lpe-tool-context.h" +#include "ui/tools/lpe-tool.h" #include <2geom/pathvector.h> #include <2geom/geom.h> @@ -33,7 +31,7 @@ static const Util::EnumDataConverter<EndType> EndTypeConverter(EndTypeData, size LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) : Effect(lpeobject), - end_type(_("End type"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) + end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) { /* register all your parameters here, so Inkscape knows which parameters this effect has: */ registerParameter( dynamic_cast<Parameter *>(&end_type) ); @@ -45,9 +43,9 @@ LPELineSegment::~LPELineSegment() } void -LPELineSegment::doBeforeEffect (SPLPEItem *lpeitem) +LPELineSegment::doBeforeEffect (SPLPEItem const* lpeitem) { - lpetool_get_limiting_bbox_corners(lpeitem->document, bboxA, bboxB); + Inkscape::UI::Tools::lpetool_get_limiting_bbox_corners(lpeitem->document, bboxA, bboxB); } std::vector<Geom::Path> diff --git a/src/live_effects/lpe-line_segment.h b/src/live_effects/lpe-line_segment.h index b2bb0994f..1a57688b6 100644 --- a/src/live_effects/lpe-line_segment.h +++ b/src/live_effects/lpe-line_segment.h @@ -32,7 +32,7 @@ public: LPELineSegment(LivePathEffectObject *lpeobject); virtual ~LPELineSegment(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 2d043ca91..4d4837d8d 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -13,6 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-mirror_symmetry.h" #include <sp-path.h> #include <display/curve.h> @@ -28,7 +30,7 @@ namespace LivePathEffect { LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : Effect(lpeobject), discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false), - reflection_line(_("Reflection line"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") + reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") { show_orig_path = true; @@ -41,7 +43,7 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() } void -LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) +LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index a37e0d45c..c01d1bf6f 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -28,7 +28,7 @@ public: LPEMirrorSymmetry(LivePathEffectObject *lpeobject); virtual ~LPEMirrorSymmetry(); - virtual void doOnApply (SPLPEItem *lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index 26e86335b..192bd17ca 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_OFFSET_CPP /** \file * LPE <offset> implementation */ @@ -12,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-offset.h" #include "sp-shape.h" #include "display/curve.h" @@ -39,7 +40,7 @@ LPEOffset::~LPEOffset() } void -LPEOffset::doOnApply(SPLPEItem *lpeitem) +LPEOffset::doOnApply(SPLPEItem const* lpeitem) { offset_pt.param_set_and_write_new_value(*(SP_SHAPE(lpeitem)->_curve->first_point())); } diff --git a/src/live_effects/lpe-offset.h b/src/live_effects/lpe-offset.h index f57d41a14..9966fd45d 100644 --- a/src/live_effects/lpe-offset.h +++ b/src/live_effects/lpe-offset.h @@ -26,7 +26,7 @@ public: LPEOffset(LivePathEffectObject *lpeobject); virtual ~LPEOffset(); - virtual void doOnApply (SPLPEItem *lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 95340fcf4..bb37fd42c 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_PARALLEL_CPP /** \file * LPE <parallel> implementation */ @@ -12,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-parallel.h" #include "sp-shape.h" #include "display/curve.h" @@ -31,14 +32,14 @@ class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: KnotHolderEntityLeftEnd(LPEParallel *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityRightEnd : public LPEKnotHolderEntity { public: KnotHolderEntityRightEnd(LPEParallel *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; } // namespace Pl @@ -47,8 +48,8 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: offset_pt(_("Offset"), _("Adjust the offset"), "offset_pt", &wr, this), - length_left(_("Length left"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150), - length_right(_("Length right"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150) + length_left(_("Length left:"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150), + length_right(_("Length right:"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150) { show_orig_path = true; _provides_knotholder_entities = true; @@ -64,7 +65,7 @@ LPEParallel::~LPEParallel() } void -LPEParallel::doOnApply (SPLPEItem *lpeitem) +LPEParallel::doOnApply (SPLPEItem const* lpeitem) { SPCurve const *curve = SP_SHAPE(lpeitem)->_curve; @@ -112,13 +113,13 @@ void LPEParallel::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt namespace Pl { void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); lpe->length_left.param_set_value(-lambda); @@ -127,13 +128,13 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir)); lpe->length_right.param_set_value(lambda); @@ -142,16 +143,16 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or } Geom::Point -KnotHolderEntityLeftEnd::knot_get() +KnotHolderEntityLeftEnd::knot_get() const { - LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect); + LPEParallel const *lpe = dynamic_cast<LPEParallel const*>(_effect); return lpe->C; } Geom::Point -KnotHolderEntityRightEnd::knot_get() +KnotHolderEntityRightEnd::knot_get() const { - LPEParallel *lpe = dynamic_cast<LPEParallel *>(_effect); + LPEParallel const *lpe = dynamic_cast<LPEParallel const*>(_effect); return lpe->D; } diff --git a/src/live_effects/lpe-parallel.h b/src/live_effects/lpe-parallel.h index e23361675..ff19d690e 100644 --- a/src/live_effects/lpe-parallel.h +++ b/src/live_effects/lpe-parallel.h @@ -32,7 +32,7 @@ public: LPEParallel(LivePathEffectObject *lpeobject); virtual ~LPEParallel(); - virtual void doOnApply (SPLPEItem *lpeitem); + virtual void doOnApply (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp index e33a16002..4ca380c15 100644 --- a/src/live_effects/lpe-path_length.cpp +++ b/src/live_effects/lpe-path_length.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_PATH_LENGTH_CPP /** \file * LPE <path_length> implementation. */ @@ -12,8 +11,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-path_length.h" -#include "sp-metrics.h" +#include "util/units.h" #include "2geom/sbasis-geometric.h" @@ -22,9 +23,9 @@ namespace LivePathEffect { LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) : Effect(lpeobject), - scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), + scale(_("Scale:"), _("Scaling factor"), "scale", &wr, this, 1.0), info_text(this), - unit(_("Unit"), _("Unit"), "unit", &wr, this), + unit(_("Unit:"), _("Unit"), "unit", &wr, this), display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true) { registerParameter(dynamic_cast<Parameter *>(&scale)); @@ -51,11 +52,11 @@ LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p /* convert the measured length to the correct unit ... */ double lengthval = Geom::length(pwd2_in) * scale; - gboolean success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), unit); + lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit.get_abbreviation()); /* ... set it as the canvas text ... */ gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, - display_unit ? (success ? unit.get_abbreviation() : "px") : ""); + display_unit ? unit.get_abbreviation() : ""); info_text.param_setValue(arc_length); g_free(arc_length); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 0a05228d2..ed65a0d50 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_PATTERN_ALONG_PATH_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index f6d69f03c..feed55b26 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_PERP_BISECTOR_CPP /** \file * LPE <perp_bisector> implementation. */ @@ -13,6 +12,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-perp_bisector.h" #include "display/curve.h" #include "sp-path.h" @@ -30,41 +31,41 @@ namespace PB { class KnotHolderEntityEnd : public LPEKnotHolderEntity { public: KnotHolderEntityEnd(LPEPerpBisector *effect) : LPEKnotHolderEntity(effect) {}; - void bisector_end_set(Geom::Point const &p, bool left = true); + void bisector_end_set(Geom::Point const &p, guint state, bool left = true); }; class KnotHolderEntityLeftEnd : public KnotHolderEntityEnd { public: KnotHolderEntityLeftEnd(LPEPerpBisector *effect) : KnotHolderEntityEnd(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityRightEnd : public KnotHolderEntityEnd { public: KnotHolderEntityRightEnd(LPEPerpBisector *effect) : KnotHolderEntityEnd(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; Geom::Point -KnotHolderEntityLeftEnd::knot_get() { - LPEPerpBisector *lpe = dynamic_cast<LPEPerpBisector *>(_effect); +KnotHolderEntityLeftEnd::knot_get() const { + LPEPerpBisector const* lpe = dynamic_cast<LPEPerpBisector const*>(_effect); return Geom::Point(lpe->C); } Geom::Point -KnotHolderEntityRightEnd::knot_get() { - LPEPerpBisector *lpe = dynamic_cast<LPEPerpBisector *>(_effect); +KnotHolderEntityRightEnd::knot_get() const { + LPEPerpBisector const* lpe = dynamic_cast<LPEPerpBisector const*>(_effect); return Geom::Point(lpe->D); } void -KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) { +KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, guint state, bool left) { LPEPerpBisector *lpe = dynamic_cast<LPEPerpBisector *>(_effect); if (!lpe) return; - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->M, lpe->perp_dir); if (left) { @@ -80,21 +81,21 @@ KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, bool left) { } void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - bisector_end_set(p); +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + bisector_end_set(p, state); } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - bisector_end_set(p, false); +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + bisector_end_set(p, state, false); } } //namescape PB LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) : Effect(lpeobject), - length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200), - length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200), + length_left(_("Length left:"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200), + length_right(_("Length right:"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200), A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0) { show_orig_path = true; @@ -110,7 +111,7 @@ LPEPerpBisector::~LPEPerpBisector() } void -LPEPerpBisector::doOnApply (SPLPEItem */*lpeitem*/) +LPEPerpBisector::doOnApply (SPLPEItem const*/*lpeitem*/) { /* make the path a straight line */ /** @@ -155,13 +156,13 @@ LPEPerpBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskto { KnotHolderEntity *e = new PB::KnotHolderEntityLeftEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"left\" end") ); + _("Adjust the \"left\" end of the bisector") ); knotholder->add(e); } { KnotHolderEntity *e = new PB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"right\" end") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h index 823717e62..3a2278de3 100644 --- a/src/live_effects/lpe-perp_bisector.h +++ b/src/live_effects/lpe-perp_bisector.h @@ -27,7 +27,7 @@ namespace PB { class KnotHolderEntityEnd; class KnotHolderEntityLeftEnd; class KnotHolderEntityRightEnd; - void bisector_end_set(SPItem *item, Geom::Point const &p, bool left); + void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true); } class LPEPerpBisector : public Effect { @@ -37,7 +37,7 @@ public: virtual EffectType effectType () { return PERP_BISECTOR; } - void doOnApply (SPLPEItem *lpeitem); + void doOnApply (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); @@ -46,7 +46,7 @@ public: friend class PB::KnotHolderEntityEnd; friend class PB::KnotHolderEntityLeftEnd; friend class PB::KnotHolderEntityRightEnd; - friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, bool left = true); + friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left); void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c8048f74b..c255f8665 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -11,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "persp3d.h" //#include "transf_mat_3x4.h" #include "document.h" @@ -34,7 +36,7 @@ class KnotHolderEntityOffset : public LPEKnotHolderEntity public: KnotHolderEntityOffset(LPEPerspectivePath *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; } // namespace PP @@ -69,7 +71,7 @@ LPEPerspectivePath::~LPEPerspectivePath() } void -LPEPerspectivePath::doBeforeEffect (SPLPEItem *lpeitem) +LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem, true); } @@ -147,13 +149,13 @@ void LPEPerspectivePath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop namespace PP { void -KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint /*state*/) +KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) { using namespace Geom; LPEPerspectivePath* lpe = dynamic_cast<LPEPerspectivePath *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); lpe->offsetx.param_set_value((s - origin)[Geom::X]); lpe->offsety.param_set_value(-(s - origin)[Geom::Y]); // additional minus sign is due to coordinate system flipping @@ -163,9 +165,9 @@ KnotHolderEntityOffset::knot_set(Geom::Point const &p, Geom::Point const &origin } Geom::Point -KnotHolderEntityOffset::knot_get() +KnotHolderEntityOffset::knot_get() const { - LPEPerspectivePath* lpe = dynamic_cast<LPEPerspectivePath *>(_effect); + LPEPerspectivePath const *lpe = dynamic_cast<LPEPerspectivePath const*>(_effect); return lpe->orig + Geom::Point(lpe->offsetx, -lpe->offsety); } diff --git a/src/live_effects/lpe-perspective_path.h b/src/live_effects/lpe-perspective_path.h index 14321f52e..a9ee004f9 100644 --- a/src/live_effects/lpe-perspective_path.h +++ b/src/live_effects/lpe-perspective_path.h @@ -34,7 +34,7 @@ public: LPEPerspectivePath(LivePathEffectObject *lpeobject); virtual ~LPEPerspectivePath(); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 048742452..90b01aaa4 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -24,10 +24,12 @@ #include <2geom/bezier-utils.h> #include <2geom/svg-elliptical-arc.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> +#include <2geom/math-utils.h> +#include <math.h> #include "spiro.h" @@ -36,7 +38,7 @@ namespace Geom { /** Find the point where two straight lines cross. */ -boost::optional<Point> intersection_point( Point const & origin_a, Point const & vector_a, +static boost::optional<Point> intersection_point( Point const & origin_a, Point const & vector_a, Point const & origin_b, Point const & vector_b) { Coord denom = cross(vector_b, vector_a); @@ -47,7 +49,7 @@ boost::optional<Point> intersection_point( Point const & origin_a, Point const & return boost::none; } -Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2<Geom::SBasis> const & sbasis_in) +static Geom::CubicBezier sbasis_to_cubicbezier(Geom::D2<Geom::SBasis> const & sbasis_in) { std::vector<Geom::Point> temp; sbasis_to_bezier(temp, sbasis_in, 4); @@ -86,6 +88,96 @@ static Ellipse find_ellipse(Point P, Point Q, Point O) return Ellipse(A, B, C, D, E, F); } +/** + * Refer to: Weisstein, Eric W. "Circle-Circle Intersection." + From MathWorld--A Wolfram Web Resource. + http://mathworld.wolfram.com/Circle-CircleIntersection.html + * + * @return 0 if no intersection + * @return 1 if one circle is contained in the other + * @return 2 if intersections are found (they are written to p0 and p1) + */ +static int circle_circle_intersection(Circle const &circle0, Circle const &circle1, + Point & p0, Point & p1) +{ + Point X0 = circle0.center(); + double r0 = circle0.ray(); + Point X1 = circle1.center(); + double r1 = circle1.ray(); + + /* dx and dy are the vertical and horizontal distances between + * the circle centers. + */ + Point D = X1 - X0; + + /* Determine the straight-line distance between the centers. */ + double d = L2(D); + + /* Check for solvability. */ + if (d > (r0 + r1)) + { + /* no solution. circles do not intersect. */ + return 0; + } + if (d <= fabs(r0 - r1)) + { + /* no solution. one circle is contained in the other */ + return 1; + } + + /* 'point 2' is the point where the line through the circle + * intersection points crosses the line between the circle + * centers. + */ + + /* Determine the distance from point 0 to point 2. */ + double a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ; + + /* Determine the coordinates of point 2. */ + Point p2 = X0 + D * (a/d); + + /* Determine the distance from point 2 to either of the + * intersection points. + */ + double h = std::sqrt((r0*r0) - (a*a)); + + /* Now determine the offsets of the intersection points from + * point 2. + */ + Point r = (h/d)*rot90(D); + + /* Determine the absolute intersection points. */ + p0 = p2 + r; + p1 = p2 - r; + + return 2; +} + +/** + * Find circle that touches inside of the curve, with radius matching the curvature, at time value \c t. + * Because this method internally uses unitTangentAt, t should be smaller than 1.0 (see unitTangentAt). + */ +static Circle touching_circle( D2<SBasis> const &curve, double t, double tol=0.01 ) +{ + //Piecewise<SBasis> k = curvature(curve, tol); + D2<SBasis> dM=derivative(curve); + if ( are_near(L2sq(dM(t)),0.) ) { + dM=derivative(dM); + } + if ( are_near(L2sq(dM(t)),0.) ) { // try second time + dM=derivative(dM); + } + Piecewise<D2<SBasis> > unitv = unitVector(dM,tol); + Piecewise<SBasis> dMlength = dot(Piecewise<D2<SBasis> >(dM),unitv); + Piecewise<SBasis> k = cross(derivative(unitv),unitv); + k = divide(k,dMlength,tol,3); + double curv = k(t); // note that this value is signed + + Geom::Point normal = unitTangentAt(curve, t).cw(); + double radius = 1/curv; + Geom::Point center = curve(t) + radius*normal; + return Geom::Circle(center, fabs(radius)); +} } // namespace Geom @@ -121,7 +213,8 @@ enum LineJoinType { LINEJOIN_ROUND, LINEJOIN_EXTRP_MITER, LINEJOIN_MITER, - LINEJOIN_SPIRO + LINEJOIN_SPIRO, + LINEJOIN_EXTRP_MITER_ARC }; static const Util::EnumData<unsigned> LineJoinTypeData[] = { {LINEJOIN_BEVEL, N_("Beveled"), "bevel"}, @@ -129,19 +222,22 @@ static const Util::EnumData<unsigned> LineJoinTypeData[] = { {LINEJOIN_EXTRP_MITER, N_("Extrapolated"), "extrapolated"}, {LINEJOIN_MITER, N_("Miter"), "miter"}, {LINEJOIN_SPIRO, N_("Spiro"), "spiro"}, +#ifdef LPE_ENABLE_TEST_EFFECTS + {LINEJOIN_EXTRP_MITER_ARC, N_("Extrapolated arc"), "extrp_arc"}, +#endif }; static const Util::EnumDataConverter<unsigned> LineJoinTypeConverter(LineJoinTypeData, sizeof(LineJoinTypeData)/sizeof(*LineJoinTypeData)); LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : Effect(lpeobject), offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this), - sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true), - interpolator_type(_("Interpolator type"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path."), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), - interpolator_beta(_("Smoothness"), _("Sets the smoothness for the CubicBezierJohan interpolator. 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), - start_linecap_type(_("Start cap"), _("Determines the shape of the path's start."), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), - linejoin_type(_("Join"), _("Specifies the shape of the path's corners."), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), - miter_limit(_("Miter limit"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), - end_linecap_type(_("End cap"), _("Determines the shape of the path's end."), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) + sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve"), "sort_points", &wr, this, true), + interpolator_type(_("Interpolator type:"), _("Determines which kind of interpolator will be used to interpolate between stroke width along the path"), "interpolator_type", InterpolatorTypeConverter, &wr, this, Geom::Interpolate::INTERP_CUBICBEZIER_JOHAN), + interpolator_beta(_("Smoothness:"), _("Sets the smoothness for the CubicBezierJohan interpolator; 0 = linear interpolation, 1 = smooth"), "interpolator_beta", &wr, this, 0.2), + start_linecap_type(_("Start cap:"), _("Determines the shape of the path's start"), "start_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND), + linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", LineJoinTypeConverter, &wr, this, LINEJOIN_ROUND), + miter_limit(_("Miter limit:"), _("Maximum length of the miter (in units of stroke width)"), "miter_limit", &wr, this, 4.), + end_linecap_type(_("End cap:"), _("Determines the shape of the path's end"), "end_linecap_type", LineCapTypeConverter, &wr, this, LINECAP_ROUND) { show_orig_path = true; @@ -167,7 +263,7 @@ LPEPowerStroke::~LPEPowerStroke() void -LPEPowerStroke::doOnApply(SPLPEItem *lpeitem) +LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem) { if (SP_IS_SHAPE(lpeitem)) { std::vector<Geom::Point> points; @@ -205,12 +301,11 @@ static bool compare_offsets (Geom::Point first, Geom::Point second) return first[Geom::X] < second[Geom::X]; } -Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> > const & B, - Geom::Piecewise<Geom::SBasis> const & y, // width path - LineJoinType jointype, - double miter_limit, - bool /*forward_direction*/, - double tol=Geom::EPSILON) +static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> > const & B, + Geom::Piecewise<Geom::SBasis> const & y, // width path + LineJoinType jointype, + double miter_limit, + double tol=Geom::EPSILON) { /* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type */ @@ -310,6 +405,65 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> } break; } + case LINEJOIN_EXTRP_MITER_ARC: { + Geom::Circle circle1 = Geom::touching_circle(reverse(B[prev_i]),0.); + Geom::Circle circle2 = Geom::touching_circle(B[i],0.); + Geom::Point points[2]; + int solutions = circle_circle_intersection(circle1, circle2, points[0], points[1]); + if (solutions == 2) { + Geom::Point sol(0.,0.); + if ( dot(tang2,points[0]-B[i].at0()) > 0 ) { + // points[0] is bad, choose points[1] + sol = points[1]; + } else if ( dot(tang2,points[1]-B[i].at0()) > 0 ) { // points[0] could be good, now check points[1] + // points[1] is bad, choose points[0] + sol = points[0]; + } else { + // both points are good, choose nearest + sol = ( distanceSq(B[i].at0(), points[0]) < distanceSq(B[i].at0(), points[1]) ) ? + points[0] : points[1]; + } + + Geom::EllipticalArc *arc0 = circle1.arc(B[prev_i].at1(), 0.5*(B[prev_i].at1()+sol), sol, true); + Geom::EllipticalArc *arc1 = circle2.arc(sol, 0.5*(sol+B[i].at0()), B[i].at0(), true); + + if (arc0) { + build_from_sbasis(pb,arc0->toSBasis(), tol, false); + delete arc0; + arc0 = NULL; + } + if (arc1) { + build_from_sbasis(pb,arc1->toSBasis(), tol, false); + delete arc1; + arc1 = NULL; + } + + break; + } else { + // fall back to miter + boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1, + B[i].at0(), tang2 ); + if (p) { + // check size of miter + Geom::Point point_on_path = B[prev_i].at1() - rot90(tang1) * width; + Geom::Coord len = distance(*p, point_on_path); + if (len <= fabs(width) * miter_limit) { + // miter OK + pb.lineTo(*p); + } + } + pb.lineTo(B[i].at0()); + } + /*else if (solutions == 1) { // one circle is inside the other + // don't know what to do: default to bevel + pb.lineTo(B[i].at0()); + } else { // no intersections + // don't know what to do: default to bevel + pb.lineTo(B[i].at0()); + } */ + + break; + } case LINEJOIN_MITER: { boost::optional<Geom::Point> p = intersection_point( B[prev_i].at1(), tang1, B[i].at0(), tang2 ); @@ -382,7 +536,7 @@ Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> prev_i = i; } - pb.finish(); + pb.flush(); return pb.peek().front(); } @@ -453,7 +607,7 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) Piecewise<D2<SBasis> > pwd2_out = compose(pwd2_in,x) + y*compose(n,x); Piecewise<D2<SBasis> > mirrorpath = reverse(compose(pwd2_in,x) - y*compose(n,x)); - Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE); + Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE); Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, reverse(y), jointype, miter_limit, LPE_CONVERSION_TOLERANCE); if (path_in[0].closed()) { diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index e6c915234..7bc736820 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -27,7 +27,7 @@ public: virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); - virtual void doOnApply(SPLPEItem *lpeitem); + virtual void doOnApply(SPLPEItem const* lpeitem); // methods called by path-manipulator upon edits void adjustForNewPath(std::vector<Geom::Path> const & path_in); diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index c1cc47d7f..ac571d963 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -10,6 +10,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-recursiveskeleton.h" #include <2geom/path.h> @@ -25,7 +27,7 @@ namespace LivePathEffect { LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) : Effect(lpeobject), - iterations(_("Iterations"), _("recursivity"), "iterations", &wr, this, 2) + iterations(_("Iterations:"), _("recursivity"), "iterations", &wr, this, 2) { show_orig_path = true; concatenate_before_pwd2 = true; @@ -47,8 +49,6 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > co using namespace Geom; Piecewise<D2<SBasis> > output; - std::vector<Piecewise<D2<SBasis> > > pre_output; - double prop_scale = 1.0; D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(pwd2_in); @@ -88,11 +88,11 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > co Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton)); n = force_continuity(remove_short_cuts(n,.1)); - double scaling = 1; - scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); + double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); // TODO investigate why pattWidth is not being used: - double pattWidth = pattBndsX->extent() * scaling; + // - Doesn't appear to have been used anywhere in bzr history (Alex V: 2013-03-16) + // double pattWidth = pattBndsX->extent() * scaling; if (scaling != 1.0) { x*=scaling; diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index fb3d143aa..6ffb913bd 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_ROUGH_HATCHES_CPP /** \file * LPE Curve Stitching implementation, used as an example for a base starting class * when implementing new LivePathEffects. @@ -14,6 +13,7 @@ */ #include "ui/widget/scalar.h" +#include <glibmm/i18n.h> #include "live_effects/lpe-rough-hatches.h" #include "sp-item.h" @@ -67,7 +67,7 @@ struct LevelCrossingInfoOrder { typedef std::vector<LevelCrossing> LevelCrossings; -std::vector<double> +static std::vector<double> discontinuities(Piecewise<D2<SBasis> > const &f){ std::vector<double> result; if (f.size()==0) return result; @@ -210,7 +210,7 @@ public: // Bend a path... //------------------------------------------------------- -Piecewise<D2<SBasis> > bend(Piecewise<D2<SBasis> > const &f, Piecewise<SBasis> bending){ +static Piecewise<D2<SBasis> > bend(Piecewise<D2<SBasis> > const &f, Piecewise<SBasis> bending){ D2<Piecewise<SBasis> > ff = make_cuts_independent(f); ff[X] += compose(bending, ff[Y]); return sectionize(ff); @@ -239,10 +239,10 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : fat_output(_("Generate thick/thin path"), _("Simulate a stroke of varying width"), "fat_output", &wr, this, true), do_bend(_("Bend hatches"), _("Add a global bend to the hatches (slower)"), "do_bend", &wr, this, true), stroke_width_top(_("Thickness: at 1st side:"), _("Width at 'bottom' half-turns"), "stroke_width_top", &wr, this, 1.), - stroke_width_bot(_("at 2nd side:"), _("Width at 'top' half-turns"), "stroke_width_bottom", &wr, this, 1.), + stroke_width_bot(_("At 2nd side:"), _("Width at 'top' half-turns"), "stroke_width_bottom", &wr, this, 1.), // - front_thickness(_("from 2nd to 1st side:"), _("Width from 'top' to 'bottom'"), "front_thickness", &wr, this, 1.), - back_thickness(_("from 1st to 2nd side:"), _("Width from 'bottom' to 'top'"), "back_thickness", &wr, this, .25), + front_thickness(_("From 2nd to 1st side:"), _("Width from 'top' to 'bottom'"), "front_thickness", &wr, this, 1.), + back_thickness(_("From 1st to 2nd side:"), _("Width from 'bottom' to 'top'"), "back_thickness", &wr, this, .25), direction(_("Hatches width and dir"), _("Defines hatches frequency and direction"), "direction", &wr, this, Geom::Point(50,0)), // @@ -413,7 +413,7 @@ LPERoughHatches::linearSnake(Piecewise<D2<SBasis> > const &f, Point const &org){ while ( i < lscs.size() ){ int dir = 0; //switch orientation of first segment according to starting point. - if ((i % 2 == n % 2) && ((j + 1) < lscs[i].size()) && !lscs[i][j].used){ + if ((static_cast<long long>(i) % 2 == n % 2) && ((j + 1) < lscs[i].size()) && !lscs[i][j].used){ j += 1; dir = 2; } @@ -538,7 +538,7 @@ LPERoughHatches::smoothSnake(std::vector<std::vector<Point> > const &linearSnake } void -LPERoughHatches::doBeforeEffect (SPLPEItem */*lpeitem*/) +LPERoughHatches::doBeforeEffect (SPLPEItem const*/*lpeitem*/) { using namespace Geom; top_edge_variation.resetRandomizer(); @@ -554,7 +554,7 @@ LPERoughHatches::doBeforeEffect (SPLPEItem */*lpeitem*/) void -LPERoughHatches::resetDefaults(SPItem * item) +LPERoughHatches::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-rough-hatches.h b/src/live_effects/lpe-rough-hatches.h index 5051b313a..f8454e1ea 100644 --- a/src/live_effects/lpe-rough-hatches.h +++ b/src/live_effects/lpe-rough-hatches.h @@ -31,9 +31,9 @@ public: virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); - virtual void doBeforeEffect(SPLPEItem * item); + virtual void doBeforeEffect(SPLPEItem const* item); std::vector<double> generateLevels(Geom::Interval const &domain, double x_org); diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index d7a393197..788ab593a 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_RULER_CPP - /** \file * LPE <ruler> implementation, see lpe-ruler.cpp. */ @@ -82,11 +80,10 @@ LPERuler::ruler_mark(Geom::Point const &A, Geom::Point const &n, MarkType const { using namespace Geom; - gboolean success; double real_mark_length = mark_length; - success = sp_convert_distance(&real_mark_length, unit, &sp_unit_get_by_id(SP_UNIT_PX)); + real_mark_length = Inkscape::Util::Quantity::convert(real_mark_length, unit.get_abbreviation(), "px"); double real_minor_mark_length = minor_mark_length; - success = sp_convert_distance(&real_minor_mark_length, unit, &sp_unit_get_by_id(SP_UNIT_PX)); + real_minor_mark_length = Inkscape::Util::Quantity::convert(real_minor_mark_length, unit.get_abbreviation(), "px"); n_major = real_mark_length * n; n_minor = real_minor_mark_length * n; @@ -136,10 +133,10 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_i std::vector<double> s_cuts; double real_mark_distance = mark_distance; - gboolean success = sp_convert_distance(&real_mark_distance, unit, &sp_unit_get_by_id(SP_UNIT_PX)); + real_mark_distance = Inkscape::Util::Quantity::convert(real_mark_distance, unit.get_abbreviation(), "px"); double real_offset = offset; - success = sp_convert_distance(&real_offset, unit, &sp_unit_get_by_id(SP_UNIT_PX)); + real_offset = Inkscape::Util::Quantity::convert(real_offset, unit.get_abbreviation(), "px"); for (double s = real_offset; s<totlength; s+=real_mark_distance){ s_cuts.push_back(s); } @@ -152,10 +149,10 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_i t_cuts.push_back(roots[v][0]); } //draw the marks - for (unsigned i=0; i<t_cuts.size(); i++){ + for (size_t i = 0; i < t_cuts.size(); i++) { Point A = pwd2_in(t_cuts[i]); Point n = rot90(unit_vector(speed(t_cuts[i])))*sign; - if ((i % mminterval) == i_shift) { + if (static_cast<int>(i % mminterval) == i_shift) { output.concat (ruler_mark(A, n, MARK_MAJOR)); } else { output.concat (ruler_mark(A, n, MARK_MINOR)); diff --git a/src/live_effects/lpe-ruler.h b/src/live_effects/lpe-ruler.h index 497398e22..8c5c83ceb 100644 --- a/src/live_effects/lpe-ruler.h +++ b/src/live_effects/lpe-ruler.h @@ -15,8 +15,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "live_effects/effect.h" #include "live_effects/parameter/enum.h" +#include "live_effects/effect.h" #include "live_effects/parameter/unit.h" namespace Inkscape { diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index f3d7788d6..c61e9773f 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -23,6 +23,8 @@ // You might need to include other 2geom files. You can add them here: #include <2geom/path.h> +#include <glibmm/i18n.h> + //#include "knot-holder-entity.h" //#include "knotholder.h" @@ -93,7 +95,7 @@ class KnotHolderEntityMyHandle : public LPEKnotHolderEntity public: // the set() and get() methods must be implemented, click() is optional virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; //virtual void knot_click(guint state); }; diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e39b82f20..8ad0e616f 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -13,6 +13,8 @@ #include "live_effects/lpe-sketch.h" +#include <glibmm/i18n.h> + // You might need to include other 2geom files. You can add them here: #include <2geom/path.h> #include <2geom/sbasis.h> @@ -360,7 +362,7 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_ } void -LPESketch::doBeforeEffect (SPLPEItem */*lpeitem*/) +LPESketch::doBeforeEffect (SPLPEItem const*/*lpeitem*/) { //init random parameters. parallel_offset.resetRandomizer(); diff --git a/src/live_effects/lpe-sketch.h b/src/live_effects/lpe-sketch.h index b95f57682..3bef0cf5e 100644 --- a/src/live_effects/lpe-sketch.h +++ b/src/live_effects/lpe-sketch.h @@ -31,7 +31,7 @@ public: virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void doBeforeEffect (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); private: // add the parameters for your effect here: diff --git a/src/live_effects/lpe-spiro.h b/src/live_effects/lpe-spiro.h index f3cdbda79..edce42280 100644 --- a/src/live_effects/lpe-spiro.h +++ b/src/live_effects/lpe-spiro.h @@ -18,7 +18,7 @@ public: LPESpiro(LivePathEffectObject *lpeobject); virtual ~LPESpiro(); - virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 633a36860..dbebdf7fb 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_TANGENT_TO_CURVE_CPP /** \file * Implementation of tangent-to-curve LPE. */ @@ -14,6 +13,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-tangent_to_curve.h" // FIXME: The following are only needed to convert the path's SPCurve* to pwd2. // There must be a more convenient way to achieve this. @@ -35,14 +36,14 @@ class KnotHolderEntityAttachPt : public LPEKnotHolderEntity { public: KnotHolderEntityAttachPt(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity { public: KnotHolderEntityLeftEnd(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; class KnotHolderEntityRightEnd : public LPEKnotHolderEntity @@ -50,17 +51,17 @@ class KnotHolderEntityRightEnd : public LPEKnotHolderEntity public: KnotHolderEntityRightEnd(LPETangentToCurve *effect) : LPEKnotHolderEntity(effect) {}; virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; }; } // namespace TtC LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : Effect(lpeobject), - angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0), - t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5), - length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150), - length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) + angle(_("Angle:"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0), + t_attach(_("Location along curve:"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5), + length_left(_("Length left:"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150), + length_right(_("Length right:"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150) { show_orig_path = true; _provides_knotholder_entities = true; @@ -121,13 +122,13 @@ LPETangentToCurve::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desk namespace TtC { void -KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; LPETangentToCurve* lpe = dynamic_cast<LPETangentToCurve *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); // FIXME: There must be a better way of converting the path's SPCurve* to pwd2. SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); @@ -145,11 +146,11 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or } void -KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA); lpe->length_left.param_set_value(-lambda); @@ -158,11 +159,11 @@ KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*ori } void -KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double lambda = Geom::nearest_point(s, lpe->ptA, lpe->derivA); lpe->length_right.param_set_value(lambda); @@ -171,23 +172,23 @@ KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*or } Geom::Point -KnotHolderEntityAttachPt::knot_get() +KnotHolderEntityAttachPt::knot_get() const { - LPETangentToCurve* lpe = dynamic_cast<LPETangentToCurve *>(_effect); + LPETangentToCurve const *lpe = dynamic_cast<LPETangentToCurve const*>(_effect); return lpe->ptA; } Geom::Point -KnotHolderEntityLeftEnd::knot_get() +KnotHolderEntityLeftEnd::knot_get() const { - LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect); + LPETangentToCurve const *lpe = dynamic_cast<LPETangentToCurve const*>(_effect); return lpe->C; } Geom::Point -KnotHolderEntityRightEnd::knot_get() +KnotHolderEntityRightEnd::knot_get() const { - LPETangentToCurve *lpe = dynamic_cast<LPETangentToCurve *>(_effect); + LPETangentToCurve const *lpe = dynamic_cast<LPETangentToCurve const*>(_effect); return lpe->D; } diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index bb6d36fdc..03e3e7997 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -1,11 +1,11 @@ -#define INKSCAPE_LPE_DOEFFECT_STACK_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-test-doEffect-stack.h" #include <2geom/piecewise.h> @@ -19,9 +19,9 @@ namespace LivePathEffect { LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : Effect(lpeobject), - step(_("Stack step"), ("How deep we should go into the stack"), "step", &wr, this), - point(_("point param"), "tooltip of point parameter", "point_param", &wr, this), - path(_("path param"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") + step(_("Stack step:"), ("How deep we should go into the stack"), "step", &wr, this), + point(_("Point param:"), "tooltip of point parameter", "point_param", &wr, this), + path(_("Path param:"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") { registerParameter( dynamic_cast<Parameter *>(&step) ); registerParameter( dynamic_cast<Parameter *>(&point) ); diff --git a/src/live_effects/lpe-text_label.cpp b/src/live_effects/lpe-text_label.cpp index c986dbd63..602a6897c 100644 --- a/src/live_effects/lpe-text_label.cpp +++ b/src/live_effects/lpe-text_label.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_LPE_TEXT_LABEL_CPP /** \file * LPE <text_label> implementation */ @@ -12,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/lpe-text_label.h" namespace Inkscape { @@ -19,7 +20,7 @@ namespace LivePathEffect { LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) : Effect(lpeobject), - label(_("Label"), _("Text label attached to the path"), "label", &wr, this, "This is a label") + label(_("Label:"), _("Text label attached to the path"), "label", &wr, this, "This is a label") { registerParameter( dynamic_cast<Parameter *>(&label) ); } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 953c2d443..c0050fa60 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LPE_VONKOCH_CPP - /* * Copyright (C) JF Barraud 2007 <jf.barraud@gmail.com> * @@ -7,6 +5,9 @@ */ #include <cstdio> + +#include <glibmm/i18n.h> + #include "live_effects/lpe-vonkoch.h" #include <2geom/transforms.h> @@ -175,7 +176,7 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in) //Usefull?? //void -//LPEVonKoch::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +//LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) /*{ using namespace Geom; if (draw_boxes.get_value()){ @@ -240,7 +241,7 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in) */ void -LPEVonKoch::doBeforeEffect (SPLPEItem *lpeitem) +LPEVonKoch::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; original_bbox(lpeitem); @@ -268,7 +269,7 @@ LPEVonKoch::doBeforeEffect (SPLPEItem *lpeitem) void -LPEVonKoch::resetDefaults(SPItem * item) +LPEVonKoch::resetDefaults(SPItem const* item) { Effect::resetDefaults(item); diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index 7862cdbb5..7dff2be52 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -51,13 +51,13 @@ public: virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in); - virtual void resetDefaults(SPItem * item); + virtual void resetDefaults(SPItem const* item); - virtual void doBeforeEffect(SPLPEItem * item); + virtual void doBeforeEffect(SPLPEItem const* item); //Usefull?? // protected: - //virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: ScalarParam nbgenerations; diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index e2378265a..2a1b70a6a 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -22,7 +22,7 @@ namespace LivePathEffect { * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine. * @post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met. */ -void GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) +void GroupBBoxEffect::original_bbox(SPLPEItem const* lpeitem, bool absolute) { // Get item bounding box Geom::Affine transform; diff --git a/src/live_effects/lpegroupbbox.h b/src/live_effects/lpegroupbbox.h index 57577d20f..cc14203d1 100644 --- a/src/live_effects/lpegroupbbox.h +++ b/src/live_effects/lpegroupbbox.h @@ -22,7 +22,7 @@ protected: Geom::Interval boundingbox_Y; //This sets boundingbox_X and boundingbox_Y - void original_bbox(SPLPEItem *lpeitem, bool absolute = false); + void original_bbox(SPLPEItem const* lpeitem, bool absolute = false); }; }; //namespace LivePathEffect diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index 571c3b1f1..b1ba1ee4e 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -15,11 +15,11 @@ namespace Inkscape { namespace XML { -struct Node; +class Node; } } -struct LivePathEffectObject; +class LivePathEffectObject; namespace Inkscape { diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 3e4e40198..d92c94d01 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -20,33 +20,18 @@ //#define LIVEPATHEFFECT_VERBOSE -static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); +#include "sp-factory.h" -static SPObjectClass *livepatheffect_parent_class; -/** - * Registers the LivePathEffect class with Gdk and returns its type number. - */ -GType -LivePathEffectObject::livepatheffect_get_type () -{ - static GType livepatheffect_type = 0; - - if (!livepatheffect_type) { - GTypeInfo livepatheffect_info = { - sizeof (LivePathEffectObjectClass), - NULL, NULL, - (GClassInitFunc) LivePathEffectObject::livepatheffect_class_init, - NULL, NULL, - sizeof (LivePathEffectObject), - 16, - (GInstanceInitFunc) LivePathEffectObject::livepatheffect_init, - NULL, - }; - livepatheffect_type = g_type_register_static (SP_TYPE_OBJECT, "LivePathEffectObject", &livepatheffect_info, (GTypeFlags)0); - } - return livepatheffect_type; +namespace { + SPObject* createLivepatheffect() { + return new LivePathEffectObject(); + } + + bool livepatheffectRegistered = SPFactory::instance().registerObject("inkscape:path-effect", createLivepatheffect); } +static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); + static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { NULL, /* child_added */ NULL, /* child_removed */ @@ -56,57 +41,31 @@ static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = { }; -/** - * Callback to initialize livepatheffect vtable. - */ -void -LivePathEffectObject::livepatheffect_class_init(LivePathEffectObjectClass *klass) -{ - SPObjectClass *sp_object_class = (SPObjectClass *) klass; - - livepatheffect_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT); - - sp_object_class->build = livepatheffect_build; - sp_object_class->release = livepatheffect_release; - - sp_object_class->set = livepatheffect_set; - sp_object_class->write = livepatheffect_write; -} - -/** - * Callback to initialize livepatheffect object. - */ -void -LivePathEffectObject::livepatheffect_init(LivePathEffectObject *lpeobj) +LivePathEffectObject::LivePathEffectObject() + : SPObject(), effecttype(Inkscape::LivePathEffect::INVALID_LPE), effecttype_set(false), + lpe(NULL) { #ifdef LIVEPATHEFFECT_VERBOSE g_message("Init livepatheffectobject"); #endif - lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; - lpeobj->lpe = NULL; +} - lpeobj->effecttype_set = false; +LivePathEffectObject::~LivePathEffectObject() { } /** * Virtual build: set livepatheffect attributes from its associated XML node. */ -void -LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ -#ifdef LIVEPATHEFFECT_VERBOSE - g_message("Build livepatheffect"); -#endif - g_assert(object != NULL); - g_assert(SP_IS_OBJECT(object)); +void LivePathEffectObject::build(SPDocument *document, Inkscape::XML::Node *repr) { + g_assert(this != NULL); + g_assert(SP_IS_OBJECT(this)); - if (((SPObjectClass *) livepatheffect_parent_class)->build) - (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); + SPObject::build(document, repr); - object->readAttr( "effect" ); + this->readAttr( "effect" ); if (repr) { - repr->addListener (&livepatheffect_repr_events, object); + repr->addListener (&livepatheffect_repr_events, this); } /* Register ourselves, is this necessary? */ @@ -116,17 +75,8 @@ LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *documen /** * Virtual release of livepatheffect members before destruction. */ -void -LivePathEffectObject::livepatheffect_release(SPObject *object) -{ -#ifdef LIVEPATHEFFECT_VERBOSE - g_print("Releasing livepatheffect"); -#endif - - LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); - - object->getRepr()->removeListenerByData(object); - +void LivePathEffectObject::release() { + this->getRepr()->removeListenerByData(this); /* if (object->document) { @@ -142,77 +92,64 @@ LivePathEffectObject::livepatheffect_release(SPObject *object) } gradient->modified_connection.~connection(); - */ - if (lpeobj->lpe) { - delete lpeobj->lpe; - lpeobj->lpe = NULL; + if (this->lpe) { + delete this->lpe; + this->lpe = NULL; } - lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; - if (((SPObjectClass *) livepatheffect_parent_class)->release) - ((SPObjectClass *) livepatheffect_parent_class)->release(object); + this->effecttype = Inkscape::LivePathEffect::INVALID_LPE; + + SPObject::release(); } /** * Virtual set: set attribute to value. */ -void -LivePathEffectObject::livepatheffect_set(SPObject *object, unsigned key, gchar const *value) -{ - LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); +void LivePathEffectObject::set(unsigned key, gchar const *value) { #ifdef LIVEPATHEFFECT_VERBOSE g_print("Set livepatheffect"); #endif + switch (key) { case SP_PROP_PATH_EFFECT: - if (lpeobj->lpe) { - delete lpeobj->lpe; - lpeobj->lpe = NULL; + if (this->lpe) { + delete this->lpe; + this->lpe = NULL; } if ( value && Inkscape::LivePathEffect::LPETypeConverter.is_valid_key(value) ) { - lpeobj->effecttype = Inkscape::LivePathEffect::LPETypeConverter.get_id_from_key(value); - lpeobj->lpe = Inkscape::LivePathEffect::Effect::New(lpeobj->effecttype, lpeobj); - lpeobj->effecttype_set = true; + this->effecttype = Inkscape::LivePathEffect::LPETypeConverter.get_id_from_key(value); + this->lpe = Inkscape::LivePathEffect::Effect::New(this->effecttype, this); + this->effecttype_set = true; } else { - lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; - lpeobj->effecttype_set = false; + this->effecttype = Inkscape::LivePathEffect::INVALID_LPE; + this->effecttype_set = false; } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } - if (((SPObjectClass *) livepatheffect_parent_class)->set) { - ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value); - } + SPObject::set(key, value); } /** * Virtual write: write object attributes to repr. */ -Inkscape::XML::Node * -LivePathEffectObject::livepatheffect_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -{ -#ifdef LIVEPATHEFFECT_VERBOSE - g_print("Write livepatheffect"); -#endif - - LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); - +Inkscape::XML::Node* LivePathEffectObject::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("inkscape:path-effect"); } - if ((flags & SP_OBJECT_WRITE_ALL) || lpeobj->lpe) { - repr->setAttribute("effect", Inkscape::LivePathEffect::LPETypeConverter.get_key(lpeobj->effecttype).c_str()); + if ((flags & SP_OBJECT_WRITE_ALL) || this->lpe) { + repr->setAttribute("effect", Inkscape::LivePathEffect::LPETypeConverter.get_key(this->effecttype).c_str()); - lpeobj->lpe->writeParamsToSVG(); + this->lpe->writeParamsToSVG(); } - if (((SPObjectClass *) livepatheffect_parent_class)->write) - (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags); + SPObject::write(xml_doc, repr, flags); return repr; } @@ -244,7 +181,7 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/, /** * If this has other users, create a new private duplicate and return it * returns 'this' when no forking was necessary (and therefore no duplicate was made) - * Check out sp_lpe_item_fork_path_effects_if_necessary ! + * Check out SPLPEItem::forkPathEffectsIfNecessary ! */ LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned int nr_of_allowed_users) { diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h index 3ea1ea9ad..9700024fe 100644 --- a/src/live_effects/lpeobject.h +++ b/src/live_effects/lpeobject.h @@ -15,24 +15,21 @@ namespace Inkscape { namespace XML { class Node; - class Document; + struct Document; } namespace LivePathEffect { class Effect; } } -#define TYPE_LIVEPATHEFFECT (LivePathEffectObject::livepatheffect_get_type()) -#define LIVEPATHEFFECT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), TYPE_LIVEPATHEFFECT, LivePathEffectObject)) -#define IS_LIVEPATHEFFECT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), TYPE_LIVEPATHEFFECT)) - -/// The LivePathEffect vtable. -struct LivePathEffectObjectClass { - SPObjectClass parent_class; -}; +#define LIVEPATHEFFECT(obj) ((LivePathEffectObject*)obj) +#define IS_LIVEPATHEFFECT(obj) (dynamic_cast<const LivePathEffectObject*>((SPObject*)obj)) class LivePathEffectObject : public SPObject { public: + LivePathEffectObject(); + virtual ~LivePathEffectObject(); + Inkscape::LivePathEffect::EffectType effecttype; bool effecttype_set; @@ -42,22 +39,18 @@ public: /* Note that the returned pointer can be NULL in a valid LivePathEffectObject contained in a valid list of lpeobjects in an lpeitem! * So one should always check whether the returned value is NULL or not */ Inkscape::LivePathEffect::Effect * get_lpe() { return lpe; }; + Inkscape::LivePathEffect::Effect const * get_lpe() const { return lpe; }; -private: Inkscape::LivePathEffect::Effect *lpe; // this can be NULL in a valid LivePathEffectObject - /* C-style class functions: */ -public: - static GType livepatheffect_get_type(); -private: - static void livepatheffect_class_init(LivePathEffectObjectClass *klass); - static void livepatheffect_init(LivePathEffectObject *stop); - static void livepatheffect_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); - static void livepatheffect_release(SPObject *object); - static void livepatheffect_set(SPObject *object, unsigned key, gchar const *value); - static Inkscape::XML::Node *livepatheffect_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -}; +protected: + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void release(); + + virtual void set(unsigned int key, const gchar* value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); +}; #endif diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index d1c30edf7..1b8f742da 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ARRAY_CPP - /* * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl> * diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 6dbe2918f..c1e8f8a7b 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_BOOL_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * @@ -15,6 +13,7 @@ #include "inkscape.h" #include "verbs.h" #include "helper-fns.h" +#include <glibmm/i18n.h> namespace Inkscape { diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index d7aa299aa..fafb1beca 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -36,10 +36,9 @@ public: void param_setValue(bool newvalue); virtual void param_set_default(); - bool get_value() { return value; }; + bool get_value() const { return value; }; - inline operator bool() - { return value; }; + inline operator bool() const { return value; }; private: BoolParam(const BoolParam&); diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 2a1b07b47..2340663c3 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -68,8 +68,9 @@ public: return value; } - inline operator E() - { return value; }; + inline operator E() const { + return value; + }; void param_set_default() { param_set_value(defvalue); diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 71ab006d6..6c4f2a100 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -4,6 +4,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H +#include <glibmm/threads.h> +#endif + #include <gtkmm/box.h> #include "live_effects/parameter/originalpath.h" @@ -21,6 +29,7 @@ #include "inkscape.h" #include "desktop-handles.h" #include "selection.h" +#include "ui/icon-names.h" namespace Inkscape { @@ -51,7 +60,7 @@ OriginalPathParam::param_newWidget() } { // Paste path to link button - Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button *pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); diff --git a/src/live_effects/parameter/originalpath.h b/src/live_effects/parameter/originalpath.h index 7dd17edb0..b3feec41f 100644 --- a/src/live_effects/parameter/originalpath.h +++ b/src/live_effects/parameter/originalpath.h @@ -31,7 +31,7 @@ public: /** Disable the canvas indicators of parent class by overriding this method */ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ - virtual void addCanvasIndicators(SPLPEItem * /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {}; + virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {}; protected: virtual void linked_modified_callback(SPObject *linked_obj, guint flags); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index f0a090b24..a5de2169e 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -1,16 +1,16 @@ -#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 "ui/widget/registered-widget.h" +#include <glibmm/i18n.h> + #include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" #include "svg/svg.h" #include "xml/repr.h" -#include "ui/widget/registered-widget.h" #include "svg/stringstream.h" @@ -51,8 +51,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, gdouble default_value) : Parameter(label, tip, key, wr, effect), value(default_value), - min(-Geom::infinity()), - max(Geom::infinity()), + min(-G_MAXDOUBLE), + max(G_MAXDOUBLE), integer(false), defvalue(default_value), digits(2), diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 4785d5455..785ada92e 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -59,9 +59,9 @@ public: virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; }; // overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths - virtual bool providesKnotHolderEntities() { return false; } + virtual bool providesKnotHolderEntities() const { return false; } virtual void addKnotHolderEntities(KnotHolder */*knotholder*/, SPDesktop */*desktop*/, SPItem */*item*/) {}; - virtual void addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) {}; + virtual void addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) {}; virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {}; @@ -112,8 +112,7 @@ public: virtual Gtk::Widget * param_newWidget(); - inline operator gdouble() - { return value; }; + inline operator gdouble() const { return value; }; protected: gdouble value; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 69c337a7c..cdbbef1db 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -5,6 +5,9 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "ui/widget/point.h" +#include <glibmm/i18n.h> + #include "live_effects/parameter/path.h" #include "live_effects/effect.h" #include "svg/svg.h" @@ -13,7 +16,6 @@ #include <2geom/pathvector.h> #include <2geom/d2.h> -#include "ui/widget/point.h" #include "widgets/icon.h" #include <gtk/gtk.h> #include "selection-chemistry.h" @@ -38,12 +40,13 @@ #include "sp-text.h" #include "display/curve.h" -#include "ui/tool/node-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/shape-record.h" #include <gtkmm/button.h> #include <gtkmm/label.h> +#include "ui/icon-names.h" namespace Inkscape { @@ -75,7 +78,7 @@ PathParam::~PathParam() } std::vector<Geom::Path> const & -PathParam::get_pathvector() +PathParam::get_pathvector() const { return _pathvector; } @@ -151,7 +154,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "tool-node-editor", Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -161,7 +164,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Edit on-canvas")); - pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_COPY, Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -171,7 +174,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Copy path")); - pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -181,7 +184,7 @@ PathParam::param_newWidget() static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); pButton->set_tooltip_text(_("Paste path")); - pIcon = Gtk::manage( sp_icon_get_icon( "edit-clone", Inkscape::ICON_SIZE_BUTTON) ); + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); pButton->set_relief(Gtk::RELIEF_NONE); pIcon->show(); @@ -206,7 +209,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) tools_switch(dt, TOOLS_NODES); } - InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context); + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(dt->event_context); std::set<ShapeRecord> shapes; ShapeRecord r; @@ -229,7 +232,7 @@ PathParam::param_setup_nodepath(Inkscape::NodePath::Path *) } void -PathParam::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +PathParam::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { hp_vec.push_back(_pathvector); } diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index a4f46f11f..112a1ea13 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -31,7 +31,7 @@ public: const gchar * default_value = "M0,0 L1,1"); virtual ~PathParam(); - std::vector<Geom::Path> const & get_pathvector(); + std::vector<Geom::Path> const & get_pathvector() const; Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2(); virtual Gtk::Widget * param_newWidget(); @@ -46,7 +46,7 @@ public: virtual void param_editOncanvas(SPItem * item, SPDesktop * dt); virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index c192cd6d6..302818e55 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * @@ -16,6 +14,7 @@ #include "inkscape.h" #include "verbs.h" #include "knotholder.h" +#include <glibmm/i18n.h> // needed for on-canvas editting: #include "desktop.h" @@ -133,7 +132,7 @@ public: virtual ~PointParamKnotHolderEntity() {} virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; virtual void knot_click(guint state); private: @@ -141,15 +140,15 @@ private: }; void -PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); pparam->param_setValue(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } Geom::Point -PointParamKnotHolderEntity::knot_get() +PointParamKnotHolderEntity::knot_get() const { return *pparam; } diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index f2397753e..319835bb3 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -47,7 +47,7 @@ public: void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); - virtual bool providesKnotHolderEntities() { return true; } + virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 07cc71245..fecdfeda8 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -1,11 +1,11 @@ -#define INKSCAPE_LIVEPATHEFFECT_POWERSTROKE_POINT_ARRAY_CPP - /* * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <glibmm/i18n.h> + #include "live_effects/parameter/powerstrokepointarray.h" #include "live_effects/effect.h" @@ -124,11 +124,11 @@ public: virtual ~PowerStrokePointArrayParamKnotHolderEntity() {} virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get(); + virtual Geom::Point knot_get() const; virtual void knot_click(guint state); /** Checks whether the index falls within the size of the parameter's vector */ - bool valid_index(unsigned int index) { + bool valid_index(unsigned int index) const { return (_pparam->_vector.size() > index); }; @@ -144,7 +144,7 @@ PowerStrokePointArrayParamKnotHolderEntity::PowerStrokePointArrayParamKnotHolder } void -PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) +PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { using namespace Geom; @@ -156,7 +156,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom: Piecewise<D2<SBasis> > const & pwd2 = _pparam->get_pwd2(); Piecewise<D2<SBasis> > const & n = _pparam->get_pwd2_normal(); - Geom::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p, state); double t = nearest_point(s, pwd2); double offset = dot(s - pwd2.valueAt(t), n.valueAt(t)); _pparam->_vector.at(_index) = Geom::Point(t, offset); @@ -164,7 +164,7 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom: } Geom::Point -PowerStrokePointArrayParamKnotHolderEntity::knot_get() +PowerStrokePointArrayParamKnotHolderEntity::knot_get() const { using namespace Geom; diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 0e08d78fe..e1fa440f2 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -37,12 +37,12 @@ public: void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); - virtual bool providesKnotHolderEntities() { return true; } + 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() { return last_pwd2; } - Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2_normal() { return last_pwd2_normal; } + 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; } void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 10f76b6ba..075e85ee1 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -1,15 +1,14 @@ -#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 "ui/widget/registered-widget.h" #include "live_effects/parameter/random.h" #include "live_effects/effect.h" +#include <glibmm/i18n.h> #include "svg/svg.h" -#include "ui/widget/registered-widget.h" #include "ui/widget/random.h" #include "svg/stringstream.h" diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index b72f6f976..ca4440336 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -42,8 +42,7 @@ public: void resetRandomizer(); operator gdouble(); - inline gdouble get_value() - { return value; } ; + inline gdouble get_value() { return value; } ; protected: long startseed; diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 13440798b..fcb2fc9fc 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_CPP - /* * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com> * @@ -11,6 +9,8 @@ */ #include "ui/widget/registered-widget.h" +#include <glibmm/i18n.h> + #include "live_effects/parameter/text.h" #include "live_effects/effect.h" #include "svg/svg.h" diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 85833885e..62de70eec 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -46,7 +46,7 @@ public: const double t, const double length, bool use_curvature = false); void setAnchor(double x_value, double y_value); - const Glib::ustring get_value() { return defvalue; }; + const Glib::ustring get_value() const { return defvalue; }; private: TextParam(const TextParam&); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 2f2d71679..0ee553e2c 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -1,15 +1,18 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_UNIT_CPP - /* * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com> * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "ui/widget/registered-widget.h" +#include <glibmm/i18n.h> + #include "live_effects/parameter/unit.h" #include "live_effects/effect.h" -#include "ui/widget/registered-widget.h" #include "verbs.h" +#include "util/units.h" + +using Inkscape::Util::unit_table; namespace Inkscape { @@ -18,10 +21,10 @@ namespace LivePathEffect { UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, SPUnitId default_value) + Effect* effect, Glib::ustring default_unit) : Parameter(label, tip, key, wr, effect) { - defunit = &sp_unit_get_by_id(default_value);; + defunit = unit_table.getUnit(default_unit); unit = defunit; } @@ -32,9 +35,8 @@ UnitParam::~UnitParam() bool UnitParam::param_readSVGValue(const gchar * strvalue) { - SPUnit const *newval = sp_unit_get_by_abbreviation(strvalue); - if (newval) { - param_set_value(newval); + if (strvalue) { + param_set_value(*unit_table.getUnit(strvalue)); return true; } return false; @@ -43,25 +45,25 @@ UnitParam::param_readSVGValue(const gchar * strvalue) gchar * UnitParam::param_getSVGValue() const { - return g_strdup(sp_unit_get_abbreviation(unit)); + return g_strdup(unit->abbr.c_str()); } void UnitParam::param_set_default() { - param_set_value(defunit); + param_set_value(*defunit); } void -UnitParam::param_set_value(SPUnit const *val) +UnitParam::param_set_value(Inkscape::Util::Unit const &val) { - unit = val; + unit = new Inkscape::Util::Unit(val); } const gchar * -UnitParam::get_abbreviation() +UnitParam::get_abbreviation() const { - return sp_unit_get_abbreviation(unit); + return unit->abbr.c_str(); } Gtk::Widget * @@ -74,7 +76,7 @@ UnitParam::param_newWidget() param_effect->getRepr(), param_effect->getSPDoc())); - unit_menu->setUnit(unit); + unit_menu->setUnit(unit->abbr); unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); return dynamic_cast<Gtk::Widget *> (unit_menu); diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index 3d417fcd6..59a483018 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -10,10 +10,13 @@ */ #include "live_effects/parameter/parameter.h" -#include <helper/units.h> namespace Inkscape { +namespace Util { + class Unit; +} + namespace LivePathEffect { class UnitParam : public Parameter { @@ -23,22 +26,22 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - SPUnitId default_value = SP_UNIT_PX); + Glib::ustring default_unit = "px"); virtual ~UnitParam(); virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - void param_set_value(SPUnit const *val); - const gchar *get_abbreviation(); + void param_set_value(Inkscape::Util::Unit const &val); + const gchar *get_abbreviation() const; virtual Gtk::Widget * param_newWidget(); - operator SPUnit const *() { return unit; } + operator Inkscape::Util::Unit const *() const { return unit; } private: - SPUnit const *unit; - SPUnit const *defunit; + Inkscape::Util::Unit const *unit; + Inkscape::Util::Unit const *defunit; UnitParam(const UnitParam&); UnitParam& operator=(const UnitParam&); diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 3348670dd..cfaa9e7e7 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -1,5 +1,3 @@ -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_VECTOR_CPP - /* * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl> * @@ -7,6 +5,8 @@ */ #include "ui/widget/registered-widget.h" +#include <glibmm/i18n.h> + #include "live_effects/parameter/vector.h" #include "sp-lpe-item.h" #include "knotholder.h" @@ -149,12 +149,12 @@ public: VectorParamKnotHolderEntity_Origin(VectorParam *p) : param(p) { } virtual ~VectorParamKnotHolderEntity_Origin() {} - virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) { - Geom::Point const s = snap_knot_position(p); + virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + Geom::Point const s = snap_knot_position(p, state); param->setOrigin(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); }; - virtual Geom::Point knot_get(){ + virtual Geom::Point knot_get() const { return param->origin; }; virtual void knot_click(guint /*state*/){ @@ -176,7 +176,7 @@ public: param->setVector(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); }; - virtual Geom::Point knot_get(){ + virtual Geom::Point knot_get() const { return param->origin + param->vector; }; virtual void knot_click(guint /*state*/){ diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index f82affe16..35ca04437 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -52,7 +52,7 @@ public: void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - virtual bool providesKnotHolderEntities() { return true; } + virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); private: diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp index e4b72793c..46e53a0da 100644 --- a/src/live_effects/spiro.cpp +++ b/src/live_effects/spiro.cpp @@ -83,7 +83,7 @@ int n = 4; #endif /* Integrate polynomial spiral curve over range -.5 .. .5. */ -void +static void integrate_spiro(const double ks[4], double xy[2]) { #if 0 @@ -631,7 +631,7 @@ banbks11(const bandmat *m, const int *perm, double *v, int n) } } -int compute_jinc(char ty0, char ty1) +static int compute_jinc(char ty0, char ty1) { if (ty0 == 'o' || ty1 == 'o' || ty0 == ']' || ty1 == '[') @@ -645,7 +645,7 @@ int compute_jinc(char ty0, char ty1) return 0; } -int count_vec(const spiro_seg *s, int nseg) +static int count_vec(const spiro_seg *s, int nseg) { int i; int n = 0; @@ -677,163 +677,165 @@ add_mat_line(bandmat *m, double *v, } static double -spiro_iter(spiro_seg *s, bandmat *m, int *perm, double *v, int n) +spiro_iter(spiro_seg *s, bandmat *m, int *perm, double *v, const int n) { int cyclic = s[0].ty != '{' && s[0].ty != 'v'; - int i, j, jj; int nmat = count_vec(s, n); - double norm; int n_invert; - for (i = 0; i < nmat; i++) { - v[i] = 0.; - for (j = 0; j < 11; j++) - m[i].a[j] = 0.; - for (j = 0; j < 5; j++) - m[i].al[j] = 0.; + for (int i = 0; i < nmat; i++) { + v[i] = 0.; + for (int j = 0; j < 11; j++) { + m[i].a[j] = 0.; + } + for (int j = 0; j < 5; j++) { + m[i].al[j] = 0.; + } } - j = 0; - if (s[0].ty == 'o') - jj = nmat - 2; - else if (s[0].ty == 'c') - jj = nmat - 1; - else - jj = 0; - for (i = 0; i < n; i++) { - char ty0 = s[i].ty; - char ty1 = s[i + 1].ty; - int jinc = compute_jinc(ty0, ty1); - double th = s[i].bend_th; - double ends[2][4]; - double derivs[4][2][4]; - int jthl = -1, jk0l = -1, jk1l = -1, jk2l = -1; - int jthr = -1, jk0r = -1, jk1r = -1, jk2r = -1; - - compute_pderivs(&s[i], ends, derivs, jinc); - - /* constraints crossing left */ - if (ty0 == 'o' || ty0 == 'c' || ty0 == '[' || ty0 == ']') { - jthl = jj++; - jj %= nmat; - jk0l = jj++; - } - if (ty0 == 'o') { - jj %= nmat; - jk1l = jj++; - jk2l = jj++; - } + int j = 0; + int jj; + if (s[0].ty == 'o') { + jj = nmat - 2; + } else if (s[0].ty == 'c') { + jj = nmat - 1; + } else { + jj = 0; + } + for (int i = 0; i < n; i++) { + char ty0 = s[i].ty; + char ty1 = s[i + 1].ty; + int jinc = compute_jinc(ty0, ty1); + double th = s[i].bend_th; + double ends[2][4]; + double derivs[4][2][4]; + int jthl = -1, jk0l = -1, jk1l = -1, jk2l = -1; + int jthr = -1, jk0r = -1, jk1r = -1, jk2r = -1; + + compute_pderivs(&s[i], ends, derivs, jinc); + + /* constraints crossing left */ + if (ty0 == 'o' || ty0 == 'c' || ty0 == '[' || ty0 == ']') { + jthl = jj++; + jj %= nmat; + jk0l = jj++; + } + if (ty0 == 'o') { + jj %= nmat; + jk1l = jj++; + jk2l = jj++; + } - /* constraints on left */ - if ((ty0 == '[' || ty0 == 'v' || ty0 == '{' || ty0 == 'c') && - jinc == 4) { - if (ty0 != 'c') - jk1l = jj++; - jk2l = jj++; - } + /* constraints on left */ + if ((ty0 == '[' || ty0 == 'v' || ty0 == '{' || ty0 == 'c') && + jinc == 4) { + if (ty0 != 'c') + jk1l = jj++; + jk2l = jj++; + } - /* constraints on right */ - if ((ty1 == ']' || ty1 == 'v' || ty1 == '}' || ty1 == 'c') && - jinc == 4) { - if (ty1 != 'c') - jk1r = jj++; - jk2r = jj++; - } + /* constraints on right */ + if ((ty1 == ']' || ty1 == 'v' || ty1 == '}' || ty1 == 'c') && + jinc == 4) { + if (ty1 != 'c') + jk1r = jj++; + jk2r = jj++; + } - /* constraints crossing right */ - if (ty1 == 'o' || ty1 == 'c' || ty1 == '[' || ty1 == ']') { - jthr = jj; - jk0r = (jj + 1) % nmat; - } - if (ty1 == 'o') { - jk1r = (jj + 2) % nmat; - jk2r = (jj + 3) % nmat; - } + /* constraints crossing right */ + if (ty1 == 'o' || ty1 == 'c' || ty1 == '[' || ty1 == ']') { + jthr = jj; + jk0r = (jj + 1) % nmat; + } + if (ty1 == 'o') { + jk1r = (jj + 2) % nmat; + jk2r = (jj + 3) % nmat; + } - add_mat_line(m, v, derivs[0][0], th - ends[0][0], 1, j, jthl, jinc, nmat); - add_mat_line(m, v, derivs[1][0], ends[0][1], -1, j, jk0l, jinc, nmat); - add_mat_line(m, v, derivs[2][0], ends[0][2], -1, j, jk1l, jinc, nmat); - add_mat_line(m, v, derivs[3][0], ends[0][3], -1, j, jk2l, jinc, nmat); - add_mat_line(m, v, derivs[0][1], -ends[1][0], 1, j, jthr, jinc, nmat); - add_mat_line(m, v, derivs[1][1], -ends[1][1], 1, j, jk0r, jinc, nmat); - add_mat_line(m, v, derivs[2][1], -ends[1][2], 1, j, jk1r, jinc, nmat); - add_mat_line(m, v, derivs[3][1], -ends[1][3], 1, j, jk2r, jinc, nmat); - if (jthl >= 0) - v[jthl] = mod_2pi(v[jthl]); - if (jthr >= 0) - v[jthr] = mod_2pi(v[jthr]); - j += jinc; + add_mat_line(m, v, derivs[0][0], th - ends[0][0], 1, j, jthl, jinc, nmat); + add_mat_line(m, v, derivs[1][0], ends[0][1], -1, j, jk0l, jinc, nmat); + add_mat_line(m, v, derivs[2][0], ends[0][2], -1, j, jk1l, jinc, nmat); + add_mat_line(m, v, derivs[3][0], ends[0][3], -1, j, jk2l, jinc, nmat); + add_mat_line(m, v, derivs[0][1], -ends[1][0], 1, j, jthr, jinc, nmat); + add_mat_line(m, v, derivs[1][1], -ends[1][1], 1, j, jk0r, jinc, nmat); + add_mat_line(m, v, derivs[2][1], -ends[1][2], 1, j, jk1r, jinc, nmat); + add_mat_line(m, v, derivs[3][1], -ends[1][3], 1, j, jk2r, jinc, nmat); + if (jthl >= 0) + v[jthl] = mod_2pi(v[jthl]); + if (jthr >= 0) + v[jthr] = mod_2pi(v[jthr]); + j += jinc; } if (cyclic) { - memcpy(m + nmat, m, sizeof(bandmat) * nmat); - memcpy(m + 2 * nmat, m, sizeof(bandmat) * nmat); - memcpy(v + nmat, v, sizeof(double) * nmat); - memcpy(v + 2 * nmat, v, sizeof(double) * nmat); - n_invert = 3 * nmat; - j = nmat; + memcpy(m + nmat, m, sizeof(bandmat) * nmat); + memcpy(m + 2 * nmat, m, sizeof(bandmat) * nmat); + memcpy(v + nmat, v, sizeof(double) * nmat); + memcpy(v + 2 * nmat, v, sizeof(double) * nmat); + n_invert = 3 * nmat; + j = nmat; } else { - n_invert = nmat; - j = 0; + n_invert = nmat; + j = 0; } #ifdef VERBOSE - for (i = 0; i < n; i++) { - int k; - for (k = 0; k < 11; k++) - printf(" %2.4f", m[i].a[k]); - printf(": %2.4f\n", v[i]); + for (int i = 0; i < n; i++) { + for (int k = 0; k < 11; k++) { + printf(" %2.4f", m[i].a[k]); + } + printf(": %2.4f\n", v[i]); } printf("---\n"); #endif bandec11(m, perm, n_invert); banbks11(m, perm, v, n_invert); - norm = 0.; - for (i = 0; i < n; i++) { - char ty0 = s[i].ty; - char ty1 = s[i + 1].ty; - int jinc = compute_jinc(ty0, ty1); - int k; + + double norm = 0.; + for (int i = 0; i < n; i++) { + char ty0 = s[i].ty; + char ty1 = s[i + 1].ty; + int jinc = compute_jinc(ty0, ty1); + int k; - for (k = 0; k < jinc; k++) { - double dk = v[j++]; + for (k = 0; k < jinc; k++) { + double dk = v[j++]; #ifdef VERBOSE - printf("s[%d].ks[%d] += %f\n", i, k, dk); + printf("s[%d].ks[%d] += %f\n", i, k, dk); #endif - s[i].ks[k] += dk; - norm += dk * dk; - } + s[i].ks[k] += dk; + norm += dk * dk; + } s[i].ks[0] = 2.0*mod_2pi(s[i].ks[0]/2.0); } return norm; } -int -solve_spiro(spiro_seg *s, int nseg) +static int +solve_spiro(spiro_seg *s, const int nseg) { - bandmat *m; - double *v; - int *perm; int nmat = count_vec(s, nseg); int n_alloc = nmat; - double norm; - int i; - if (nmat == 0) - return 0; - if (s[0].ty != '{' && s[0].ty != 'v') - n_alloc *= 3; - if (n_alloc < 5) - n_alloc = 5; - m = (bandmat *)malloc(sizeof(bandmat) * n_alloc); - v = (double *)malloc(sizeof(double) * n_alloc); - perm = (int *)malloc(sizeof(int) * n_alloc); - - for (i = 0; i < 10; i++) { - norm = spiro_iter(s, m, perm, v, nseg); + if (nmat == 0) { + return 0; + } + if (s[0].ty != '{' && s[0].ty != 'v') { + n_alloc *= 3; + } + if (n_alloc < 5) { + n_alloc = 5; + } + + bandmat *m = (bandmat *)malloc(sizeof(bandmat) * n_alloc); + double *v = (double *)malloc(sizeof(double) * n_alloc); + int *perm = (int *)malloc(sizeof(int) * n_alloc); + + for (unsigned i = 0; i < 10; i++) { + double norm = spiro_iter(s, m, perm, v, nseg); #ifdef VERBOSE - printf("%% norm = %g\n", norm); + printf("%% norm = %g\n", norm); #endif - if (norm < 1e-12) break; + if (norm < 1e-12) break; } free(m); @@ -850,7 +852,7 @@ spiro_seg_to_otherpath(const double ks[4], double bend = fabs(ks[0]) + fabs(.5 * ks[1]) + fabs(.125 * ks[2]) + fabs((1./48) * ks[3]); - if (!bend > 1e-8) { + if (!(bend > 1e-8)) { bc.lineto(x1, y1); } else { double seg_ch = hypot(x1 - x0, y1 - y0); |
