summaryrefslogtreecommitdiffstats
path: root/src/sp-item.cpp
diff options
context:
space:
mode:
authorMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
committerMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
commite7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch)
tree9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/sp-item.cpp
parentupdated to latest trunk (diff)
parent[Bug #1695016] Xaml export misses some radialGradients. (diff)
downloadinkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz
inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/sp-item.cpp')
-rw-r--r--src/sp-item.cpp145
1 files changed, 73 insertions, 72 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 9fd6e8ecc..368f8896c 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -13,10 +13,14 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "sp-item.h"
+
+#include <glibmm/i18n.h>
+
+#include "bad-uri-exception.h"
#include "svg/svg.h"
#include "print.h"
#include "display/drawing-item.h"
@@ -25,27 +29,19 @@
#include "uri.h"
#include "inkscape.h"
#include "desktop.h"
-
-
#include "style.h"
-#include <glibmm/i18n.h>
#include "sp-root.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-rect.h"
-#include "sp-use.h"
#include "sp-text.h"
#include "sp-textpath.h"
#include "sp-item-rm-unsatisfied-cns.h"
#include "sp-pattern.h"
-#include "sp-paint-server.h"
#include "sp-switch.h"
-#include "sp-guide-constraint.h"
#include "gradient-chemistry.h"
-#include "preferences.h"
#include "conn-avoid-ref.h"
#include "conditions.h"
-#include "sp-filter-reference.h"
#include "filter-chemistry.h"
#include "sp-guide.h"
#include "sp-title.h"
@@ -53,13 +49,8 @@
#include "util/find-last-if.h"
#include "util/reverse-list.h"
-#include <2geom/rect.h>
-#include <2geom/affine.h>
-#include <2geom/transforms.h>
-#include "xml/repr.h"
#include "extract-uri.h"
-#include "helper/geom.h"
#include "live_effects/lpeobject.h"
#include "live_effects/effect.h"
@@ -69,6 +60,7 @@
#define noSP_ITEM_DEBUG_IDLE
+//#define OBJECT_TRACE
static SPItemView* sp_item_view_list_remove(SPItemView *list,
SPItemView *view);
@@ -85,7 +77,6 @@ SPItem::SPItem() : SPObject() {
transform_center_y = 0;
freeze_stroke_width = false;
-
_is_evaluated = true;
_evaluated_status = StatusUnknown;
@@ -131,6 +122,7 @@ void SPItem::setLocked(bool locked) {
setAttribute("sodipodi:insensitive",
( locked ? "1" : NULL ));
updateRepr();
+ document->_emitModified();
}
bool SPItem::isHidden() const {
@@ -308,51 +300,46 @@ bool is_item(SPObject const &object) {
void SPItem::raiseToTop() {
using Inkscape::Algorithms::find_last_if;
- SPObject *topmost=find_last_if<SPObject::SiblingIterator>(
- next, NULL, &is_item
- );
- if (topmost) {
+ auto topmost = find_last_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item);
+ if (topmost != parent->children.end()) {
getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() );
}
}
-void SPItem::raiseOne() {
- SPObject *next_higher=std::find_if<SPObject::SiblingIterator>(
- next, NULL, &is_item
- );
- if (next_higher) {
+bool SPItem::raiseOne() {
+ auto next_higher = std::find_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item);
+ if (next_higher != parent->children.end()) {
Inkscape::XML::Node *ref = next_higher->getRepr();
getRepr()->parent()->changeOrder(getRepr(), ref);
+ return true;
}
+ return false;
}
-void SPItem::lowerOne() {
- using Inkscape::Util::MutableList;
- using Inkscape::Util::reverse_list;
+bool SPItem::lowerOne() {
+ using Inkscape::Algorithms::find_last_if;
- MutableList<SPObject &> next_lower=std::find_if(
- reverse_list<SPObject::SiblingIterator>(
- parent->firstChild(), this
- ),
- MutableList<SPObject &>(),
- &is_item
- );
- if (next_lower) {
- ++next_lower;
- Inkscape::XML::Node *ref = ( next_lower ? next_lower->getRepr() : NULL );
+ auto next_lower = find_last_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item);
+ if (next_lower != parent->children.iterator_to(*this)) {
+ Inkscape::XML::Node *ref = nullptr;
+ if (next_lower != parent->children.begin()) {
+ next_lower--;
+ ref = next_lower->getRepr();
+ }
getRepr()->parent()->changeOrder(getRepr(), ref);
+ return true;
}
+ return false;
}
void SPItem::lowerToBottom() {
- using Inkscape::Algorithms::find_last_if;
- using Inkscape::Util::MutableList;
- using Inkscape::Util::reverse_list;
-
- SPObject * bottom=parent->firstChild();
- while(dynamic_cast<SPObject*>(bottom) && dynamic_cast<SPObject*>(bottom->next) && bottom!=this && !is_item(*(bottom->next))) bottom=bottom->next;
- if (bottom && bottom != this) {
- Inkscape::XML::Node *ref = bottom->getRepr() ;
+ auto bottom = std::find_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item);
+ if (bottom != parent->children.iterator_to(*this)) {
+ Inkscape::XML::Node *ref = nullptr;
+ if (bottom != parent->children.begin()) {
+ bottom--;
+ ref = bottom->getRepr();
+ }
parent->getRepr()->changeOrder(getRepr(), ref);
}
}
@@ -366,8 +353,8 @@ void SPItem::moveTo(SPItem *target, bool intoafter) {
// Assume move to the "first" in the top node, find the top node
intoafter = false;
SPObject* bottom = this->document->getObjectByRepr(our_ref->root())->firstChild();
- while(!dynamic_cast<SPItem*>(bottom->next)){
- bottom=bottom->next;
+ while(!dynamic_cast<SPItem*>(bottom->getNext())){
+ bottom = bottom->getNext();
}
target_ref = bottom->getRepr();
}
@@ -686,7 +673,7 @@ void SPItem::update(SPCtx* ctx, guint flags) {
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
for (SPItemView *v = display; v != NULL; v = v->next) {
v->arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value));
- v->arenaitem->setAntialiasing(style->shape_rendering.computed != SP_CSS_SHAPE_RENDERING_CRISPEDGES);
+ v->arenaitem->setAntialiasing(style->shape_rendering.computed == SP_CSS_SHAPE_RENDERING_CRISPEDGES ? 0 : 2);
v->arenaitem->setIsolation( style->isolation.value );
v->arenaitem->setBlendMode( style->mix_blend_mode.value );
v->arenaitem->setVisible(!isHidden());
@@ -710,6 +697,10 @@ void SPItem::update(SPCtx* ctx, guint flags) {
void SPItem::modified(unsigned int /*flags*/)
{
+#ifdef OBJECT_TRACE
+ objectTrace( "SPItem::modified" );
+ objectTrace( "SPItem::modified", false );
+#endif
}
Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
@@ -720,9 +711,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X
// so we need to add any children from the underlying object to the new repr
if (flags & SP_OBJECT_WRITE_BUILD) {
GSList *l = NULL;
- for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) {
- if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: object->children) {
+ if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend (l, crepr);
}
@@ -734,9 +725,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X
l = g_slist_remove (l, l->data);
}
} else {
- for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) {
- if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) {
- child->updateRepr(flags);
+ for (auto& child: object->children) {
+ if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) {
+ child.updateRepr(flags);
}
}
}
@@ -883,6 +874,17 @@ Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const
}
}
+Geom::OptRect SPItem::documentPreferredBounds() const
+{
+ if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) {
+ return documentBounds(SPItem::VISUAL_BBOX);
+ } else {
+ return documentBounds(SPItem::GEOMETRIC_BBOX);
+ }
+}
+
+
+
Geom::OptRect SPItem::documentGeometricBounds() const
{
return geometricBounds(i2doc_affine());
@@ -943,12 +945,12 @@ unsigned int SPItem::pos_in_parent() const {
unsigned int pos = 0;
- for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) {
- if (iter == this) {
+ for (auto& iter: parent->children) {
+ if (&iter == this) {
return pos;
}
- if (dynamic_cast<SPItem *>(iter)) {
+ if (dynamic_cast<SPItem *>(&iter)) {
pos++;
}
}
@@ -989,8 +991,8 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap
for (std::list<SPObject const *>::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) {
if (*o) {
// obj is a group object, the children are the actual clippers
- for (SPObject *child = (*o)->children ; child ; child = child->next) {
- SPItem *item = dynamic_cast<SPItem *>(child);
+ for(auto& child: (*o)->children) {
+ SPItem *item = dynamic_cast<SPItem *>(const_cast<SPObject*>(&child));
if (item) {
std::vector<Inkscape::SnapCandidatePoint> p_clip_or_mask;
// Please note the recursive call here!
@@ -1317,8 +1319,8 @@ void SPItem::adjust_stroke_width_recursive(double expansion)
// A clone's child is the ghost of its original - we must not touch it, skip recursion
if ( !dynamic_cast<SPUse *>(this) ) {
- for ( SPObject *o = children; o; o = o->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if (item) {
item->adjust_stroke_width_recursive(expansion);
}
@@ -1332,8 +1334,8 @@ void SPItem::freeze_stroke_width_recursive(bool freeze)
// A clone's child is the ghost of its original - we must not touch it, skip recursion
if ( !dynamic_cast<SPUse *>(this) ) {
- for ( SPObject *o = children; o; o = o->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if (item) {
item->freeze_stroke_width_recursive(freeze);
}
@@ -1352,10 +1354,10 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform)
rect->compensateRxRy(advertized_transform);
}
- for (SPObject *o = item->children; o != NULL; o = o->next) {
- SPItem *item = dynamic_cast<SPItem *>(o);
- if (item) {
- sp_item_adjust_rects_recursive(item, advertized_transform);
+ for(auto& o: item->children) {
+ SPItem *itm = dynamic_cast<SPItem *>(&o);
+ if (itm) {
+ sp_item_adjust_rects_recursive(itm, advertized_transform);
}
}
}
@@ -1372,8 +1374,8 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af
// also we do not recurse into clones, because a clone's child is the ghost of its original -
// we must not touch it
if (!(this && (dynamic_cast<SPText *>(this) || dynamic_cast<SPUse *>(this)))) {
- for (SPObject *o = children; o != NULL; o = o->next) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if (item) {
// At the level of the transformed item, t_ancestors is identity;
// below it, it is the accmmulated chain of transforms from this level to the top level
@@ -1423,7 +1425,6 @@ Geom::Affine SPItem::set_transform(Geom::Affine const &transform) {
void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv, bool compensate)
{
g_return_if_fail(repr != NULL);
-
// calculate the relative transform, if not given by the adv attribute
Geom::Affine advertized_transform;
if (adv != NULL) {
@@ -1681,8 +1682,8 @@ SPItem const *sp_item_first_item_child(SPObject const *obj)
SPItem *sp_item_first_item_child(SPObject *obj)
{
SPItem *child = 0;
- for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) {
- SPItem *tmp = dynamic_cast<SPItem *>(iter);
+ for (auto& iter: obj->children) {
+ SPItem *tmp = dynamic_cast<SPItem *>(&iter);
if ( tmp ) {
child = tmp;
break;