summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2017-01-24 00:37:00 +0000
committerJabiertxof <jtx@jtx>2017-01-24 00:37:00 +0000
commitba053c48cdcd8b4995f188d80887d46c41f97b3d (patch)
tree7095f1fb83aa1bf9ee14d633f73a35374136d88b /src
parentUpdate to trunk (diff)
downloadinkscape-ba053c48cdcd8b4995f188d80887d46c41f97b3d.tar.gz
inkscape-ba053c48cdcd8b4995f188d80887d46c41f97b3d.zip
Remove some code and make dependant of rotate copies
(bzr r15356.1.17)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp39
-rw-r--r--src/live_effects/effect.h8
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp1
-rw-r--r--src/sp-ellipse.cpp13
-rw-r--r--src/sp-item-group.cpp37
-rw-r--r--src/sp-lpe-item.cpp21
-rw-r--r--src/sp-lpe-item.h3
-rw-r--r--src/sp-object.cpp15
-rw-r--r--src/sp-object.h3
-rw-r--r--src/ui/clipboard.cpp2
10 files changed, 41 insertions, 101 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 81a512d23..9d9381294 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -356,7 +356,7 @@ Effect::Effect(LivePathEffectObject *lpeobject)
sp_lpe_item(NULL),
current_zoom(1),
upd_params(true),
- sp_shape(NULL),
+ sp_curve(NULL),
provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
{
@@ -392,9 +392,9 @@ Effect::doOnApply (SPLPEItem const*/*lpeitem*/)
}
void
-Effect::setSelectedNodePoints(std::vector<Geom::Point> selected_np)
+Effect::setSelectedNodePoints(std::vector<Geom::Point> sNP)
{
- selected_nodes_points = selected_np;
+ selectedNodesPoints = sNP;
}
void
@@ -404,16 +404,16 @@ Effect::setCurrentZoom(double cZ)
}
bool
-Effect::isNodePointSelected(Geom::Point const &node_point) const
+Effect::isNodePointSelected(Geom::Point const &nodePoint) const
{
- if (selected_nodes_points.size() > 0) {
+ if (selectedNodesPoints.size() > 0) {
using Geom::X;
using Geom::Y;
- for (std::vector<Geom::Point>::const_iterator i = selected_nodes_points.begin();
- i != selected_nodes_points.end(); ++i) {
+ for (std::vector<Geom::Point>::const_iterator i = selectedNodesPoints.begin();
+ i != selectedNodesPoints.end(); ++i) {
Geom::Point p = *i;
Geom::Affine transformCoordinate = sp_lpe_item->i2dt_affine();
- Geom::Point p2(node_point[X], node_point[Y]);
+ Geom::Point p2(nodePoint[X],nodePoint[Y]);
p2 *= transformCoordinate;
if (Geom::are_near(p, p2, 0.01)) {
return true;
@@ -446,24 +446,21 @@ void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
{
sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
- SPShape * shape = dynamic_cast<SPShape *>(sp_lpe_item);
- if(shape){
- setCurrentShape(shape);
- }
+ /*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
+ pathvector_before_effect = sp_curve->get_pathvector();*/
doOnApply(lpeitem);
}
void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
{
sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
- //Groups set shape in performPathEffect before each call to doEffect
+ //printf("(SPLPEITEM*) %p\n", sp_lpe_item);
SPShape * shape = dynamic_cast<SPShape *>(sp_lpe_item);
if(shape){
- setCurrentShape(shape);
+ sp_curve = shape->getCurve();
+ pathvector_before_effect = sp_curve->get_pathvector();
}
- //printf("(SPLPEITEM*) %p\n", sp_lpe_item);
doBeforeEffect(lpeitem);
-
if (apply_to_clippath_and_mask && SP_IS_GROUP(sp_lpe_item)) {
sp_lpe_item->apply_to_clippath(sp_lpe_item);
sp_lpe_item->apply_to_mask(sp_lpe_item);
@@ -471,16 +468,6 @@ void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
update_helperpath();
}
-void Effect::setCurrentShape(SPShape * shape){
- if(shape){
- sp_shape = shape;
- if (!(sp_curve = sp_shape->getCurve())) {
- // oops
- return;
- }
- pathvector_before_effect = sp_curve->get_pathvector();
- }
-}
/**
* Effects can have a parameter path set before they are applied by accepting a nonzero number of
* mouse clicks. This method activates the pen context, which waits for the specified number of
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 5dfa3de29..1997ff0ca 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -73,8 +73,7 @@ public:
static int acceptsNumClicks(EffectType type);
int acceptsNumClicks() const { return acceptsNumClicks(effectType()); }
void doAcceptPathPreparations(SPLPEItem *lpeitem);
- SPShape * getCurrentShape(){ return sp_shape; };
- void setCurrentShape(SPShape * shape);
+
/*
* 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
@@ -164,10 +163,9 @@ protected:
// instead of normally 'splitting' the path into continuous pwd2 paths and calling doEffect_pwd2 for each.
bool concatenate_before_pwd2;
- SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them.z
- SPShape * sp_shape; // these get stored in doBeforeEffect_impl before doEffect chain, or in performPathEffects on groups, and derived classes may do as they please with them.
+ SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them.
double current_zoom;
- std::vector<Geom::Point> selected_nodes_points;
+ std::vector<Geom::Point> selectedNodesPoints;
SPCurve * sp_curve;
Geom::PathVector pathvector_before_effect;
private:
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 250f6aa29..813f25d3d 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -125,6 +125,7 @@ void
LPECopyRotate::transform_multiply(Geom::Affine const& postmul, bool set)
{
// cycle through all parameters. Most parameters will not need transformation, but path and point params do.
+
for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) {
Parameter * param = *it;
param->param_transform_multiply(postmul, set);
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index 9589d6fce..ed1e2b504 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -445,20 +445,11 @@ void SPGenericEllipse::set_shape()
if (hasPathEffect() && pathEffectsEnabled()) {
SPCurve *c_lpe = curve->copy();
bool success = this->performPathEffect(c_lpe);
-
+
if (success) {
this->setCurveInsync(c_lpe, TRUE);
- } else {
- Inkscape::XML::Node *repr = this->getRepr();
- if (gchar const * value = repr->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new (std::nothrow) SPCurve(pv);
- if (oldcurve) {
- this->setCurveInsync(oldcurve, TRUE);
- oldcurve->unref();
- }
- }
}
+
c_lpe->unref();
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 808d475c7..7b2507b5e 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -950,36 +950,25 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
} else {
c = subShape->getCurve();
}
- bool success = false;
+
// only run LPEs when the shape has a curve defined
if (c) {
c->transform(i2anc_affine(subitem, topgroup));
- success = topgroup->performPathEffect(c, subShape);
+ topgroup->performPathEffect(c);
c->transform(i2anc_affine(subitem, topgroup).inverse());
- if (c && success) {
- subShape->setCurve(c, TRUE);
- if (write) {
- Inkscape::XML::Node *repr = subitem->getRepr();
- gchar *str = sp_svg_write_path(c->get_pathvector());
- repr->setAttribute("d", str);
- #ifdef GROUP_VERBOSE
- g_message("sp_group_perform_patheffect writes 'd' attribute");
- #endif
- g_free(str);
- }
- c->unref();
- } else {
- // LPE was unsuccesfull or doeffect stack return null. Read the old 'd'-attribute.
+ subShape->setCurve(c, TRUE);
+
+ if (write) {
Inkscape::XML::Node *repr = subitem->getRepr();
- if (gchar const * value = repr->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new (std::nothrow) SPCurve(pv);
- if (oldcurve) {
- subShape->setCurve(oldcurve, TRUE);
- oldcurve->unref();
- }
- }
+ gchar *str = sp_svg_write_path(c->get_pathvector());
+ repr->setAttribute("d", str);
+#ifdef GROUP_VERBOSE
+ g_message("sp_group_perform_patheffect writes 'd' attribute");
+#endif
+ g_free(str);
}
+
+ c->unref();
}
}
}
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index 2dd7cec5a..e2f61bfb5 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -209,7 +209,7 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape
/**
* returns true when LPE was successful.
*/
-bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip_or_mask) {
+bool SPLPEItem::performPathEffect(SPCurve *curve, bool is_clip_or_mask) {
if (!curve) {
return false;
@@ -241,14 +241,12 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip
}
if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) {
// Groups have their doBeforeEffect called elsewhere
- if (current) {
- lpe->setCurrentShape(current);
- }
if (!SP_IS_GROUP(this)) {
lpe->doBeforeEffect_impl(this);
}
+
try {
- lpe->doEffect(curve);
+ lpe->doEffect(curve);
}
catch (std::exception & e) {
g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what());
@@ -697,10 +695,10 @@ SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item)
try {
if(SP_IS_GROUP(this)){
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)));
- success = this->performPathEffect(c, SP_SHAPE(clip_mask), true);
+ success = this->performPathEffect(c, true);
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
} else {
- success = this->performPathEffect(c, SP_SHAPE(clip_mask), true);
+ success = this->performPathEffect(c, true);
}
} catch (std::exception & e) {
g_warning("Exception during LPE execution. \n %s", e.what());
@@ -711,13 +709,12 @@ SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item)
success = false;
}
Inkscape::XML::Node *repr = clip_mask->getRepr();
- // This c check allow to not apply LPE if curve is NULL after performPathEffect used in clone.obgets LPE
- if (success && c) {
+ if (success) {
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
} else {
- // LPE was unsuccesfull or doeffect stack return null.. Read the old 'd'-attribute.
+ // LPE was unsuccesfull. Read the old 'd'-attribute.
if (gchar const * value = repr->attribute("d")) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new (std::nothrow) SPCurve(pv);
@@ -727,9 +724,7 @@ SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item)
}
}
}
- if (c) {
- c->unref();
- }
+ c->unref();
}
}
}
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index 9cf868cf2..9e5cb3329 100644
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
@@ -23,7 +23,6 @@
class LivePathEffectObject;
class SPCurve;
-class SPShape;
class SPDesktop;
namespace Inkscape{
@@ -70,7 +69,7 @@ public:
virtual void update_patheffect(bool write);
- bool performPathEffect(SPCurve *curve, SPShape *current = NULL, bool is_clip_or_mask = false);
+ bool performPathEffect(SPCurve *curve, bool is_clip_or_mask = false);
bool pathEffectsEnabled() const;
bool hasPathEffect() const;
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 0dc301c49..75f4657ef 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -775,21 +775,6 @@ void SPObject::appendChild(Inkscape::XML::Node *child) {
repr->appendChild(child);
}
-SPObject* SPObject::nthChild(unsigned index) {
- g_assert(this->repr);
- if (hasChildren()) {
- std::vector<SPObject*> l;
- unsigned counter = 0;
- for (auto& child: children) {
- if (counter == index) {
- return &child;
- }
- counter++;
- }
- }
- return NULL;
-}
-
void SPObject::addChild(Inkscape::XML::Node *child, Inkscape::XML::Node * prev)
{
g_assert(this->repr);
diff --git a/src/sp-object.h b/src/sp-object.h
index d145e966b..9abbd324b 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -318,9 +318,6 @@ public:
SPObject *lastChild() { return children.empty() ? nullptr : &children.back(); }
SPObject const *lastChild() const { return children.empty() ? nullptr : &children.back(); }
- SPObject *nthChild(unsigned index);
- SPObject const *nthChild(unsigned index) const;
-
enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
/**
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 2e866a9d1..c1e824c1e 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -410,8 +410,6 @@ const gchar *ClipboardManagerImpl::getFirstObjectID()
strcmp(ch->name(), "svg:use") &&
strcmp(ch->name(), "svg:text") &&
strcmp(ch->name(), "svg:image") &&
- strcmp(ch->name(), "svg:ellipse") &&
- strcmp(ch->name(), "svg:circle") &&
strcmp(ch->name(), "svg:rect")
) {
ch = ch->next();