From 1d854ff519b9c0867bfa4ecaf2f6329ca256f06a Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 2 Mar 2014 10:29:06 -0500 Subject: Experimental merge of Ponyscape features into trunk (will not compile) (bzr r13090.1.1) --- src/sp-item.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5e126f486..aec749929 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -183,6 +183,26 @@ bool SPItem::isHidden(unsigned display_key) const { return true; } +bool SPItem::isHighlightSet() const { + return _highlightColor != NULL; +} + +guint32 SPItem::highlight_color() const { + if (_highlightColor) + { + return atoi(_highlightColor) | 0x000000ff; + } + else if (parent && parent != this && SP_IS_ITEM(parent)) + { + return SP_ITEM(parent)->highlight_color(); + } + else + { + static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x000000ff; + } +} + void SPItem::setEvaluated(bool evaluated) { _is_evaluated = evaluated; _evaluated_status = StatusSet; -- cgit v1.2.3 From 1f7732ba927a31166d834a206bdfc7d20128d483 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 2 Mar 2014 14:15:38 -0500 Subject: Attempt at merging certaing features of Ponyscape to trunk (will not link) (bzr r13090.1.5) --- src/sp-item.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index aec749929..279606481 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -416,6 +416,7 @@ void SPItem::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "inkscape:transform-center-y" ); object->readAttr( "inkscape:connector-avoid" ); object->readAttr( "inkscape:connection-points" ); + object->readAttr( "inkscape:highlight-color" ); SPObject::build(document, repr); } -- cgit v1.2.3 From 93e2eef0d931bc2250b0328ddc24dac76c7c3e03 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 2 Mar 2014 18:18:32 -0500 Subject: Modified Objects dialogue to stop crashing on change of highlight color (bzr r13090.1.10) --- src/sp-item.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 279606481..79d8cc37d 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -99,6 +99,8 @@ SPItem::SPItem() : SPObject() { sensitive = TRUE; bbox_valid = FALSE; + _highlightColor = NULL; + transform_center_x = 0; transform_center_y = 0; -- cgit v1.2.3 From 4eed716131afa00f3590b7d60600ef0c476c78e3 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 2 Mar 2014 20:24:50 -0500 Subject: Fixed path color when changed by Objects Dialog (bzr r13090.1.11) --- src/sp-item.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 79d8cc37d..ff3e3a31c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -493,11 +493,23 @@ void SPItem::set(unsigned int key, gchar const* value) { break; } case SP_ATTR_SODIPODI_INSENSITIVE: + { item->sensitive = !value; for (SPItemView *v = item->display; v != NULL; v = v->next) { v->arenaitem->setSensitive(item->sensitive); } break; + } + case SP_ATTR_INKSCAPE_HIGHLIGHT_COLOR: + { + g_free(item->_highlightColor); + if (value) { + item->_highlightColor = g_strdup(value); + } else { + item->_highlightColor = NULL; + } + break; + } case SP_ATTR_CONNECTOR_AVOID: item->avoidRef->setAvoid(value); break; @@ -706,6 +718,11 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X g_free ((void *) uri); } } + if (item->_highlightColor){ + repr->setAttribute("inkscape:highlight-color", item->_highlightColor); + } else { + repr->setAttribute("inkscape:highlight-color", NULL); + } SPObject::write(xml_doc, repr, flags); -- cgit v1.2.3 From f50d13ff0fa4de4abf81251ec855ca0166db9050 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 12 Jul 2014 15:32:27 +0200 Subject: Fix moving of item center: 1) at paste and 2) at changing document units Fixed bugs: - https://launchpad.net/bugs/1247799 (bzr r13452) --- src/sp-item.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index b10aae1c6..0cdff6546 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -271,6 +271,11 @@ Geom::Point SPItem::getCenter() const { } } +void +SPItem::scaleCenter(Geom::Scale const &sc) { + transform_center_x *= sc[Geom::X]; + transform_center_y *= sc[Geom::Y]; +} namespace { -- cgit v1.2.3 From d7c36cd293ee35f53a5b47f2795b061888d4f79b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 22 Jul 2014 21:16:52 +0200 Subject: Fixed some logic errors; clang warnings. (bzr r13460) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 0cdff6546..698559a9f 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1264,7 +1264,7 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // Within text, we do not fork gradients, and so must not recurse to avoid double compensation; // 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 && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { + if (!(SP_IS_TEXT(this) || SP_IS_USE(this))) { for (SPObject *o = children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) { // At the level of the transformed item, t_ancestors is identity; -- cgit v1.2.3 From d9e1d33c2eb1793056aab9c4d567e7981042a294 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 23 Jul 2014 22:29:55 +0200 Subject: Partly reverted r13460. (bzr r13464) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 698559a9f..0cdff6546 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1264,7 +1264,7 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // Within text, we do not fork gradients, and so must not recurse to avoid double compensation; // also we do not recurse into clones, because a clone's child is the ghost of its original - // we must not touch it - if (!(SP_IS_TEXT(this) || SP_IS_USE(this))) { + if (!(this && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { for (SPObject *o = children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) { // At the level of the transformed item, t_ancestors is identity; -- cgit v1.2.3 From 653be18705548ae8ab5a0358ecf77feca1b22e54 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 28 Jul 2014 21:34:56 +0200 Subject: noop: remove commented-out code that is dangerous and should not come back (bzr r13475) --- src/sp-item.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 0cdff6546..a3f1a5d64 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -118,10 +118,6 @@ SPItem::SPItem() : SPObject() { mask_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(mask_ref_changed), this)); avoidRef = new SPAvoidRef(this); - - //new (&constraints) std::vector(); - - //new (&_transformed_signal) sigc::signal(); } SPItem::~SPItem() { -- cgit v1.2.3 From 97a4ef4fd8b0c841a90f3bb29dee13fd96edecb7 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 1 Aug 2014 11:04:51 +0200 Subject: Rename 'blend-mode' property to 'mix-blend-mode' per CSS spec. (bzr r13485) --- src/sp-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index a3f1a5d64..6c2ada9d7 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -602,7 +602,7 @@ void SPItem::update(SPCtx* /*ctx*/, guint flags) { v->arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(object->style->opacity.value)); v->arenaitem->setAntialiasing(object->style->shape_rendering.computed != SP_CSS_SHAPE_RENDERING_CRISPEDGES); v->arenaitem->setIsolation( object->style->isolation.value ); - v->arenaitem->setBlendMode( object->style->blend_mode.value ); + v->arenaitem->setBlendMode( object->style->mix_blend_mode.value ); v->arenaitem->setVisible(!item->isHidden()); } } @@ -1028,7 +1028,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned ai->setTransform(transform); ai->setOpacity(SP_SCALE24_TO_FLOAT(style->opacity.value)); ai->setIsolation( style->isolation.value ); - ai->setBlendMode( style->blend_mode.value ); + ai->setBlendMode( style->mix_blend_mode.value ); //ai->setCompositeOperator( style->composite_op.value ); ai->setVisible(!isHidden()); ai->setSensitive(sensitive); -- cgit v1.2.3 From acd8f135f2a901c5f046e51ad7783e442c43997a Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 4 Aug 2014 12:10:37 -0400 Subject: Allow editing of fill and stroke patterns simultaneously. Fixes #601336, #604025, #486192 Fixed bugs: - https://launchpad.net/bugs/601336 - https://launchpad.net/bugs/604025 - https://launchpad.net/bugs/486192 (bzr r13489) --- src/sp-item.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 6c2ada9d7..780845deb 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1109,9 +1109,10 @@ void SPItem::invoke_hide(unsigned key) // Adjusters -void SPItem::adjust_pattern (Geom::Affine const &postmul, bool set) +void SPItem::adjust_pattern(Geom::Affine const &postmul, bool set, PatternTransform pt) { - if (style && (style->fill.isPaintserver())) { + bool fill = (pt == TRANSFORM_FILL || pt == TRANSFORM_BOTH); + if (fill && style && (style->fill.isPaintserver())) { SPObject *server = style->getFillPaintServer(); if ( SP_IS_PATTERN(server) ) { SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "fill"); @@ -1119,7 +1120,8 @@ void SPItem::adjust_pattern (Geom::Affine const &postmul, bool set) } } - if (style && (style->stroke.isPaintserver())) { + bool stroke = (pt == TRANSFORM_STROKE || pt == TRANSFORM_BOTH); + if (stroke && style && (style->stroke.isPaintserver())) { SPObject *server = style->getStrokePaintServer(); if ( SP_IS_PATTERN(server) ) { SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "stroke"); -- cgit v1.2.3 From 6c4eb87454986e1e4c680b7b7f8fe8a166b25cda Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 4 Aug 2014 13:23:56 -0400 Subject: refresh bbox of clipped clone (Bug 1349018) Fixed bugs: - https://launchpad.net/bugs/1349018 (bzr r13491) --- src/sp-item.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 780845deb..0cacc86b1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -778,6 +778,7 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const bbox = const_cast(this)->bbox(transform, SPItem::VISUAL_BBOX); } if (clip_ref->getObject()) { + SP_ITEM(clip_ref->getOwner())->bbox_valid = FALSE; // LP Bug 1349018 bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); } -- cgit v1.2.3 From 9fdd8f25ee0f04d337864c7ec5e3216dae727e3c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 14 Aug 2014 22:09:10 +0200 Subject: Fix some transformation center regressions, related to the viewbox/units changes (bzr r13512) --- src/sp-item.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 0cacc86b1..428f9555e 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -228,18 +228,25 @@ void SPItem::setExplicitlyHidden(bool val) { } /** - * Sets the transform_center_x and transform_center_y properties to retain the rotation centre - */ + * Sets the transform_center_x and transform_center_y properties to retain the rotation center +*/ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); + // Copied from DocumentProperties::onDocUnitChange() + gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); + gdouble viewscale = std::min(viewscale_h, viewscale_w); + // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { - transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; + // object centre is document coordinates (i.e. in pixels), so we need to consider the viewbox + // to translate to user units; transform_center_x/y is in user units + transform_center_x = (object_centre[Geom::X] - bbox->midpoint()[Geom::X])/viewscale; if (Geom::are_near(transform_center_x, 0)) // rounding error transform_center_x = 0; - transform_center_y = object_centre[Geom::Y] - bbox->midpoint()[Geom::Y]; + transform_center_y = (object_centre[Geom::Y] - bbox->midpoint()[Geom::Y])/viewscale; if (Geom::are_near(transform_center_y, 0)) // rounding error transform_center_y = 0; } @@ -255,16 +262,25 @@ bool SPItem::isCenterSet() const { return (transform_center_x != 0 || transform_center_y != 0); } +// Get the item's transformation center in document coordinates (i.e. in pixels) Geom::Point SPItem::getCenter() const { document->ensureUpToDate(); + // Copied from DocumentProperties::onDocUnitChange() + gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); + gdouble viewscale = std::min(viewscale_h, viewscale_w); + // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); if (bbox) { - return bbox->midpoint() + Geom::Point (transform_center_x, transform_center_y); + // transform_center_x/y are stored in user units, so we have to take the viewbox into account to translate to document coordinates + return bbox->midpoint() + Geom::Point (transform_center_x*viewscale, transform_center_y*viewscale); + } else { return Geom::Point(0, 0); // something's wrong! } + } void -- cgit v1.2.3 From 7fd8ede6c698136bfa675dd4f1d5da6f5803154f Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 26 Aug 2014 22:38:14 +0200 Subject: Fix rotation center regression caused by my own commit 13512 Fixed bugs: - https://launchpad.net/bugs/1360953 - https://launchpad.net/bugs/1360946 (bzr r13534) --- src/sp-item.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 428f9555e..19dc71785 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -234,9 +234,13 @@ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); @@ -267,9 +271,13 @@ Geom::Point SPItem::getCenter() const { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); -- cgit v1.2.3 From 1f2d8bc4ce99e970cead4ca96c1859c383a9c043 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 31 Aug 2014 14:17:26 -0400 Subject: Header cleanup: stop using Glib types where they aren't truly needed. Eases GThread deprecation errors. (bzr r13341.1.190) --- src/sp-item.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 428f9555e..c79508199 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -360,7 +360,7 @@ void SPItem::lowerToBottom() { * \param target - the SPItem to move into or after * \param intoafter - move to after the target (false), move inside (sublayer) of the target (true) */ -void SPItem::moveTo(SPItem *target, gboolean intoafter) { +void SPItem::moveTo(SPItem *target, bool intoafter) { Inkscape::XML::Node *target_ref = ( target ? target->getRepr() : NULL ); Inkscape::XML::Node *our_ref = getRepr(); -- cgit v1.2.3 From 0d0958e3b2aff0ed5f3ad7a98b4035213475c7f1 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 7 Sep 2014 13:02:01 -0400 Subject: Update to experimental r13543 (bzr r13090.1.108) --- src/sp-item.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 67a0eac13..c3cbe531f 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -256,9 +256,13 @@ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); @@ -289,9 +293,13 @@ Geom::Point SPItem::getCenter() const { document->ensureUpToDate(); // Copied from DocumentProperties::onDocUnitChange() - gdouble viewscale_w = this->document->getWidth().value("px") / this->document->getRoot()->viewBox.width(); - gdouble viewscale_h = this->document->getHeight().value("px")/ this->document->getRoot()->viewBox.height(); - gdouble viewscale = std::min(viewscale_h, viewscale_w); + gdouble viewscale = 1.0; + Geom::Rect vb = this->document->getRoot()->viewBox; + if ( !vb.hasZeroArea() ) { + gdouble viewscale_w = this->document->getWidth().value("px") / vb.width(); + gdouble viewscale_h = this->document->getHeight().value("px")/ vb.height(); + viewscale = std::min(viewscale_h, viewscale_w); + } // FIXME this is seriously wrong Geom::OptRect bbox = desktopGeometricBounds(); -- cgit v1.2.3 From 3f649ca279f98542e8147e9bd5ab67691c6e21a0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 24 Sep 2014 21:22:34 +0200 Subject: Fix bug in object dialog, in highlight color couldent select opacity, now fixed (bzr r13341.1.224) --- src/sp-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index c3cbe531f..10dc1a32c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -188,7 +188,7 @@ bool SPItem::isHighlightSet() const { guint32 SPItem::highlight_color() const { if (_highlightColor) { - return atoi(_highlightColor) | 0x000000ff; + return atoi(_highlightColor) | 0x00000000; } else if (parent && parent != this && SP_IS_ITEM(parent)) { @@ -197,7 +197,7 @@ guint32 SPItem::highlight_color() const { else { static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x000000ff; + return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x00000000; } } -- cgit v1.2.3 From 25a22169e6587f58856cc288b8967bc862013d26 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 27 Sep 2014 07:39:25 -0400 Subject: transform text in text-on-path the same regardless of whether optimized or preserved (Bug 1279534) Fixed bugs: - https://launchpad.net/bugs/1279534 (bzr r13566) --- src/sp-item.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 19dc71785..71cdfa394 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -44,6 +44,7 @@ #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" @@ -1407,10 +1408,11 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra // onSetTransform cannot be pure due to the fact that not all visible Items are transformable. if ( // run the object's set_transform (i.e. embed transform) only if: - !preserve && // user did not chose to preserve all transforms + SP_IS_TEXT_TEXTPATH(this) || + (!preserve && // user did not chose to preserve all transforms (!clip_ref || !clip_ref->getObject()) && // the object does not have a clippath (!mask_ref || !mask_ref->getObject()) && // the object does not have a mask - !(!transform.isTranslation() && style && style->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) + !(!transform.isTranslation() && style && style->getFilter())) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = this->set_transform(transform); -- cgit v1.2.3 From b9875e6c09fcb62fa4f9c667ee6a48c8b62f8508 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 14 Oct 2014 12:06:31 +0200 Subject: Merged src/sp-item.cpp from svg-paints-support branch (bzr r13611.1.7) --- src/sp-item.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 71cdfa394..edf758e7d 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -118,6 +118,9 @@ SPItem::SPItem() : SPObject() { mask_ref = new SPMaskReference(this); mask_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(mask_ref_changed), this)); + style->signal_fill_ps_changed.connect(sigc::bind(sigc::ptr_fun(fill_ps_ref_changed), this)); + style->signal_stroke_ps_changed.connect(sigc::bind(sigc::ptr_fun(stroke_ps_ref_changed), this)); + avoidRef = new SPAvoidRef(this); } @@ -442,7 +445,15 @@ void SPItem::release() { SPObject::release(); + SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); + SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); while (item->display) { + if (fill_pattern) { + fill_pattern->hide(item->display->arenaitem->key()); + } + if (stroke_pattern) { + stroke_pattern->hide(item->display->arenaitem->key()); + } item->display = sp_item_view_list_remove(item->display, item->display); } @@ -588,6 +599,34 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } +void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { + SPPattern *old_fill_pattern = SP_PATTERN(old_ps); + if (old_fill_pattern) { + for (SPItemView *v =item->display; v != NULL; v = v->next) { + old_fill_pattern->hide(v->arenaitem->key()); + } + } + + SPPattern *new_fill_pattern = SP_PATTERN(ps); + if (new_fill_pattern) { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingPattern *pi = new_fill_pattern->show( + v->arenaitem->drawing(), v->arenaitem->key()); + v->arenaitem->setFillPattern(pi); + new_fill_pattern->setBBox(v->arenaitem->key(), bbox); + new_fill_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + } +} + +void SPItem::stroke_ps_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { + +} + void SPItem::update(SPCtx* /*ctx*/, guint flags) { SPItem *item = this; SPItem* object = item; @@ -647,6 +686,9 @@ void SPItem::update(SPCtx* /*ctx*/, guint flags) { item->avoidRef->handleSettingChange(); } +void SPItem::modified(unsigned int flags) { +} + Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPItem *item = this; SPItem* object = item; @@ -1090,6 +1132,31 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned SP_MASK(mask)->sp_mask_set_bbox(mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } + + SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); + if (fill_pattern) { + if (!display->arenaitem->key()) { + display->arenaitem->setKey(display_key_new(3)); + } + int fill_key = display->arenaitem->key(); + + Inkscape::DrawingPattern *ac = fill_pattern->show(drawing, fill_key); + ai->setFillPattern(ac); + fill_pattern->setBBox(fill_key, item_bbox); + fill_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); + if (stroke_pattern) { + if (!display->arenaitem->key()) { + display->arenaitem->setKey(display_key_new(3)); + } + int stroke_key = display->arenaitem->key(); + + Inkscape::DrawingPattern *ac = stroke_pattern->show(drawing, stroke_key); + ai->setStrokePattern(ac); + stroke_pattern->setBBox(stroke_key, item_bbox); + stroke_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } ai->setData(this); ai->setItemBounds(geometricBounds()); } @@ -1119,6 +1186,14 @@ void SPItem::invoke_hide(unsigned key) mask_ref->getObject()->sp_mask_hide(v->arenaitem->key()); v->arenaitem->setMask(NULL); } + SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); + if (fill_pattern) { + fill_pattern->hide(v->arenaitem->key()); + } + SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); + if (stroke_pattern) { + stroke_pattern->hide(v->arenaitem->key()); + } if (!ref) { display = v->next; } else { -- cgit v1.2.3 From f3b182a2facfd52c7bbfee67f207ad765f536beb Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 14 Oct 2014 13:01:49 +0200 Subject: Merged hatch rendering code (bzr r13611.1.8) --- src/sp-item.cpp | 70 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index edf758e7d..da6e6ea58 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -445,14 +445,14 @@ void SPItem::release() { SPObject::release(); - SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); - SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); + SPPaintServer *fill_ps = style->getFillPaintServer(); + SPPaintServer *stroke_ps = style->getStrokePaintServer(); while (item->display) { - if (fill_pattern) { - fill_pattern->hide(item->display->arenaitem->key()); + if (fill_ps) { + fill_ps->hide(item->display->arenaitem->key()); } - if (stroke_pattern) { - stroke_pattern->hide(item->display->arenaitem->key()); + if (stroke_ps) { + stroke_ps->hide(item->display->arenaitem->key()); } item->display = sp_item_view_list_remove(item->display, item->display); } @@ -600,25 +600,27 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { - SPPattern *old_fill_pattern = SP_PATTERN(old_ps); - if (old_fill_pattern) { + SPPaintServer *old_fill_ps = SP_PAINT_SERVER(old_ps); + if (old_fill_ps) { for (SPItemView *v =item->display; v != NULL; v = v->next) { - old_fill_pattern->hide(v->arenaitem->key()); + old_fill_ps->hide(v->arenaitem->key()); } } - SPPattern *new_fill_pattern = SP_PATTERN(ps); - if (new_fill_pattern) { + SPPaintServer *new_fill_ps = SP_PAINT_SERVER(ps); + if (new_fill_ps) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingPattern *pi = new_fill_pattern->show( + Inkscape::DrawingPattern *pi = new_fill_ps->show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setFillPattern(pi); - new_fill_pattern->setBBox(v->arenaitem->key(), bbox); - new_fill_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + new_fill_ps->setBBox(v->arenaitem->key(), bbox); + if (pi) { + new_fill_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } } } } @@ -1133,29 +1135,33 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); - if (fill_pattern) { + SPPaintServer *fill_ps = style->getFillPaintServer(); + if (fill_ps) { if (!display->arenaitem->key()) { display->arenaitem->setKey(display_key_new(3)); } int fill_key = display->arenaitem->key(); - Inkscape::DrawingPattern *ac = fill_pattern->show(drawing, fill_key); - ai->setFillPattern(ac); - fill_pattern->setBBox(fill_key, item_bbox); - fill_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + Inkscape::DrawingPattern *ap = fill_ps->show(drawing, fill_key); + ai->setFillPattern(ap); + fill_ps->setBBox(fill_key, item_bbox); + if (ap) { + fill_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } } - SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); - if (stroke_pattern) { + SPPaintServer *stroke_ps = style->getStrokePaintServer(); + if (stroke_ps) { if (!display->arenaitem->key()) { display->arenaitem->setKey(display_key_new(3)); } int stroke_key = display->arenaitem->key(); - Inkscape::DrawingPattern *ac = stroke_pattern->show(drawing, stroke_key); - ai->setStrokePattern(ac); - stroke_pattern->setBBox(stroke_key, item_bbox); - stroke_pattern->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + Inkscape::DrawingPattern *ap = stroke_ps->show(drawing, stroke_key); + ai->setStrokePattern(ap); + stroke_ps->setBBox(stroke_key, item_bbox); + if (ap) { + stroke_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } } ai->setData(this); ai->setItemBounds(geometricBounds()); @@ -1186,13 +1192,13 @@ void SPItem::invoke_hide(unsigned key) mask_ref->getObject()->sp_mask_hide(v->arenaitem->key()); v->arenaitem->setMask(NULL); } - SPPattern *fill_pattern = SP_PATTERN(style->getFillPaintServer()); - if (fill_pattern) { - fill_pattern->hide(v->arenaitem->key()); + SPPaintServer *fill_ps = style->getFillPaintServer(); + if (fill_ps) { + fill_ps->hide(v->arenaitem->key()); } - SPPattern *stroke_pattern = SP_PATTERN(style->getStrokePaintServer()); - if (stroke_pattern) { - stroke_pattern->hide(v->arenaitem->key()); + SPPaintServer *stroke_ps = style->getStrokePaintServer(); + if (stroke_ps) { + stroke_ps->hide(v->arenaitem->key()); } if (!ref) { display = v->next; -- cgit v1.2.3 From bf11ecdfe29082801833fa565f0a1710f6fcd281 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 14 Oct 2014 13:30:31 +0200 Subject: Merged hatch pdf and png export code (bzr r13611.1.9) --- src/sp-item.cpp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index da6e6ea58..f6de165a6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -615,9 +615,8 @@ void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { v->arenaitem->setKey(SPItem::display_key_new(3)); } Inkscape::DrawingPattern *pi = new_fill_ps->show( - v->arenaitem->drawing(), v->arenaitem->key()); + v->arenaitem->drawing(), v->arenaitem->key(), bbox); v->arenaitem->setFillPattern(pi); - new_fill_ps->setBBox(v->arenaitem->key(), bbox); if (pi) { new_fill_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -625,8 +624,29 @@ void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { } } -void SPItem::stroke_ps_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { +void SPItem::stroke_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { + SPPaintServer *old_stroke_ps = SP_PAINT_SERVER(old_ps); + if (old_stroke_ps) { + for (SPItemView *v =item->display; v != NULL; v = v->next) { + old_stroke_ps->hide(v->arenaitem->key()); + } + } + SPPaintServer *new_stroke_ps = SP_PAINT_SERVER(ps); + if (new_stroke_ps) { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingPattern *pi = new_stroke_ps->show( + v->arenaitem->drawing(), v->arenaitem->key(), bbox); + v->arenaitem->setStrokePattern(pi); + if (pi) { + new_stroke_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + } + } } void SPItem::update(SPCtx* /*ctx*/, guint flags) { @@ -1142,9 +1162,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } int fill_key = display->arenaitem->key(); - Inkscape::DrawingPattern *ap = fill_ps->show(drawing, fill_key); + Inkscape::DrawingPattern *ap = fill_ps->show(drawing, fill_key, item_bbox); ai->setFillPattern(ap); - fill_ps->setBBox(fill_key, item_bbox); if (ap) { fill_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -1156,9 +1175,8 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned } int stroke_key = display->arenaitem->key(); - Inkscape::DrawingPattern *ap = stroke_ps->show(drawing, stroke_key); + Inkscape::DrawingPattern *ap = stroke_ps->show(drawing, stroke_key, item_bbox); ai->setStrokePattern(ap); - stroke_ps->setBBox(stroke_key, item_bbox); if (ap) { stroke_ps->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -- cgit v1.2.3 From dcbfb36e7c6279b1cc651131758700961152a8b0 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 15 Oct 2014 02:43:52 -0700 Subject: Post-merge cleanup. (bzr r13615) --- src/sp-item.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index f6de165a6..52ee6b7d8 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -708,7 +708,8 @@ void SPItem::update(SPCtx* /*ctx*/, guint flags) { item->avoidRef->handleSettingChange(); } -void SPItem::modified(unsigned int flags) { +void SPItem::modified(unsigned int /*flags*/) +{ } Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -- cgit v1.2.3 From ce462c6c703507a22f36a6e4a934c1deec27abdb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 6 Nov 2014 19:45:35 -0800 Subject: Doc comment cleanup. (bzr r13674) --- src/sp-item.cpp | 101 +++----------------------------------------------------- 1 file changed, 5 insertions(+), 96 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 967756055..ebb08e3d8 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1,6 +1,3 @@ -/** \file - * Base class for visual SVG elements - */ /* * Authors: * Lauris Kaplinski @@ -15,12 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -/** \class SPItem - * - * SPItem is an abstract base class for all graphic (visible) SVG nodes. It - * is a subclass of SPObject, with great deal of specific functionality. - */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -232,20 +223,12 @@ bool SPItem::isEvaluated() const { return _is_evaluated; } -/** - * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box. - * Corresponds to setExplicitlyHidden. - */ bool SPItem::isExplicitlyHidden() const { return (style->display.set && style->display.value == SP_CSS_DISPLAY_NONE); } -/** - * Sets the display CSS property to `hidden' if \a val is true, - * otherwise makes it unset - */ void SPItem::setExplicitlyHidden(bool val) { style->display.set = val; style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE ); @@ -253,9 +236,6 @@ void SPItem::setExplicitlyHidden(bool val) { updateRepr(); } -/** - * Sets the transform_center_x and transform_center_y properties to retain the rotation center -*/ void SPItem::setCenter(Geom::Point const &object_centre) { document->ensureUpToDate(); @@ -389,11 +369,6 @@ void SPItem::lowerToBottom() { } } -/* - * Move this SPItem into or after another SPItem in the doc - * \param target - the SPItem to move into or after - * \param intoafter - move to after the target (false), move inside (sublayer) of the target (true) - */ void SPItem::moveTo(SPItem *target, bool intoafter) { Inkscape::XML::Node *target_ref = ( target ? target->getRepr() : NULL ); @@ -826,11 +801,7 @@ Geom::OptRect SPItem::bbox(Geom::Affine const & /*transform*/, SPItem::BBoxType //throw; return Geom::OptRect(); } -/** - * Get item's geometric bounding box in this item's coordinate system. - * - * The geometric bounding box includes only the path, disregarding all style attributes. - */ + Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const { Geom::OptRect bbox; @@ -843,11 +814,6 @@ Geom::OptRect SPItem::geometricBounds(Geom::Affine const &transform) const return bbox; } -/** - * Get item's visual bounding box in this item's coordinate system. - * - * The visual bounding box includes the stroke and the filter region. - */ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const { using Geom::X; @@ -924,14 +890,11 @@ Geom::OptRect SPItem::bounds(BBoxType type, Geom::Affine const &transform) const } } -/** Get item's geometric bbox in document coordinate system. - * Document coordinates are the default coordinates of the root element: - * the origin is at the top left, X grows to the right and Y grows downwards. */ Geom::OptRect SPItem::documentGeometricBounds() const { return geometricBounds(i2doc_affine()); } -/// Get item's visual bbox in document coordinate system. + Geom::OptRect SPItem::documentVisualBounds() const { if (!bbox_valid) { @@ -948,14 +911,12 @@ Geom::OptRect SPItem::documentBounds(BBoxType type) const return documentVisualBounds(); } } -/** Get item's geometric bbox in desktop coordinate system. - * Desktop coordinates should be user defined. Currently they are hardcoded: - * origin is at bottom left, X grows to the right and Y grows upwards. */ + Geom::OptRect SPItem::desktopGeometricBounds() const { return geometricBounds(i2dt_affine()); } -/// Get item's visual bbox in desktop coordinate system. + Geom::OptRect SPItem::desktopVisualBounds() const { /// @fixme hardcoded desktop transform @@ -1079,11 +1040,6 @@ gchar* SPItem::description() const { return g_strdup(""); } -/** - * Returns a string suitable for status bar, formatted in pango markup language. - * - * Must be freed by caller. - */ gchar *SPItem::detailedDescription() const { gchar* s = g_strdup_printf("%s %s", this->displayName(), this->description()); @@ -1117,20 +1073,10 @@ gchar *SPItem::detailedDescription() const { return s; } -/** - * Returns true if the item is filtered, false otherwise. Used with groups/lists to determine how many, or if any, are filtered - * - */ bool SPItem::isFiltered() const { return (style && style->filter.href && style->filter.href->getObject()); } -/** - * Allocates unique integer keys. - * \param numkeys Number of keys required. - * \return First allocated key; hence if the returned key is n - * you can use n, n + 1, ..., n + (numkeys - 1) - */ unsigned SPItem::display_key_new(unsigned numkeys) { static unsigned dkey = 0; @@ -1367,9 +1313,6 @@ static Geom::Affine sp_item_transform_repr (SPItem *item) } -/** - * Recursively scale stroke width in \a item and its children by \a expansion. - */ void SPItem::adjust_stroke_width_recursive(double expansion) { adjust_stroke (expansion); @@ -1414,9 +1357,6 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) } } -/** - * Recursively compensate pattern or gradient transform. - */ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Affine t_ancestors, bool is_pattern) { // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors @@ -1478,14 +1418,6 @@ Geom::Affine SPItem::set_transform(Geom::Affine const &transform) { return transform; } -/** - * Set a new transform on an object. - * - * Compensate for stroke scaling and gradient/pattern fill transform, if - * necessary. Call the object's set_transform method if transforms are - * stored optimized. Send _transformed_signal. Invoke _write method so that - * the repr is updated with the new transform. - */ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &transform, Geom::Affine const *adv, bool compensate) { g_return_if_fail(repr != NULL); @@ -1597,10 +1529,6 @@ gint SPItem::emitEvent(SPEvent &event) return this->event(&event); } -/** - * Sets item private transform (not propagated to repr), without compensating stroke widths, - * gradients, patterns as sp_item_write_transform does. - */ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) { if (!Geom::are_near(transform_matrix, transform, 1e-18)) { @@ -1618,12 +1546,7 @@ void SPItem::set_item_transform(Geom::Affine const &transform_matrix) //} -/** - * \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL. - * ("Ancestor (\>=)" here includes as far as \a object itself.) - */ -Geom::Affine -i2anc_affine(SPObject const *object, SPObject const *const ancestor) { +Geom::Affine i2anc_affine(SPObject const *object, SPObject const *const ancestor) { Geom::Affine ret(Geom::identity()); g_return_val_if_fail(object != NULL, ret); @@ -1650,18 +1573,11 @@ Geom::Affine SPItem::getRelativeTransform(SPObject const *dest) const { return i2i_affine(this, dest); } -/** - * Returns the accumulated transformation of the item and all its ancestors, including root's viewport. - * \pre (item != NULL) and SP_IS_ITEM(item). - */ Geom::Affine SPItem::i2doc_affine() const { return i2anc_affine(this, NULL); } -/** - * Returns the transformation from item to desktop coords - */ Geom::Affine SPItem::i2dt_affine() const { Geom::Affine ret; @@ -1692,9 +1608,6 @@ void SPItem::set_i2d_affine(Geom::Affine const &i2dt) } -/** - * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa) - */ Geom::Affine SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ @@ -1738,10 +1651,6 @@ sp_item_view_list_remove(SPItemView *list, SPItemView *view) return ret; } -/** - * Return the arenaitem corresponding to the given item in the display - * with the given key - */ Inkscape::DrawingItem *SPItem::get_arenaitem(unsigned key) { for ( SPItemView *iv = display ; iv ; iv = iv->next ) { -- cgit v1.2.3 From e179290f049d5c34ae2b9c05fdfeab830b7c39e7 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 10 Nov 2014 09:39:33 -0800 Subject: Removed SP_USE/SP_IS_USE Gtk-ish macros and cleaned affected files. (bzr r13700) --- src/sp-item.cpp | 183 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 78 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ebb08e3d8..73347fc4e 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -130,7 +130,8 @@ bool SPItem::isVisibleAndUnlocked(unsigned display_key) const { bool SPItem::isLocked() const { for (SPObject const *o = this; o != NULL; o = o->parent) { - if (SP_IS_ITEM(o) && !(SP_ITEM(o)->sensitive)) { + SPItem const *item = dynamic_cast(o); + if (item && !(item->sensitive)) { return true; } } @@ -185,14 +186,17 @@ guint32 SPItem::highlight_color() const { { return atoi(_highlightColor) | 0x00000000; } - else if (parent && parent != this && SP_IS_ITEM(parent)) - { - return SP_ITEM(parent)->highlight_color(); - } - else - { - static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x00000000; + else { + SPItem const *item = dynamic_cast(parent); + if (parent && (parent != this) && item) + { + return item->highlight_color(); + } + else + { + static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + return prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) | 0x00000000; + } } } @@ -209,8 +213,9 @@ void SPItem::resetEvaluated() { requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } } if ( StatusSet == _evaluated_status ) { - if (SP_IS_SWITCH(parent)) { - SP_SWITCH(parent)->resetChildEvaluated(); + SPSwitch *switchItem = dynamic_cast(parent); + if (switchItem) { + switchItem->resetChildEvaluated(); } } } @@ -306,7 +311,7 @@ SPItem::scaleCenter(Geom::Scale const &sc) { namespace { bool is_item(SPObject const &object) { - return SP_IS_ITEM(&object); + return dynamic_cast(&object) != NULL; } } @@ -566,20 +571,23 @@ void SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) SPItemView *v; /* Hide clippath */ for (v = item->display; v != NULL; v = v->next) { - SP_CLIPPATH(old_clip)->hide(v->arenaitem->key()); + SPClipPath *oldPath = dynamic_cast(old_clip); + g_assert(oldPath != NULL); + oldPath->hide(v->arenaitem->key()); } } - if (SP_IS_CLIPPATH(clip)) { + SPClipPath *clipPath = dynamic_cast(clip); + if (clipPath) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingItem *ai = SP_CLIPPATH(clip)->show( + Inkscape::DrawingItem *ai = clipPath->show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setClip(ai); - SP_CLIPPATH(clip)->setBBox(v->arenaitem->key(), bbox); + clipPath->setBBox(v->arenaitem->key(), bbox); clip->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -590,34 +598,37 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (old_mask) { /* Hide mask */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - SP_MASK(old_mask)->sp_mask_hide(v->arenaitem->key()); + SPMask *maskItem = dynamic_cast(old_mask); + g_assert(maskItem != NULL); + maskItem->sp_mask_hide(v->arenaitem->key()); } } - if (SP_IS_MASK(mask)) { + SPMask *maskItem = dynamic_cast(mask); + if (maskItem) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingItem *ai = SP_MASK(mask)->sp_mask_show( + Inkscape::DrawingItem *ai = maskItem->sp_mask_show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setMask(ai); - SP_MASK(mask)->sp_mask_set_bbox(v->arenaitem->key(), bbox); + maskItem->sp_mask_set_bbox(v->arenaitem->key(), bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } } void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { - SPPaintServer *old_fill_ps = SP_PAINT_SERVER(old_ps); + SPPaintServer *old_fill_ps = dynamic_cast(old_ps); if (old_fill_ps) { for (SPItemView *v =item->display; v != NULL; v = v->next) { old_fill_ps->hide(v->arenaitem->key()); } } - SPPaintServer *new_fill_ps = SP_PAINT_SERVER(ps); + SPPaintServer *new_fill_ps = dynamic_cast(ps); if (new_fill_ps) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { @@ -635,14 +646,14 @@ void SPItem::fill_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { } void SPItem::stroke_ps_ref_changed(SPObject *old_ps, SPObject *ps, SPItem *item) { - SPPaintServer *old_stroke_ps = SP_PAINT_SERVER(old_ps); + SPPaintServer *old_stroke_ps = dynamic_cast(old_ps); if (old_stroke_ps) { for (SPItemView *v =item->display; v != NULL; v = v->next) { old_stroke_ps->hide(v->arenaitem->key()); } } - SPPaintServer *new_stroke_ps = SP_PAINT_SERVER(ps); + SPPaintServer *new_stroke_ps = dynamic_cast(ps); if (new_stroke_ps) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { @@ -731,7 +742,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + if (dynamic_cast(child) || dynamic_cast(child)) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); @@ -745,7 +756,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X } } else { for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + if (dynamic_cast(child) || dynamic_cast(child)) { child->updateRepr(flags); } } @@ -821,13 +832,14 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const Geom::OptRect bbox; - if ( style && style->filter.href && style->getFilter() && SP_IS_FILTER(style->getFilter())) { + + SPFilter *filter = (style && style->filter.href) ? dynamic_cast(style->getFilter()) : NULL; + if ( filter ) { // call the subclass method // CPPIFY //bbox = this->bbox(Geom::identity(), SPItem::VISUAL_BBOX); bbox = const_cast(this)->bbox(Geom::identity(), SPItem::GEOMETRIC_BBOX); // see LP Bug 1229971 - SPFilter *filter = SP_FILTER(style->getFilter()); // default filer area per the SVG spec: SVGLength x, y, w, h; Geom::Point minp, maxp; @@ -874,8 +886,10 @@ Geom::OptRect SPItem::visualBounds(Geom::Affine const &transform) const bbox = const_cast(this)->bbox(transform, SPItem::VISUAL_BBOX); } if (clip_ref->getObject()) { - SP_ITEM(clip_ref->getOwner())->bbox_valid = FALSE; // LP Bug 1349018 - bbox.intersectWith(SP_CLIPPATH(clip_ref->getObject())->geometricBounds(transform)); + SPItem *ownerItem = dynamic_cast(clip_ref->getOwner()); + g_assert(ownerItem != NULL); + ownerItem->bbox_valid = FALSE; // LP Bug 1349018 + bbox.intersectWith(clip_ref->getObject()->geometricBounds(transform)); } return bbox; @@ -955,7 +969,7 @@ unsigned int SPItem::pos_in_parent() const { return pos; } - if (SP_IS_ITEM(iter)) { + if (dynamic_cast(iter)) { pos++; } } @@ -997,10 +1011,11 @@ void SPItem::getSnappoints(std::vector &p, Inkscap if (*o) { // obj is a group object, the children are the actual clippers for (SPObject *child = (*o)->children ; child ; child = child->next) { - if (SP_IS_ITEM(child)) { + SPItem *item = dynamic_cast(child); + if (item) { std::vector p_clip_or_mask; // Please note the recursive call here! - SP_ITEM(child)->getSnappoints(p_clip_or_mask, snapprefs); + item->getSnappoints(p_clip_or_mask, snapprefs); // Take into account the transformation of the item being clipped or masked for (std::vector::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); ++p_orig) { // All snappoints are in desktop coordinates, but the item's transformation is @@ -1122,7 +1137,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned ai->setClip(ac); // Update bbox, in case the clip uses bbox units - SP_CLIPPATH(cp)->setBBox(clip_key, item_bbox); + cp->setBBox(clip_key, item_bbox); cp->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } if (mask_ref->getObject()) { @@ -1138,7 +1153,7 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned ai->setMask(ac); // Update bbox, in case the mask uses bbox units - SP_MASK(mask)->sp_mask_set_bbox(mask_key, item_bbox); + mask->sp_mask_set_bbox(mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -1226,8 +1241,9 @@ void SPItem::adjust_pattern(Geom::Affine const &postmul, bool set, PatternTransf bool fill = (pt == TRANSFORM_FILL || pt == TRANSFORM_BOTH); if (fill && style && (style->fill.isPaintserver())) { SPObject *server = style->getFillPaintServer(); - if ( SP_IS_PATTERN(server) ) { - SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "fill"); + SPPattern *serverPatt = dynamic_cast(server); + if ( serverPatt ) { + SPPattern *pattern = sp_pattern_clone_if_necessary(this, serverPatt, "fill"); sp_pattern_transform_multiply(pattern, postmul, set); } } @@ -1235,8 +1251,9 @@ void SPItem::adjust_pattern(Geom::Affine const &postmul, bool set, PatternTransf bool stroke = (pt == TRANSFORM_STROKE || pt == TRANSFORM_BOTH); if (stroke && style && (style->stroke.isPaintserver())) { SPObject *server = style->getStrokePaintServer(); - if ( SP_IS_PATTERN(server) ) { - SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "stroke"); + SPPattern *serverPatt = dynamic_cast(server); + if ( serverPatt ) { + SPPattern *pattern = sp_pattern_clone_if_necessary(this, serverPatt, "stroke"); sp_pattern_transform_multiply(pattern, postmul, set); } } @@ -1246,7 +1263,8 @@ void SPItem::adjust_gradient( Geom::Affine const &postmul, bool set ) { if ( style && style->fill.isPaintserver() ) { SPPaintServer *server = style->getFillPaintServer(); - if ( SP_IS_GRADIENT(server) ) { + SPGradient *serverGrad = dynamic_cast(server); + if ( serverGrad ) { /** * \note Bbox units for a gradient are generally a bad idea because @@ -1257,7 +1275,7 @@ void SPItem::adjust_gradient( Geom::Affine const &postmul, bool set ) * \todo FIXME: convert back to bbox units after transforming with * the item, so as to preserve the original units. */ - SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), this, "fill" ); + SPGradient *gradient = sp_gradient_convert_to_userspace( serverGrad, this, "fill" ); sp_gradient_transform_multiply( gradient, postmul, set ); } @@ -1265,8 +1283,9 @@ void SPItem::adjust_gradient( Geom::Affine const &postmul, bool set ) if ( style && style->stroke.isPaintserver() ) { SPPaintServer *server = style->getStrokePaintServer(); - if ( SP_IS_GRADIENT(server) ) { - SPGradient *gradient = sp_gradient_convert_to_userspace( SP_GRADIENT(server), this, "stroke"); + SPGradient *serverGrad = dynamic_cast(server); + if ( serverGrad ) { + SPGradient *gradient = sp_gradient_convert_to_userspace( serverGrad, this, "stroke"); sp_gradient_transform_multiply( gradient, postmul, set ); } } @@ -1318,10 +1337,11 @@ void SPItem::adjust_stroke_width_recursive(double expansion) adjust_stroke (expansion); // A clone's child is the ghost of its original - we must not touch it, skip recursion - if ( !SP_IS_USE(this) ) { + if ( !dynamic_cast(this) ) { for ( SPObject *o = children; o; o = o->getNext() ) { - if (SP_IS_ITEM(o)) { - SP_ITEM(o)->adjust_stroke_width_recursive(expansion); + SPItem *item = dynamic_cast(o); + if (item) { + item->adjust_stroke_width_recursive(expansion); } } } @@ -1332,10 +1352,11 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) freeze_stroke_width = freeze; // A clone's child is the ghost of its original - we must not touch it, skip recursion - if ( !SP_IS_USE(this) ) { + if ( !dynamic_cast(this) ) { for ( SPObject *o = children; o; o = o->getNext() ) { - if (SP_IS_ITEM(o)) { - SP_ITEM(o)->freeze_stroke_width_recursive(freeze); + SPItem *item = dynamic_cast(o); + if (item) { + item->freeze_stroke_width_recursive(freeze); } } } @@ -1347,13 +1368,16 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) static void sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) { - if (SP_IS_RECT (item)) { - SP_RECT(item)->compensateRxRy(advertized_transform); + SPRect *rect = dynamic_cast(item); + if (rect) { + rect->compensateRxRy(advertized_transform); } for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - sp_item_adjust_rects_recursive(SP_ITEM(o), advertized_transform); + SPItem *item = dynamic_cast(o); + if (item) { + sp_item_adjust_rects_recursive(item, advertized_transform); + } } } @@ -1368,12 +1392,13 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // Within text, we do not fork gradients, and so must not recurse to avoid double compensation; // 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 && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { + if (!(this && (dynamic_cast(this) || dynamic_cast(this)))) { for (SPObject *o = children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) { + SPItem *item = dynamic_cast(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 - SP_ITEM(o)->adjust_paint_recursive (advertized_transform, t_item * t_ancestors, is_pattern); + item->adjust_paint_recursive (advertized_transform, t_item * t_ancestors, is_pattern); } } } @@ -1392,20 +1417,18 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) { - if ( SP_IS_LPE_ITEM(this) ) { - SPLPEItem *lpeitem = SP_LPE_ITEM (this); - if ( lpeitem->hasPathEffect() ) { - lpeitem->forkPathEffectsIfNecessary(); - - // now that all LPEs are forked_if_necessary, we can apply the transform - PathEffectList effect_list = lpeitem->getEffectList(); - for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) - { - LivePathEffectObject *lpeobj = (*it)->lpeobject; - if (lpeobj && lpeobj->get_lpe()) { - Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe(); - effect->transform_multiply(postmul, set); - } + SPLPEItem *lpeitem = dynamic_cast(this); + if ( lpeitem && lpeitem->hasPathEffect() ) { + lpeitem->forkPathEffectsIfNecessary(); + + // now that all LPEs are forked_if_necessary, we can apply the transform + PathEffectList effect_list = lpeitem->getEffectList(); + for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) + { + LivePathEffectObject *lpeobj = (*it)->lpeobject; + if (lpeobj && lpeobj->get_lpe()) { + Inkscape::LivePathEffect::Effect * effect = lpeobj->get_lpe(); + effect->transform_multiply(postmul, set); } } } @@ -1480,7 +1503,7 @@ void SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Affine const &tra // onSetTransform cannot be pure due to the fact that not all visible Items are transformable. if ( // run the object's set_transform (i.e. embed transform) only if: - SP_IS_TEXT_TEXTPATH(this) || + (dynamic_cast(this) && firstChild() && dynamic_cast(firstChild())) || (!preserve && // user did not chose to preserve all transforms (!clip_ref || !clip_ref->getObject()) && // the object does not have a clippath (!mask_ref || !mask_ref->getObject()) && // the object does not have a mask @@ -1551,11 +1574,14 @@ Geom::Affine i2anc_affine(SPObject const *object, SPObject const *const ancestor g_return_val_if_fail(object != NULL, ret); /* stop at first non-renderable ancestor */ - while ( object != ancestor && SP_IS_ITEM(object) ) { - if (SP_IS_ROOT(object)) { - ret *= SP_ROOT(object)->c2p; + while ( object != ancestor && dynamic_cast(object) ) { + SPRoot const *root = dynamic_cast(object); + if (root) { + ret *= root->c2p; } else { - ret *= SP_ITEM(object)->transform; + SPItem const *item = dynamic_cast(object); + g_assert(item != NULL); + ret *= item->transform; } object = object->parent; } @@ -1619,7 +1645,7 @@ Geom::Affine SPItem::dt2i_affine() const SPItemView *SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, Inkscape::DrawingItem *drawing_item) { g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + g_assert(dynamic_cast(item) != NULL); g_assert(drawing_item != NULL); SPItemView *new_view = g_new(SPItemView, 1); @@ -1677,8 +1703,9 @@ SPItem *sp_item_first_item_child(SPObject *obj) { SPItem *child = 0; for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) { - if ( SP_IS_ITEM(iter) ) { - child = SP_ITEM(iter); + SPItem *tmp = dynamic_cast(iter); + if ( tmp ) { + child = tmp; break; } } -- cgit v1.2.3