diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2013-09-26 20:25:56 +0000 |
|---|---|---|
| committer | Johan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl> | 2013-09-26 20:25:56 +0000 |
| commit | 90c7ce56fa03e18efa7296d12c6ca48f8e322e60 (patch) | |
| tree | 00941fe9b988c90c21e618d20fa55c0346d52da3 /src | |
| parent | Fix for Bug #1229605 (inkscape crashes when canceled import pdf). (diff) | |
| download | inkscape-90c7ce56fa03e18efa7296d12c6ca48f8e322e60.tar.gz inkscape-90c7ce56fa03e18efa7296d12c6ca48f8e322e60.zip | |
random code cleanup
(bzr r12596)
Diffstat (limited to 'src')
| -rw-r--r-- | src/lpe-tool-context.cpp | 4 | ||||
| -rw-r--r-- | src/sp-ellipse.cpp | 10 | ||||
| -rw-r--r-- | src/sp-shape.cpp | 47 | ||||
| -rw-r--r-- | src/sp-spiral.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 2 |
5 files changed, 27 insertions, 38 deletions
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 14a536b7d..bcf58aaf3 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -410,7 +410,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { if (SP_IS_PATH(i->data)) { path = SP_PATH(i->data); - curve = SP_SHAPE(path)->getCurve(); + curve = path->getCurve(); Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(curve->get_pathvector()); canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), ""); if (!show) @@ -453,7 +453,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc) ++i ) { SPPath *path = i->first; - SPCurve *curve = SP_SHAPE(path)->getCurve(); + SPCurve *curve = path->getCurve(); Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); Inkscape::Util::Unit unit; if (prefs->getString("/tools/lpetool/unit").compare("")) { diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 55f308c6b..fc78b9777 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -275,8 +275,6 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, double cx = this->cx.computed; double cy = this->cy.computed; - Geom::Point pt; - // Snap to the 4 quadrant points of the this, but only if the arc // spans far enough to include them if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) { @@ -284,7 +282,7 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, for (angle = 0; angle < SP_2PI; angle += M_PI_2) { if (angle >= this->start && angle <= this->end) { - pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2dt; + Geom::Point pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)); } } @@ -295,7 +293,7 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT); if (c1 || c2) { - pt = Geom::Point(cx, cy) * i2dt; + Geom::Point pt = Geom::Point(cx, cy) * i2dt; if (c1) { p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); @@ -310,13 +308,13 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && slice) { // Add the start point, if it's not coincident with a quadrant point if (fmod(this->start, M_PI_2) != 0.0 ) { - pt = Geom::Point(cx + cos(this->start)*rx, cy + sin(this->start)*ry) * i2dt; + Geom::Point pt = Geom::Point(cx + cos(this->start)*rx, cy + sin(this->start)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } // Add the end point, if it's not coincident with a quadrant point if (fmod(this->end, M_PI_2) != 0.0 ) { - pt = Geom::Point(cx + cos(this->end)*rx, cy + sin(this->end)*ry) * i2dt; + Geom::Point pt = Geom::Point(cx + cos(this->end)*rx, cy + sin(this->end)*ry) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } } diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 7efe28dd8..913e208aa 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -93,16 +93,13 @@ void SPShape::build(SPDocument *document, Inkscape::XML::Node *repr) { * \see SPObject::release() */ void SPShape::release() { - SPItemView *v; - int i; - - for (i = 0; i < SP_MARKER_LOC_QTY; i++) { + for (int i = 0; i < SP_MARKER_LOC_QTY; i++) { if (this->_marker[i]) { - - for (v = this->display; v != NULL; v = v->next) { + + for (SPItemView *v = this->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) this->_marker[i], v->arenaitem->key() + i); } - + this->_release_connect[i].disconnect(); this->_modified_connect[i].disconnect(); this->_marker[i] = sp_object_hunref (this->_marker[i], this); @@ -143,16 +140,14 @@ void SPShape::update(SPCtx* ctx, guint flags) { } if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - SPStyle *style = this->style; - - if (style->stroke_width.unit == SP_CSS_UNIT_PERCENT) { + if (this->style->stroke_width.unit == SP_CSS_UNIT_PERCENT) { SPItemCtx *ictx = (SPItemCtx *) ctx; double const aw = 1.0 / ictx->i2vp.descrim(); - style->stroke_width.computed = style->stroke_width.value * aw; + this->style->stroke_width.computed = this->style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (this))->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); - sh->setStyle(style); + sh->setStyle(this->style); } } } @@ -219,8 +214,7 @@ Geom::Affine sp_shape_marker_get_transform(Geom::Curve const & c1, Geom::Curve c double const angle1 = Geom::atan2(tang1); double const angle2 = Geom::atan2(tang2); - double ret_angle; - ret_angle = .5 * (angle1 + angle2); + double ret_angle = .5 * (angle1 + angle2); if ( fabs( angle2 - angle1 ) > M_PI ) { /* ret_angle is in the middle of the larger of the two sectors between angle1 and @@ -281,8 +275,6 @@ Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const & c) static void sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) { - SPStyle *style = ((SPObject *) shape)->style; - // position arguments to sp_marker_show_instance, basically counts the amount of markers. int counter[4] = {0}; @@ -300,7 +292,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) if ( shape->_marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, ai->key() + i, counter[i], m, - style->stroke_width.computed); + shape->style->stroke_width.computed); counter[i]++; } } @@ -318,7 +310,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) if ( shape->_marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, ai->key() + i, counter[i], m, - style->stroke_width.computed); + shape->style->stroke_width.computed); counter[i]++; } } @@ -338,7 +330,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) if (shape->_marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, ai->key() + i, counter[i], m, - style->stroke_width.computed); + shape->style->stroke_width.computed); counter[i]++; } } @@ -355,7 +347,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) if (shape->_marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, ai->key() + i, counter[i], m, - style->stroke_width.computed); + shape->style->stroke_width.computed); counter[i]++; } } @@ -379,7 +371,7 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) if (shape->_marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->_marker[i], ai, ai->key() + i, counter[i], m, - style->stroke_width.computed); + shape->style->stroke_width.computed); counter[i]++; } } @@ -412,9 +404,8 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox if (bboxtype == SPItem::VISUAL_BBOX) { // convert the stroke to a path and calculate that path's geometric bbox - SPStyle* style = this->style; - if (!style->stroke.isNone()) { + if (!this->style->stroke.isNone()) { Geom::PathVector *pathv = item_outline(this, true); // calculate bbox_only if (pathv) { @@ -442,7 +433,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(this->style->stroke_width.computed) * tr; } // total marker transform @@ -480,7 +471,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(this->style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr * transform; @@ -510,7 +501,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(this->style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr * transform; @@ -533,7 +524,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(this->style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr * transform; @@ -568,7 +559,7 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(this->style->stroke_width.computed) * tr; } // total marker transform diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index b9d1d11da..5d80e43fe 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -339,7 +339,6 @@ void SPSpiral::set_shape() { } Geom::Point darray[SAMPLE_SIZE + 1]; - double t; this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -365,6 +364,7 @@ void SPSpiral::set_shape() { Geom::Point hat1 = this->getTangent(this->t0); Geom::Point hat2; + double t; for (t = this->t0; t < (1.0 - tstep);) { this->fitAndDraw(c, dstep, darray, hat1, hat2, &t); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 673eba97a..6e14e8e97 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1328,7 +1328,7 @@ void PathManipulator::_setGeometry() if (_path->getRepr()->attribute("inkscape:original-d")) _path->set_original_curve(_spcurve, false, false); else - SP_SHAPE(_path)->setCurve(_spcurve, false); + _path->setCurve(_spcurve, false); } } |
