summaryrefslogtreecommitdiffstats
path: root/src/sp-shape.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:07:14 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:07:14 +0000
commite77956b4dbd029c9f6949f81fe083606f995c624 (patch)
tree74adda4df8986d65f70efb341c6235277361fd35 /src/sp-shape.cpp
parentupdated code to work on 0.92 code (diff)
parentLatvian translation update (diff)
downloadinkscape-e77956b4dbd029c9f6949f81fe083606f995c624.tar.gz
inkscape-e77956b4dbd029c9f6949f81fe083606f995c624.zip
update to trunk
(bzr r12588.1.39)
Diffstat (limited to 'src/sp-shape.cpp')
-rw-r--r--src/sp-shape.cpp59
1 files changed, 48 insertions, 11 deletions
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 8b7e735e0..78135d459 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -47,7 +47,7 @@
#include "bad-uri-exception.h"
#include "xml/repr.h"
-#include "util/mathfns.h" // for triangle_area()
+#include "helper/mathfns.h" // for triangle_area()
#include "splivarot.h" // for bounding box calculation
@@ -126,6 +126,7 @@ Inkscape::XML::Node* SPShape::write(Inkscape::XML::Document *xml_doc, Inkscape::
}
void SPShape::update(SPCtx* ctx, guint flags) {
+ // std::cout << "SPShape::update(): " << (getId()?getId():"null") << std::endl;
SPLPEItem::update(ctx, flags);
/* This stanza checks that an object's marker style agrees with
@@ -145,7 +146,15 @@ void SPShape::update(SPCtx* ctx, guint flags) {
for (SPItemView *v = ((SPItem *) (this))->display; v != NULL; v = v->next) {
Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem);
- sh->setStyle(this->style);
+ if (hasMarkers()) {
+ this->context_style = this->style;
+ sh->setStyle(this->style, this->context_style);
+ // Done at end:
+ // sh->setChildrenStyle(this->context_style); //Resolve 'context-xxx' in children.
+ } else if (this->parent) {
+ this->context_style = this->parent->context_style;
+ sh->setStyle(this->style, this->context_style);
+ }
}
}
}
@@ -163,6 +172,7 @@ void SPShape::update(SPCtx* ctx, guint flags) {
}
if (this->hasMarkers ()) {
+
/* Dimension marker views */
for (SPItemView *v = this->display; v != NULL; v = v->next) {
if (!v->arenaitem->key()) {
@@ -182,6 +192,13 @@ void SPShape::update(SPCtx* ctx, guint flags) {
for (SPItemView *v = this->display; v != NULL; v = v->next) {
sp_shape_update_marker_view (this, v->arenaitem);
}
+
+ // Marker selector needs this here or marker previews are not rendered.
+ for (SPItemView *v = this->display; v != NULL; v = v->next) {
+ Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem);
+
+ sh->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children.
+ }
}
}
@@ -382,12 +399,23 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai)
}
void SPShape::modified(unsigned int flags) {
+ // std::cout << "SPShape::modified(): " << (getId()?getId():"null") << std::endl;
SPLPEItem::modified(flags);
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
for (SPItemView *v = this->display; v != NULL; v = v->next) {
Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem);
- sh->setStyle(this->style);
+ if (hasMarkers()) {
+ this->context_style = this->style;
+ sh->setStyle(this->style, this->context_style);
+ // Note: marker selector preview does not trigger SP_OBJECT_STYLE_MODIFIED_FLAG so
+ // this is not called when marker previews are generated, however there is code in
+ // SPShape::update() that calls this routine so we don't worry about it here.
+ sh->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children.
+ } else if (this->parent) {
+ this->context_style = this->parent->context_style;
+ sh->setStyle(this->style, this->context_style);
+ }
}
}
}
@@ -434,7 +462,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
tr = Geom::Rotate::from_degrees( 180.0 ) * tr;
} else if (_marker[i]->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(_marker[i]->orient) * Geom::Translate(transl);
+ tr = Geom::Rotate::from_degrees(_marker[i]->orient.computed) * Geom::Translate(transl);
}
if (_marker[i]->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
@@ -472,7 +500,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
if (marker->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ tr = Geom::Rotate::from_degrees(marker->orient.computed) * Geom::Translate(transl);
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
@@ -502,7 +530,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
if (marker->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ tr = Geom::Rotate::from_degrees(marker->orient.computed) * Geom::Translate(transl);
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
@@ -525,7 +553,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
if (marker->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ tr = Geom::Rotate::from_degrees(marker->orient.computed) * Geom::Translate(transl);
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
@@ -560,7 +588,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
if (marker->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
- tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
+ tr = Geom::Rotate::from_degrees(marker->orient.computed) * Geom::Translate(transl);
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
@@ -718,8 +746,11 @@ void SPShape::print(SPPrintContext* ctx) {
}
Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) {
+ // std::cout << "SPShape::show(): " << (getId()?getId():"null") << std::endl;
Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing);
- s->setStyle(this->style);
+
+ bool has_markers = this->hasMarkers();
+
s->setPath(this->_curve);
/* This stanza checks that an object's marker style agrees with
@@ -731,7 +762,7 @@ Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*
sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value);
}
- if (this->hasMarkers ()) {
+ if (has_markers) {
/* provide key and dimension the marker views */
if (!s->key()) {
s->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY));
@@ -747,8 +778,14 @@ Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*
/* Update marker views */
sp_shape_update_marker_view (this, s);
- }
+ this->context_style = this->style;
+ s->setStyle(this->style, this->context_style);
+ s->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children.
+ } else if (this->parent) {
+ this->context_style = this->parent->context_style;
+ s->setStyle(this->style, this->context_style);
+ }
return s;
}