From 85ce04a12446a8a1058aa92d18e24c911963610b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 24 Sep 2013 02:53:21 +0200 Subject: Refactored SPGenericEllipse::set_shape (bzr r11608.1.127) --- src/sp-ellipse.cpp | 80 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 7c6066054..a3e1a475a 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -26,6 +26,7 @@ #include #include <2geom/transforms.h> #include <2geom/pathvector.h> +#include <2geom/svg-path.h> #include "document.h" #include "sp-ellipse.h" #include "preferences.h" @@ -141,6 +142,8 @@ void SPGenericEllipse::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +#include <2geom/ellipse.h> + /* fixme: Think (Lauris) */ /* Can't we use arcto in this method? */ void SPGenericEllipse::set_shape() { @@ -158,12 +161,6 @@ void SPGenericEllipse::set_shape() { return; } - double rx; - double ry; - double s; - double len; - gint slice = FALSE; - if ((this->rx.computed < 1e-18) || (this->ry.computed < 1e-18)) { return; } @@ -174,58 +171,65 @@ void SPGenericEllipse::set_shape() { sp_genericellipse_normalize(this); - rx = this->rx.computed; - ry = this->ry.computed; - // figure out if we have a slice, guarding against rounding errors - len = fmod(this->end - this->start, SP_2PI); + double len = fmod(this->end - this->start, SP_2PI); if (len < 0.0) { len += SP_2PI; } + bool slice = false; + if (fabs(len) < 1e-8 || fabs(len - SP_2PI) < 1e-8) { - slice = FALSE; + slice = false; this->end = this->start + SP_2PI; } else { - slice = TRUE; + slice = true; } - SPCurve * curve = new SPCurve(); - curve->moveto(cos(this->start), sin(this->start)); + SPCurve *curve = NULL; + + // For simplicity, we use a circle with center (0, 0) and radius 1 for our calculations. + + if (slice) { + Geom::Point startPoint(cos(start), sin(start)); + Geom::Point endPoint(cos(end), sin(end)); + Geom::Point middlePoint = make_angle_bisector_ray(Geom::Ray(Geom::Point(), start), Geom::Ray(Geom::Point(), end)).versor(); - for (s = this->start; s < this->end; s += M_PI_2) { - double e = s + M_PI_2; + Geom::Ellipse ellipse(0, 0, 1, 1, 0); + Geom::EllipticalArc *arc = ellipse.arc(startPoint, middlePoint, endPoint); - if (e > this->end) { - e = this->end; + Geom::Path path(startPoint); + path.append(*arc); + + delete arc; + + Geom::PathBuilder pb; + pb.append(path); + + if (this->closed) { + // "pizza slice" + pb.lineTo(Geom::Point(0, 0)); + pb.closePath(); + } else { + // arc only + pb.finish(); } - len = 4*tan((e - s)/4)/3; - double x0 = cos(s); - double y0 = sin(s); - double x1 = x0 + len * cos(s + M_PI_2); - double y1 = y0 + len * sin(s + M_PI_2); - double x3 = cos(e); - double y3 = sin(e); - double x2 = x3 + len * cos(e - M_PI_2); - double y2 = y3 + len * sin(e - M_PI_2); -#ifdef ELLIPSE_VERBOSE - g_print("step %d s %f e %f coords %f %f %f %f %f %f\n", - i, s, e, x1, y1, x2, y2, x3, y3); -#endif - curve->curveto(x1,y1, x2,y2, x3,y3); - } + curve = new SPCurve(pb.peek()); + } else { + // Full ellipse + Geom::Circle circle(0, 0, 1); + Geom::PathVector path; - if (slice && this->closed) { // TODO: is this check for "ellipse->closed" necessary? - curve->lineto(0., 0.); - } + circle.getPath(path); - if (this->closed) { + curve = new SPCurve(path); curve->closepath(); } - Geom::Affine aff = Geom::Scale(rx, ry) * Geom::Translate(this->cx.computed, this->cy.computed); + // Stretching / moving the calculated shape to fit the actual dimensions. + Geom::Affine aff = Geom::Scale(rx.computed, ry.computed) * Geom::Translate(cx.computed, cy.computed); curve->transform(aff); /* Reset the shape's curve to the "original_curve" -- cgit v1.2.3 From 2f017d2ef4974eba04515b9a155656ce9f2f7822 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 24 Sep 2013 23:32:23 +0200 Subject: Refactored SPUse. (bzr r11608.1.128) --- src/object-snapper.cpp | 12 +- src/selection-chemistry.cpp | 46 +++--- src/sp-flowtext.cpp | 58 +++++++- src/sp-item-group.cpp | 90 ++++++++++- src/sp-use.cpp | 256 ++++++++++++++------------------ src/sp-use.h | 32 +++- src/ui/dialog/livepatheffect-editor.cpp | 4 +- 7 files changed, 304 insertions(+), 194 deletions(-) (limited to 'src') diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 77ba3040f..3f3f0c1bf 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -194,7 +194,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, //Geom::Affine i2doc(Geom::identity()); SPItem *root_item = (*i).item; if (SP_IS_USE((*i).item)) { - root_item = sp_use_root(SP_USE((*i).item)); + root_item = SP_USE((*i).item)->root(); } g_return_if_fail(root_item); @@ -382,8 +382,8 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, SPItem *root_item = NULL; /* We might have a clone at hand, so make sure we get the root item */ if (SP_IS_USE((*i).item)) { - i2doc = sp_use_get_root_transform(SP_USE((*i).item)); - root_item = sp_use_root(SP_USE((*i).item)); + i2doc = SP_USE((*i).item)->get_root_transform(); + root_item = SP_USE((*i).item)->root(); g_return_if_fail(root_item); } else { i2doc = (*i).item->i2doc_affine(); @@ -770,7 +770,7 @@ void Inkscape::ObjectSnapper::_clear_paths() const Geom::PathVector* Inkscape::ObjectSnapper::_getBorderPathv() const { - Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point((_snapmanager->getDocument())->getWidth(),(_snapmanager->getDocument())->getHeight())); + Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point((_snapmanager->getDocument())->getWidth().value("px"),(_snapmanager->getDocument())->getHeight().value("px"))); return _getPathvFromRect(border_rect); } @@ -787,8 +787,8 @@ Geom::PathVector* Inkscape::ObjectSnapper::_getPathvFromRect(Geom::Rect const re void Inkscape::ObjectSnapper::_getBorderNodes(std::vector *points) const { - Geom::Coord w = (_snapmanager->getDocument())->getWidth(); - Geom::Coord h = (_snapmanager->getDocument())->getHeight(); + Geom::Coord w = (_snapmanager->getDocument())->getWidth().value("px"); + Geom::Coord h = (_snapmanager->getDocument())->getHeight().value("px"); points->push_back(SnapCandidatePoint(Geom::Point(0,0), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); points->push_back(SnapCandidatePoint(Geom::Point(0,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); points->push_back(SnapCandidatePoint(Geom::Point(w,h), SNAPSOURCE_UNDEFINED, SNAPTARGET_PAGE_CORNER)); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 91b99e3f4..8a7832d2a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -499,7 +499,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) const gchar *id = old_ids[i]; SPObject *old_clone = doc->getObjectById(id); if (SP_IS_USE(old_clone)) { - SPItem *orig = sp_use_get_original(SP_USE(old_clone)); + SPItem *orig = SP_USE(old_clone)->get_original(); if (!orig) // orphaned continue; for (unsigned int j = 0; j < old_ids.size(); j++) { @@ -1104,18 +1104,21 @@ void sp_selection_cut(SPDesktop *desktop) * \pre item != NULL */ SPCSSAttr * -take_style_from_item(SPItem *item) +take_style_from_item(SPObject *object) { + // CPPIFY: + // This function should only take SPItems, but currently SPString is not an Item. + // write the complete cascaded style, context-free - SPCSSAttr *css = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS); + SPCSSAttr *css = sp_css_attr_from_object(object, SP_STYLE_FLAG_ALWAYS); if (css == NULL) return NULL; - if ((SP_IS_GROUP(item) && item->children) || - (SP_IS_TEXT(item) && item->children && item->children->next == NULL)) { + if ((SP_IS_GROUP(object) && object->children) || + (SP_IS_TEXT(object) && object->children && object->children->next == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style - for (SPObject *last_element = item->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { + for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { if ( last_element->style ) { SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET); if (temp) { @@ -1126,15 +1129,18 @@ take_style_from_item(SPItem *item) } } } - if (!(SP_IS_TEXT(item) || SP_IS_TSPAN(item) || SP_IS_TREF(item) || SP_IS_STRING(item))) { + + if (!(SP_IS_TEXT(object) || SP_IS_TSPAN(object) || SP_IS_TREF(object) || SP_IS_STRING(object))) { // do not copy text properties from non-text objects, it's confusing css = sp_css_attr_unset_text(css); } - // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive - double ex = item->i2doc_affine().descrim(); - if (ex != 1.0) { - css = sp_css_attr_scale(css, ex); + if (SP_IS_ITEM(object)) { + // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive + double ex = SP_ITEM(object)->i2doc_affine().descrim(); + if (ex != 1.0) { + css = sp_css_attr_scale(css, ex); + } } return css; @@ -1375,7 +1381,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) SPItem *item_use_first = item; while (is_use && item_use && !contains_original) { - item_use = sp_use_get_original(SP_USE(item_use)); + item_use = SP_USE(item_use)->get_original(); contains_original |= selection->includes(item_use); if (item_use == item_use_first) break; @@ -1520,7 +1526,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons // we need to cancel out the move compensation, too // find out the clone move, same as in sp_use_move_compensate - Geom::Affine parent = sp_use_get_parent_transform(SP_USE(item)); + Geom::Affine parent = SP_USE(item)->get_parent_transform(); Geom::Affine clone_move = parent.inverse() * t * parent; if (prefs_parallel) { @@ -2616,7 +2622,7 @@ sp_selection_unlink(SPDesktop *desktop) SPItem *unlink; if (SP_IS_USE(item)) { - unlink = sp_use_unlink(SP_USE(item)); + unlink = SP_USE(item)->unlink(); // Unable to unlink use (external or invalid href?) if (!unlink) { new_select = g_slist_prepend(new_select, item); @@ -2664,7 +2670,7 @@ sp_select_clone_original(SPDesktop *desktop) SPItem *original = NULL; if (SP_IS_USE(item)) { - original = sp_use_get_original(SP_USE(item)); + original = SP_USE(item)->get_original(); } else if (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) { original = sp_offset_get_source(SP_OFFSET(item)); } else if (SP_IS_TEXT_TEXTPATH(item)) { @@ -2809,7 +2815,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } // calculate the transform to be applied to objects to move them to 0,0 - Geom::Point move_p = Geom::Point(0, doc->getHeight()) - *c; + Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - *c; move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); @@ -3093,7 +3099,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // calculate the transform to be applied to objects to move them to 0,0 - Geom::Point move_p = Geom::Point(0, doc->getHeight()) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y])); + Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y])); move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); @@ -3398,7 +3404,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) res = prefs_res; } else if (0 < prefs_min) { // If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it - res = Inkscape::Util::Quantity::convert(1, "in", "px") * prefs_min / MIN(bbox->width(), bbox->height()); + res = Inkscape::Util::Quantity::convert(prefs_min, "in", "px") / MIN(bbox->width(), bbox->height()); } else { float hint_xdpi = 0, hint_ydpi = 0; Glib::ustring hint_filename; @@ -3419,8 +3425,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // The width and height of the bitmap in pixels - unsigned width = (unsigned) floor(bbox->width() * res / Inkscape::Util::Quantity::convert(1, "in", "px")); - unsigned height =(unsigned) floor(bbox->height() * res / Inkscape::Util::Quantity::convert(1, "in", "px")); + unsigned width = (unsigned) floor(bbox->width() * Inkscape::Util::Quantity::convert(res, "px", "in")); + unsigned height =(unsigned) floor(bbox->height() * Inkscape::Util::Quantity::convert(res, "px", "in")); // Find out if we have to run an external filter gchar const *run = NULL; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index c7ef579ac..88564c0ac 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -28,6 +28,7 @@ #include "text-tag-attributes.h" #include "text-chemistry.h" #include "text-editing.h" +#include "sp-text.h" #include "livarot/Shape.h" @@ -203,7 +204,7 @@ void SPFlowtext::set(unsigned int key, const gchar* value) { if ( val == NULL ) { this->par_indent = 0.0; } else { - sp_repr_get_double((Inkscape::XML::Node*)opts, "par-indent", &this->par_indent); + this->par_indent = g_ascii_strtod(val, NULL); } } @@ -280,17 +281,20 @@ void SPFlowtext::print(SPPrintContext *ctx) { this->layout.print(ctx, pbox, dbox, bbox, ctm); } +const char* SPFlowtext::displayName() { + if (SP_FLOWTEXT(this)->has_internal_frame()) { + return _("Flowed Text"); + } else { + return _("Linked Flowed Text"); + } +} + gchar* SPFlowtext::description() { Inkscape::Text::Layout const &layout = SP_FLOWTEXT(this)->layout; int const nChars = layout.iteratorToCharIndex(layout.end()); - char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : ""; - if (SP_FLOWTEXT(this)->has_internal_frame()) { - return g_strdup_printf(ngettext("Flowed text (%d character%s)", "Flowed text (%d characters%s)", nChars), nChars, trunc); - } else { - return g_strdup_printf(ngettext("Linked flowed text (%d character%s)", "Linked flowed text (%d characters%s)", nChars), nChars, trunc); - } + return g_strdup_printf(ngettext(_("(%d character%s)"), _("(%d characters%s)"), nChars), nChars, trunc); } void SPFlowtext::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { @@ -578,7 +582,7 @@ SPItem *SPFlowtext::get_frame(SPItem *after) } if ( frame && SP_IS_USE(frame) ) { - frame = sp_use_get_original(SP_USE(frame)); + frame = SP_USE(frame)->get_original(); } } return frame; @@ -645,6 +649,44 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, return ft_item; } +Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) +{ + if ((this->_optimizeScaledText && !xform.withoutTranslation().isNonzeroUniformScale()) + || (!this->_optimizeScaledText && !xform.isNonzeroUniformScale())) { + this->_optimizeScaledText = false; + return xform; + } + this->_optimizeScaledText = false; + + SPText *text = reinterpret_cast(this); + + double const ex = xform.descrim(); + if (ex == 0) { + return xform; + } + + Geom::Affine ret(xform); + ret[0] /= ex; + ret[1] /= ex; + ret[2] /= ex; + ret[3] /= ex; + + // Adjust font size + text->_adjustFontsizeRecursive (this, ex); + + // Adjust stroke width + this->adjust_stroke_width_recursive (ex); + + // Adjust pattern fill + this->adjust_pattern(xform * ret.inverse()); + + // Adjust gradient fill + this->adjust_gradient(xform * ret.inverse()); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + + return ret; +} /* Local Variables: diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 010cc5449..2becf7139 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -50,6 +50,9 @@ #include "sp-switch.h" #include "sp-defs.h" #include "verbs.h" +#include "layer-model.h" +#include "sp-textpath.h" +#include "sp-flowtext.h" using Inkscape::DocumentUndo; @@ -325,12 +328,14 @@ void SPGroup::print(SPPrintContext *ctx) { } } +const char *SPGroup::displayName() { + return _("Group"); +} + gchar *SPGroup::description() { gint len = this->getItemCount(); return g_strdup_printf( - ngettext("Group of %d object", - "Group of %d objects", - len), len); + ngettext(_("of %d object"), _("of %d objects"), len), len); } void SPGroup::set(unsigned int key, gchar const* value) { @@ -467,8 +472,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // Merging transform Geom::Affine ctrans; Geom::Affine const g(gitem->transform); - if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) && - sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) { + if (SP_IS_USE(citem) && SP_USE(citem)->get_original() && + SP_USE(citem)->get_original()->parent == SP_OBJECT(group)) { // make sure a clone's effective transform is the same as was under group ctrans = g.inverse() * citem->transform * g; } else { @@ -642,6 +647,81 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) } } +// Recursively scale child items around a point +void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p) +{ + if ( hasChildren() ) { + for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { + if ( SP_IS_ITEM(o) ) { + if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) { + SP_GROUP(o)->scaleChildItemsRec(sc, p); + } else { + SPItem *item = SP_ITEM(o); + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox) { + // Scale item + Geom::Translate const s(p); + Geom::Affine final = s.inverse() * sc * s; + + Geom::Point old_center(0,0); + if (item->isCenterSet()) { + old_center = item->getCenter(); + } + + gchar const *conn_type = NULL; + if (SP_IS_TEXT_TEXTPATH(item)) { + SP_TEXT(item)->optimizeTextpathText(); + } else if (SP_IS_FLOWTEXT(item)) { + SP_FLOWTEXT(item)->optimizeScaledText(); + } else if (SP_IS_BOX3D(item)) { + // Force recalculation from perspective + box3d_position_set(SP_BOX3D(item)); + } else if (item->getAttribute("inkscape:connector-type") != NULL + && (item->getAttribute("inkscape:connection-start") == NULL + || item->getAttribute("inkscape:connection-end") == NULL)) { + // Remove and store connector type for transform if disconnected + conn_type = item->getAttribute("inkscape:connector-type"); + item->removeAttribute("inkscape:connector-type"); + } + + if (SP_IS_PERSP3D(item)) { + persp3d_apply_affine_transformation(SP_PERSP3D(item), final); + } else if ((SP_IS_TEXT_TEXTPATH(item) || SP_IS_FLOWTEXT(item)) && !item->transform.isIdentity()) { + // Save and reset current transform + Geom::Affine tmp(item->transform); + item->transform = Geom::Affine(); + // Apply scale + item->set_i2d_affine(item->i2dt_affine() * sc); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + // Scale translation and restore original transform + tmp[4] *= sc[0]; + tmp[5] *= sc[1]; + item->doWriteTransform(item->getRepr(), tmp, NULL, true); + } else if (SP_IS_USE(item)) { + // calculate the matrix we need to apply to the clone + // to cancel its induced transform from its original + Geom::Affine move = final.inverse() * item->transform * final; + item->doWriteTransform(item->getRepr(), move, &move, true); + } else { + item->set_i2d_affine(item->i2dt_affine() * final); + item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + } + + if (conn_type != NULL) { + item->setAttribute("inkscape:connector-type", conn_type); + } + + if (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) { + item->setCenter(old_center * final); + item->updateRepr(); + } + } + } + } + } + } +} + gint SPGroup::getItemCount() { gint len = 0; for (SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 44935e61d..a558c6bf4 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -37,12 +37,6 @@ #include "sp-use.h" #include "sp-use-reference.h" -/* fixme: */ -static void sp_use_href_changed(SPObject *old_ref, SPObject *ref, SPUse *use); -static void sp_use_delete_self(SPObject *deleted, SPUse *self); - -#include "sp-factory.h" - namespace { SPObject* createUse() { return new SPUse(); @@ -51,23 +45,20 @@ namespace { bool useRegistered = SPFactory::instance().registerObject("svg:use", createUse); } -SPUse::SPUse() : SPItem() { - this->child = NULL; - +SPUse::SPUse() + : SPItem() + , child(NULL) + , href(NULL) + , ref(new SPUseReference(this)) +{ this->x.unset(); this->y.unset(); this->width.unset(SVGLength::PERCENT, 1.0, 1.0); this->height.unset(SVGLength::PERCENT, 1.0, 1.0); - this->href = NULL; - - //new (&this->_delete_connection) sigc::connection(); - //new (&this->_changed_connection) sigc::connection(); - - //new (&this->_transformed_connection) sigc::connection(); - this->ref = new SPUseReference(this); - - this->_changed_connection = this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_use_href_changed), this)); + this->_changed_connection = this->ref->changedSignal().connect( + sigc::hide(sigc::hide(sigc::mem_fun(this, &SPUse::href_changed))) + ); } SPUse::~SPUse() { @@ -79,11 +70,6 @@ SPUse::~SPUse() { this->ref->detach(); delete this->ref; this->ref = 0; - - //this->_delete_connection.~connection(); - //this->_changed_connection.~connection(); - - //this->_transformed_connection.~connection(); } void SPUse::build(SPDocument *document, Inkscape::XML::Node *repr) { @@ -195,12 +181,8 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM Geom::OptRect SPUse::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) { Geom::OptRect bbox; - if (this->child && SP_IS_ITEM(this->child)) { - SPItem *child = SP_ITEM(this->child); - Geom::Affine const ct( child->transform - * Geom::Translate(this->x.computed, - this->y.computed) - * transform ); + if (this->child) { + Geom::Affine const ct(child->transform * Geom::Translate(this->x.computed, this->y.computed) * transform ); bbox = child->bounds(bboxtype, ct); } @@ -217,8 +199,8 @@ void SPUse::print(SPPrintContext* ctx) { translated = true; } - if (this->child && SP_IS_ITEM(this->child)) { - SP_ITEM(this->child)->invoke_print(ctx); + if (this->child) { + this->child->invoke_print(ctx); } if (translated) { @@ -226,12 +208,18 @@ void SPUse::print(SPPrintContext* ctx) { } } +const char* SPUse::displayName() { + if (this->child && SP_IS_SYMBOL( this->child )) { + return _("Symbol"); + } + + return _("Clone"); +} + gchar* SPUse::description() { if (this->child) { if( SP_IS_SYMBOL( this->child ) ) { - char *symbol_desc = SP_ITEM(this->child)->title(); - return g_strdup_printf(_("'%s' Symbol"), symbol_desc ); - g_free(symbol_desc); + return g_strdup_printf(_("called %s"), this->child->title()); } static unsigned recursion_depth = 0; @@ -245,15 +233,15 @@ gchar* SPUse::description() { } ++recursion_depth; - char *child_desc = SP_ITEM(this->child)->getDetailedDescription(); + char *child_desc = this->child->detailedDescription(); --recursion_depth; - char *ret = g_strdup_printf(_("Clone of: %s"), child_desc); + char *ret = g_strdup_printf(_("of: %s"), child_desc); g_free(child_desc); return ret; } else { - return g_strdup(_("Orphaned clone")); + return g_strdup(_("[orphaned]")); } } @@ -263,7 +251,8 @@ Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key, ai->setStyle(this->style); if (this->child) { - Inkscape::DrawingItem *ac = SP_ITEM(this->child)->invoke_show(drawing, key, flags); + Inkscape::DrawingItem *ac = this->child->invoke_show(drawing, key, flags); + if (ac) { ai->prependChild(ac); } @@ -277,7 +266,7 @@ Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key, void SPUse::hide(unsigned int key) { if (this->child) { - SP_ITEM(this->child)->invoke_hide(key); + this->child->invoke_hide(key); } // SPItem::onHide(key); @@ -292,38 +281,42 @@ void SPUse::hide(unsigned int key) { * Note that the returned is the clone object, i.e. the child of an SPUse (of the argument one for * the trivial case) and not the "true original". */ -SPItem * -sp_use_root(SPUse *use) -{ - SPObject *orig = use->child; +SPItem *SPUse::root() { + SPItem *orig = this->child; + while (orig && SP_IS_USE(orig)) { orig = SP_USE(orig)->child; } - if (!orig || !SP_IS_ITEM(orig)) + + if (!orig) { return NULL; - return SP_ITEM(orig); + } + + return orig; } /** * Returns the effective transform that goes from the ultimate original to given SPUse, both ends * included. */ -Geom::Affine -sp_use_get_root_transform(SPUse *use) -{ +Geom::Affine SPUse::get_root_transform() { //track the ultimate source of a chain of uses - SPObject *orig = use->child; + SPObject *orig = this->child; + GSList *chain = NULL; - chain = g_slist_prepend(chain, use); + chain = g_slist_prepend(chain, this); + while (SP_IS_USE(orig)) { chain = g_slist_prepend(chain, orig); orig = SP_USE(orig)->child; } + chain = g_slist_prepend(chain, orig); - //calculate the accummulated transform, starting from the original + // calculate the accummulated transform, starting from the original Geom::Affine t(Geom::identity()); + for (GSList *i = chain; i != NULL; i = i->next) { SPItem *i_tem = SP_ITEM(i->data); @@ -332,6 +325,7 @@ sp_use_get_root_transform(SPUse *use) // represent the values of the x and y attributes on the 'use' element." - http://www.w3.org/TR/SVG11/struct.html#UseElement if (SP_IS_USE(i_tem)) { SPUse *i_use = SP_USE(i_tem); + if ((i_use->x._set && i_use->x.computed != 0) || (i_use->y._set && i_use->y.computed != 0)) { t = t * Geom::Translate(i_use->x._set ? i_use->x.computed : 0, i_use->y._set ? i_use->y.computed : 0); } @@ -348,16 +342,14 @@ sp_use_get_root_transform(SPUse *use) * Returns the transform that leads to the use from its immediate original. * Does not inlcude the original's transform if any. */ -Geom::Affine -sp_use_get_parent_transform(SPUse *use) -{ +Geom::Affine SPUse::get_parent_transform() { Geom::Affine t(Geom::identity()); - if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - t *= Geom::Translate(use->x._set ? use->x.computed : 0, - use->y._set ? use->y.computed : 0); + + if ((this->x._set && this->x.computed != 0) || (this->y._set && this->y.computed != 0)) { + t *= Geom::Translate(this->x._set ? this->x.computed : 0, this->y._set ? this->y.computed : 0); } - t *= SP_ITEM(use)->transform; + t *= this->transform; return t; } @@ -366,17 +358,15 @@ sp_use_get_parent_transform(SPUse *use) * that the clone stays unmoved or moves in parallel (depending on user setting) regardless of the * clone's transform. */ -static void -sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self) -{ +void SPUse::move_compensate(Geom::Affine const *mp) { // the clone is orphaned; or this is not a real use, but a clone of another use; // we skip it, otherwise duplicate compensation will occur - if (self->cloned) { + if (this->cloned) { return; } // never compensate uses which are used in flowtext - if (self->parent && SP_IS_FLOWREGION(self->parent)) { + if (this->parent && SP_IS_FLOWREGION(this->parent)) { return; } @@ -393,9 +383,9 @@ sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self return; // restore item->transform field from the repr, in case it was changed by seltrans - self->readAttr ("transform"); + this->readAttr ("transform"); - Geom::Affine t = sp_use_get_parent_transform(self); + Geom::Affine t = this->get_parent_transform(); Geom::Affine clone_move = t.inverse() * m * t; // calculate the compensation matrix and the advertized movement matrix @@ -411,77 +401,63 @@ sp_use_move_compensate(Geom::Affine const *mp, SPItem */*original*/, SPUse *self } // commit the compensation - self->transform *= clone_move; - self->doWriteTransform(self->getRepr(), self->transform, &advertized_move); - self->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->transform *= clone_move; + this->doWriteTransform(this->getRepr(), this->transform, &advertized_move); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -static void -sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) -{ - SPItem *item = SP_ITEM(use); - - use->_delete_connection.disconnect(); - use->_transformed_connection.disconnect(); +void SPUse::href_changed() { + this->_delete_connection.disconnect(); + this->_transformed_connection.disconnect(); - if (use->child) { - use->detach(use->child); - use->child = NULL; + if (this->child) { + this->detach(this->child); + this->child = NULL; } - if (use->href) { - SPItem *refobj = use->ref->getObject(); + if (this->href) { + SPItem *refobj = this->ref->getObject(); + if (refobj) { Inkscape::XML::Node *childrepr = refobj->getRepr(); -// GType type = sp_repr_type_lookup(childrepr); -// g_return_if_fail(type > G_TYPE_NONE); -// if (g_type_is_a(type, SP_TYPE_ITEM)) { -// use->child = (SPObject*) g_object_new(type, 0); -// use->attach(use->child, use->lastChild()); -// sp_object_unref(use->child, use); -// (use->child)->invoke_build(use->document, childrepr, TRUE); -// -// for (SPItemView *v = item->display; v != NULL; v = v->next) { -// Inkscape::DrawingItem *ai; -// ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags); -// if (ai) { -// v->arenaitem->prependChild(ai); -// } -// } -// } - SPObject* obj = SPFactory::instance().createObject(NodeTraits::get_type_string(*childrepr)); + if (SP_IS_ITEM(obj)) { - use->child = obj; + this->child = SP_ITEM(obj); + + this->attach(this->child, this->lastChild()); + sp_object_unref(this->child, this); - use->attach(use->child, use->lastChild()); - sp_object_unref(use->child, use); - (use->child)->invoke_build(use->document, childrepr, TRUE); + this->child->invoke_build(this->document, childrepr, TRUE); + + for (SPItemView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingItem *ai = this->child->invoke_show(v->arenaitem->drawing(), v->key, v->flags); - for (SPItemView *v = item->display; v != NULL; v = v->next) { - Inkscape::DrawingItem *ai; - ai = SP_ITEM(use->child)->invoke_show(v->arenaitem->drawing(), v->key, v->flags); if (ai) { v->arenaitem->prependChild(ai); } } } else { delete obj; + g_warning("Tried to create svg:use from invalid object"); } - use->_delete_connection = refobj->connectDelete(sigc::bind(sigc::ptr_fun(&sp_use_delete_self), use)); - use->_transformed_connection = SP_ITEM(refobj)->connectTransformed(sigc::bind(sigc::ptr_fun(&sp_use_move_compensate), use)); + this->_delete_connection = refobj->connectDelete( + sigc::hide(sigc::mem_fun(this, &SPUse::delete_self)) + ); + + this->_transformed_connection = refobj->connectTransformed( + sigc::hide(sigc::mem_fun(this, &SPUse::move_compensate)) + ); } } } -static void -sp_use_delete_self(SPObject */*deleted*/, SPUse *self) -{ +void SPUse::delete_self() { // always delete uses which are used in flowtext - if (self->parent && SP_IS_FLOWREGION(self->parent)) { - self->deleteObject(); + if (this->parent && SP_IS_FLOWREGION(this->parent)) { + this->deleteObject(); return; } @@ -490,9 +466,9 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self) SP_CLONE_ORPHANS_UNLINK); if (mode == SP_CLONE_ORPHANS_UNLINK) { - sp_use_unlink(self); + this->unlink(); } else if (mode == SP_CLONE_ORPHANS_DELETE) { - self->deleteObject(); + this->deleteObject(); } } @@ -509,7 +485,7 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setStyle(this->style); } @@ -540,14 +516,10 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { sp_object_ref(this->child); if (flags || (this->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - if (SP_IS_ITEM(this->child)) { - SPItem const &chi = *SP_ITEM(this->child); - cctx.i2doc = chi.transform * ictx->i2doc; - cctx.i2vp = chi.transform * ictx->i2vp; - this->child->updateDisplay((SPCtx *)&cctx, flags); - } else { - this->child->updateDisplay(ctx, flags); - } + SPItem const &chi = *SP_ITEM(this->child); + cctx.i2doc = chi.transform * ictx->i2doc; + cctx.i2vp = chi.transform * ictx->i2vp; + this->child->updateDisplay((SPCtx *)&cctx, flags); } sp_object_unref(this->child); @@ -569,14 +541,12 @@ void SPUse::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM(this)->display; v != NULL; v = v->next) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast(v->arenaitem); g->setStyle(this->style); } } - SPObject *child = this->child; - if (child) { sp_object_ref(child); @@ -588,30 +558,26 @@ void SPUse::modified(unsigned int flags) { } } -SPItem *sp_use_unlink(SPUse *use) -{ - if (!use) { - return NULL; - } +SPItem *SPUse::unlink() { + Inkscape::XML::Node *repr = this->getRepr(); - Inkscape::XML::Node *repr = use->getRepr(); if (!repr) { return NULL; } Inkscape::XML::Node *parent = repr->parent(); - SPDocument *document = use->document; + SPDocument *document = this->document; Inkscape::XML::Document *xml_doc = document->getReprDoc(); // Track the ultimate source of a chain of uses. - SPItem *orig = sp_use_root(use); + SPItem *orig = this->root(); if (!orig) { return NULL; } // Calculate the accumulated transform, starting from the original. - Geom::Affine t = sp_use_get_root_transform(use); + Geom::Affine t = this->get_root_transform(); Inkscape::XML::Node *copy = NULL; @@ -634,19 +600,19 @@ SPItem *sp_use_unlink(SPUse *use) // Merge style from the use. SPStyle *unli_sty = unlinked->style; - SPStyle const *use_sty = use->style; + SPStyle const *use_sty = this->style; sp_style_merge_from_dying_parent(unli_sty, use_sty); sp_style_merge_from_parent(unli_sty, unlinked->parent->style); unlinked->updateRepr(); // Hold onto our SPObject and repr for now. - sp_object_ref(use, NULL); + sp_object_ref(this, NULL); Inkscape::GC::anchor(repr); // Remove ourselves, not propagating delete events to avoid a // chain-reaction with other elements that might reference us. - use->deleteObject(false); + this->deleteObject(false); // Give the copy our old id and let go of our old repr. copy->setAttribute("id", repr->attribute("id")); @@ -660,10 +626,11 @@ SPItem *sp_use_unlink(SPUse *use) copy->setAttribute("inkscape:tile-cy", NULL); // Establish the succession and let go of our object. - use->setSuccessor(unlinked); - sp_object_unref(use, NULL); + this->setSuccessor(unlinked); + sp_object_unref(this, NULL); SPItem *item = SP_ITEM(unlinked); + // Set the accummulated transform. { Geom::Affine nomove(Geom::identity()); @@ -674,21 +641,18 @@ SPItem *sp_use_unlink(SPUse *use) return item; } -SPItem *sp_use_get_original(SPUse *use) -{ +SPItem *SPUse::get_original() { SPItem *ref = NULL; - if (use) { - if (use->ref){ - ref = use->ref->getObject(); + if (this->ref){ + ref = this->ref->getObject(); } - } return ref; } void SPUse::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { - SPItem *root = sp_use_root(this); + SPItem *root = this->root(); if (!root) { return; diff --git a/src/sp-use.h b/src/sp-use.h index 37ff2cf66..6a83c384f 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -30,7 +30,7 @@ public: // item built from the original's repr (the visible clone) // relative to the SPUse itself, it is treated as a child, similar to a grouped item relative to its group - SPObject *child; + SPItem *child; // SVG attrs SVGLength x; @@ -57,17 +57,35 @@ public: virtual void modified(unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); + virtual const char* displayName(); virtual gchar* description(); virtual void print(SPPrintContext *ctx); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs); -}; -SPItem *sp_use_unlink (SPUse *use); -SPItem *sp_use_get_original (SPUse *use); -Geom::Affine sp_use_get_parent_transform (SPUse *use); -Geom::Affine sp_use_get_root_transform(SPUse *use); + SPItem *root(); + + SPItem *unlink(); + SPItem *get_original(); + Geom::Affine get_parent_transform(); + Geom::Affine get_root_transform(); + +private: + void href_changed(); + void move_compensate(Geom::Affine const *mp); + void delete_self(); +}; -SPItem *sp_use_root(SPUse *use); #endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 6dc9c1ee3..0102977e4 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -296,7 +296,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) } } else if ( SP_IS_USE(item) ) { // test whether linked object is supported by the CLONE_ORIGINAL LPE - SPItem *orig = sp_use_get_original( SP_USE(item) ); + SPItem *orig = SP_USE(item)->get_original(); if ( SP_IS_SHAPE(orig) || SP_IS_TEXT(orig) ) { @@ -433,7 +433,7 @@ LivePathEffectEditor::onAdd() // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path // test whether linked object is supported by the CLONE_ORIGINAL LPE - SPItem *orig = sp_use_get_original( SP_USE(item) ); + SPItem *orig = SP_USE(item)->get_original(); if ( SP_IS_SHAPE(orig) || SP_IS_TEXT(orig) ) { -- cgit v1.2.3 From 34f62f6df3f4a18f6ea25c3a1b63e6b47fdc7c5d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 25 Sep 2013 00:26:56 +0200 Subject: Refactored SPSpiral. (bzr r11608.1.130) --- src/sp-spiral.cpp | 95 +++++++++++++++++++++++++++---------------------------- src/sp-spiral.h | 13 ++++---- 2 files changed, 52 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 0c5ef253f..6a22059a8 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -38,14 +38,16 @@ namespace { bool spiralRegistered = SPFactory::instance().registerObject("spiral", createSpiral); } -SPSpiral::SPSpiral() : SPShape() { - this->cx = 0.0; - this->cy = 0.0; - this->exp = 1.0; - this->revo = 3.0; - this->rad = 1.0; - this->arg = 0.0; - this->t0 = 0.0; +SPSpiral::SPSpiral() + : SPShape() + , cx(0) + , cy(0) + , exp(1) + , revo(3) + , rad(1) + , arg(0) + , t0(0) +{ } SPSpiral::~SPSpiral() { @@ -85,11 +87,12 @@ Inkscape::XML::Node* SPSpiral::write(Inkscape::XML::Document *xml_doc, Inkscape: // make sure the curve is rebuilt with all up-to-date parameters this->set_shape(); - //Nulls might be possible if this called iteratively + // Nulls might be possible if this called iteratively if (!this->_curve) { //g_warning("sp_spiral_write(): No path to copy\n"); return NULL; } + char *d = sp_svg_write_path(this->_curve->get_pathvector()); repr->setAttribute("d", d); g_free(d); @@ -198,24 +201,21 @@ void SPSpiral::set(unsigned int key, gchar const* value) { } void SPSpiral::update(SPCtx *ctx, guint flags) { - SPSpiral* object = this; - if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - reinterpret_cast(object)->set_shape(); + this->set_shape(); } SPShape::update(ctx, flags); } void SPSpiral::update_patheffect(bool write) { - SPSpiral* shape = this; - this->set_shape(); if (write) { - Inkscape::XML::Node *repr = shape->getRepr(); - if ( shape->_curve != NULL ) { - gchar *str = sp_svg_write_path(shape->_curve->get_pathvector()); + Inkscape::XML::Node *repr = this->getRepr(); + + if ( this->_curve != NULL ) { + gchar *str = sp_svg_write_path(this->_curve->get_pathvector()); repr->setAttribute("d", str); g_free(str); } else { @@ -223,7 +223,7 @@ void SPSpiral::update_patheffect(bool write) { } } - shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } const char* SPSpiral::displayName() { @@ -233,7 +233,7 @@ const char* SPSpiral::displayName() { gchar* SPSpiral::description() { // TRANSLATORS: since turn count isn't an integer, please adjust the // string as needed to deal with an localized plural forms. - return g_strdup_printf (_("with %3f turns"), SP_SPIRAL(this)->revo); + return g_strdup_printf (_("with %3f turns"), this->revo); } /** @@ -323,18 +323,15 @@ void SPSpiral::fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom:: } void SPSpiral::set_shape() { - SPSpiral *spiral = this; - SPSpiral* shape = spiral; - - if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) { + if (sp_lpe_item_has_broken_path_effect(this)) { g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE"); - if (shape->getRepr()->attribute("d")) { + if (this->getRepr()->attribute("d")) { // unconditionally read the curve from d, if any, to preserve appearance - Geom::PathVector pv = sp_svg_read_pathv(shape->getRepr()->attribute("d")); + Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d")); SPCurve *cold = new SPCurve(pv); - shape->setCurveInsync( cold, TRUE); - shape->setCurveBeforeLPE( cold ); + this->setCurveInsync( cold, TRUE); + this->setCurveBeforeLPE( cold ); cold->unref(); } @@ -344,51 +341,51 @@ void SPSpiral::set_shape() { Geom::Point darray[SAMPLE_SIZE + 1]; double t; - spiral->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); SPCurve *c = new SPCurve (); #ifdef SPIRAL_VERBOSE g_print ("cx=%g, cy=%g, exp=%g, revo=%g, rad=%g, arg=%g, t0=%g\n", - spiral->cx, - spiral->cy, - spiral->exp, - spiral->revo, - spiral->rad, - spiral->arg, - spiral->t0); + this->cx, + this->cy, + this->exp, + this->revo, + this->rad, + this->arg, + this->t0); #endif /* Initial moveto. */ - c->moveto(spiral->getXY(spiral->t0)); + c->moveto(this->getXY(this->t0)); - double const tstep = SAMPLE_STEP / spiral->revo; + double const tstep = SAMPLE_STEP / this->revo; double const dstep = tstep / (SAMPLE_SIZE - 1); - Geom::Point hat1 = spiral->getTangent(spiral->t0); + Geom::Point hat1 = this->getTangent(this->t0); Geom::Point hat2; - for (t = spiral->t0; t < (1.0 - tstep);) { - spiral->fitAndDraw(c, dstep, darray, hat1, hat2, &t); + for (t = this->t0; t < (1.0 - tstep);) { + this->fitAndDraw(c, dstep, darray, hat1, hat2, &t); hat1 = -hat2; } if ((1.0 - t) > SP_EPSILON) { - spiral->fitAndDraw(c, (1.0 - t) / (SAMPLE_SIZE - 1.0), darray, hat1, hat2, &t); + this->fitAndDraw(c, (1.0 - t) / (SAMPLE_SIZE - 1.0), darray, hat1, hat2, &t); } /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ - shape->setCurveInsync( c, TRUE); - shape->setCurveBeforeLPE( c ); + this->setCurveInsync( c, TRUE); + this->setCurveBeforeLPE( c ); - if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) { + if (sp_lpe_item_has_path_effect(this) && sp_lpe_item_path_effects_enabled(this)) { SPCurve *c_lpe = c->copy(); - bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe); + bool success = sp_lpe_item_perform_path_effect(this, c_lpe); if (success) { - shape->setCurveInsync( c_lpe, TRUE); + this->setCurveInsync( c_lpe, TRUE); } c_lpe->unref(); @@ -593,17 +590,17 @@ bool SPSpiral::isInvalid() const { if (rad < 0.0 || rad > SP_HUGE) { g_print("rad(t=0)=%g\n", rad); - return TRUE; + return true; } this->getPolar(1.0, &rad, NULL); if (rad < 0.0 || rad > SP_HUGE) { g_print("rad(t=1)=%g\n", rad); - return TRUE; + return true; } - return FALSE; + return false; } /* diff --git a/src/sp-spiral.h b/src/sp-spiral.h index a81b4a3dd..4e067981b 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -20,8 +20,8 @@ #define SP_HUGE 1e5 #define SPIRAL_TOLERANCE 3.0 -#define SAMPLE_STEP (1.0/4.0) ///< step per 2PI -#define SAMPLE_SIZE 8 ///< sample size per one bezier +#define SAMPLE_STEP (1.0/4.0) ///< step per 2PI +#define SAMPLE_SIZE 8 ///< sample size per one bezier #define SP_SPIRAL(obj) (dynamic_cast((SPObject*)obj)) @@ -61,11 +61,6 @@ public: bool isInvalid() const; -//private: - Geom::Point getTangent(gdouble t) const; - - void fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const; - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void update(SPCtx *ctx, guint flags); @@ -77,6 +72,10 @@ public: virtual void set_shape(); virtual void update_patheffect(bool write); + +private: + Geom::Point getTangent(gdouble t) const; + void fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const; }; #endif // SEEN_SP_SPIRAL_H -- cgit v1.2.3 From 22548e97b7fd38308c9aacea4c865491d84562a6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 25 Sep 2013 00:47:22 +0200 Subject: Simplified some in-code circle creation. (bzr r11608.1.131) --- src/dropper-context.cpp | 17 ++++++++--------- src/dyna-draw-context.cpp | 15 +++++---------- src/spray-context.cpp | 14 ++++++-------- src/tweak-context.cpp | 14 ++++++-------- 4 files changed, 25 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index d513dd587..dcb1ab66c 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -19,6 +19,7 @@ #include #include #include <2geom/transforms.h> +#include <2geom/circle.h> #include "macros.h" #include "display/canvas-bpath.h" @@ -92,16 +93,14 @@ SPDropperContext::~SPDropperContext() { void SPDropperContext::setup() { SPEventContext::setup(); - /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ - SPCurve *c = new SPCurve(); - const double C1 = 0.552; - c->moveto(-1,0); - c->curveto(-1, C1, -C1, 1, 0, 1 ); - c->curveto(C1, 1, 1, C1, 1, 0 ); - c->curveto(1, -C1, C1, -1, 0, -1 ); - c->curveto(-C1, -1, -1, -C1, -1, 0 ); - c->closepath(); + /* TODO: have a look at SPDynaDrawContext::setup where the same is done.. generalize? */ + Geom::PathVector path; + Geom::Circle(0, 0, 1).getPath(path); + + SPCurve *c = new SPCurve(path); + this->area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c); + c->unref(); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->area), 0x00000000,(SPWindRule)0); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 3e35c0ac1..01f71f76a 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -38,6 +38,7 @@ #include <2geom/math-utils.h> #include <2geom/pathvector.h> #include <2geom/bezier-utils.h> +#include <2geom/circle.h> #include "display/curve.h" #include #include "macros.h" @@ -151,17 +152,11 @@ void SPDynaDrawContext::setup() { g_signal_connect(G_OBJECT(this->currentshape), "event", G_CALLBACK(sp_desktop_root_handler), this->desktop); { - /* TODO: this can be done either with an arcto, and should maybe also be put in a general file (other tools use this as well) */ - SPCurve *c = new SPCurve(); + /* TODO: have a look at SPDropperContext::setup where the same is done.. generalize? */ + Geom::PathVector path; + Geom::Circle(0, 0, 1).getPath(path); - const double C1 = 0.552; - - c->moveto(-1,0); - c->curveto(-1, C1, -C1, 1, 0, 1 ); - c->curveto(C1, 1, 1, C1, 1, 0 ); - c->curveto(1, -C1, C1, -1, 0, -1 ); - c->curveto(-C1, -1, -1, -C1, -1, 0 ); - c->closepath(); + SPCurve *c = new SPCurve(path); this->hatch_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c); diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 08dc59bce..fd9aff196 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -55,6 +55,7 @@ #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" +#include <2geom/circle.h> #include <2geom/transforms.h> #include "preferences.h" #include "style.h" @@ -212,14 +213,11 @@ void SPSprayContext::setup() { { /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ - SPCurve *c = new SPCurve(); - const double C1 = 0.552; - c->moveto(-1,0); - c->curveto(-1, C1, -C1, 1, 0, 1 ); - c->curveto(C1, 1, 1, C1, 1, 0 ); - c->curveto(1, -C1, C1, -1, 0, -1 ); - c->curveto(-C1, -1, -1, -C1, -1, 0 ); - c->closepath(); + Geom::PathVector path; + Geom::Circle(0, 0, 1).getPath(path); + + SPCurve *c = new SPCurve(path); + this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c); c->unref(); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0); diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 65106e651..410ea4000 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -74,6 +74,7 @@ #include "display/curve.h" #include "livarot/Shape.h" #include <2geom/transforms.h> +#include <2geom/circle.h> #include "preferences.h" #include "style.h" #include "box3d.h" @@ -271,14 +272,11 @@ void SPTweakContext::setup() { { /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ - SPCurve *c = new SPCurve(); - const double C1 = 0.552; - c->moveto(-1,0); - c->curveto(-1, C1, -C1, 1, 0, 1 ); - c->curveto(C1, 1, 1, C1, 1, 0 ); - c->curveto(1, -C1, C1, -1, 0, -1 ); - c->curveto(-C1, -1, -1, -C1, -1, 0 ); - c->closepath(); + Geom::PathVector path; + Geom::Circle(0, 0, 1).getPath(path); + + SPCurve *c = new SPCurve(path); + this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c); c->unref(); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0); -- cgit v1.2.3 From 04966dbfbdc8b43e9a02fd939a511be93c6fe9f5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 26 Sep 2013 21:25:44 +0200 Subject: Fix for Bug #1229605 (inkscape crashes when canceled import pdf). Fixed bugs: - https://launchpad.net/bugs/1229605 (bzr r12595) --- src/file.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index b19fe21ff..e0675e8cf 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1143,7 +1143,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, Inkscape::Extension::Extension *key) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - + bool cancelled = false; + //DEBUG_MESSAGE( fileImport, "file_import( in_doc:%p uri:[%s], key:%p", in_doc, uri, key ); SPDocument *doc; try { @@ -1152,6 +1153,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, doc = NULL; } catch (Inkscape::Extension::Input::open_failed &e) { doc = NULL; + } catch (Inkscape::Extension::Input::open_cancelled &e) { + doc = NULL; + cancelled = true; } if (doc != NULL) { @@ -1248,7 +1252,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, DocumentUndo::done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); return new_obj; - } else { + } else if (!cancelled) { gchar *text = g_strdup_printf(_("Failed to load the requested file %s"), uri.c_str()); sp_ui_error_dialog(text); g_free(text); -- cgit v1.2.3 From 90c7ce56fa03e18efa7296d12c6ca48f8e322e60 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 26 Sep 2013 22:25:56 +0200 Subject: random code cleanup (bzr r12596) --- src/lpe-tool-context.cpp | 4 ++-- src/sp-ellipse.cpp | 10 ++++----- src/sp-shape.cpp | 47 ++++++++++++++++------------------------ src/sp-spiral.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 2 +- 5 files changed, 27 insertions(+), 38 deletions(-) (limited to 'src') 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 > 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 > 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 &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 &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 &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 &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(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); } } -- cgit v1.2.3 From 79213831ab8c63a482a86527065d27102c6e19ce Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 26 Sep 2013 22:32:45 +0200 Subject: cppcheck (bzr r12597) --- src/libuemf/uemf_print.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c index 4ea9620cf..b4e1753c6 100644 --- a/src/libuemf/uemf_print.c +++ b/src/libuemf/uemf_print.c @@ -407,7 +407,7 @@ void extlogpen_print( printf("elpStyleEntry:"); elpStyleEntry = (uint32_t *) elp->elpStyleEntry; for(i=0;ielpNumEntries;i++){ - printf("%d:%u ",i,elpStyleEntry[i]); + printf("%u:%u ",i,elpStyleEntry[i]); } } } @@ -484,7 +484,7 @@ void rgndata_print( if(rd->rdh.nCount){ rects = (PU_RECTL) &(rd->Buffer); for(i=0;irdh.nCount;i++){ - printf("%d:",i); rectl_print(rects[i]); + printf("%u:",i); rectl_print(rects[i]); } } } @@ -616,7 +616,7 @@ void core1_print(const char *name, const char *contents){ printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;icptl; i++){ - printf("[%d]:",i); pointl_print(pEmr->aptl[i]); + printf("[%u]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); } @@ -631,13 +631,13 @@ void core2_print(const char *name, const char *contents){ printf(" cptl: %d\n",pEmr->cptl ); printf(" Counts: "); for(i=0;inPolys; i++){ - printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); PU_POINTL paptl = (PU_POINTL)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); printf(" Points: "); for(i=0;icptl; i++){ - printf(" [%d]:",i); pointl_print(paptl[i]); + printf(" [%u]:",i); pointl_print(paptl[i]); } printf("\n"); } @@ -675,7 +675,7 @@ void core6_print(const char *name, const char *contents){ printf(" Points: "); PU_POINT16 papts = (PU_POINT16)(&(pEmr->apts)); for(i=0; icpts; i++){ - printf(" [%d]:",i); point16_print(papts[i]); + printf(" [%u]:",i); point16_print(papts[i]); } printf("\n"); } @@ -729,7 +729,7 @@ void core10_print(const char *name, const char *contents){ printf(" cpts: %d\n",pEmr->cpts ); printf(" Counts: "); for(i=0;inPolys; i++){ - printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); printf(" Points: "); @@ -753,7 +753,7 @@ void core11_print(const char *name, const char *contents){ i=1; char *prd = (char *) &(pEmr->RgnData); while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData:%d",i); + printf(" RegionData:%u",i); rgndata_print((PU_RGNDATA) (prd + roff)); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); printf("\n"); @@ -1362,7 +1362,7 @@ void U_EMRSETPALETTEENTRIES_print(const char *contents){ printf(" PLTEntries:"); PU_LOGPLTNTRY aPalEntries = (PU_LOGPLTNTRY) &(pEmr->aPalEntries); for(i=0; icEntries; i++){ - printf("%d:",i); logpltntry_print(aPalEntries[i]); + printf("%u:",i); logpltntry_print(aPalEntries[i]); } printf("\n"); } @@ -1428,13 +1428,13 @@ void U_EMRPOLYDRAW_print(const char *contents){ printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;icptl; i++){ - printf(" [%d]:",i); + printf(" [%u]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); printf(" Types: "); for(i=0;icptl; i++){ - printf(" [%d]:%u ",i,pEmr->abTypes[i]); + printf(" [%u]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -1619,7 +1619,7 @@ void U_EMRFILLRGN_print(const char *contents){ i=1; char *prd = (char *) &(pEmr->RgnData); while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1641,7 +1641,7 @@ void U_EMRFRAMERGN_print(const char *contents){ i=1; char *prd = (char *) &(pEmr->RgnData); while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1973,13 +1973,13 @@ void U_EMRPOLYDRAW16_print(const char *contents){ printf(" cpts: %d\n",pEmr->cpts ); printf(" Points: "); for(i=0;icpts; i++){ - printf(" [%d]:",i); + printf(" [%u]:",i); point16_print(pEmr->apts[i]); } printf("\n"); printf(" Types: "); for(i=0;icpts; i++){ - printf(" [%d]:%u ",i,pEmr->abTypes[i]); + printf(" [%u]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -2218,7 +2218,7 @@ void U_EMRCREATECOLORSPACEW_print(const char *contents){ printf(" Data: "); if(pEmr->dwFlags & 1){ for(i=0; icbData; i++){ - printf("[%d]:%2.2X ",i,pEmr->Data[i]); + printf("[%u]:%2.2X ",i,pEmr->Data[i]); } } printf("\n"); -- cgit v1.2.3