summaryrefslogtreecommitdiffstats
path: root/src/live_effects/effect.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/live_effects/effect.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/live_effects/effect.cpp')
-rw-r--r--src/live_effects/effect.cpp57
1 files changed, 25 insertions, 32 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;
}