From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 18:05:42 +0000 (+0530) Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d5ad05ac17abfd7d2eae333a8c1233971e1c1a8f;p=inkscape.git This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. --- diff --git a/src/application/editor.cpp b/src/application/editor.cpp index 49010efdc..d2ccccbe3 100644 --- a/src/application/editor.cpp +++ b/src/application/editor.cpp @@ -76,10 +76,10 @@ Editor::init() // gchar const *tmpl = g_build_filename ((INKSCAPE_TEMPLATESDIR), "default.svg", NULL); bool have_default = Inkscape::IO::file_test (tmpl, G_FILE_TEST_IS_REGULAR); - SPDocument *doc = sp_document_new (have_default? tmpl:0, true, true); + SPDocument *doc = SPDocument::createDoc (have_default? tmpl:0, true, true); g_return_val_if_fail (doc != 0, false); Inkscape::UI::View::EditWidget *ew = new Inkscape::UI::View::EditWidget (doc); - sp_document_unref (doc); + doc->doUnref (); _window = ew->getWindow(); return ew != 0; } @@ -129,7 +129,7 @@ Editor::createDesktop (SPDocument* doc) { g_assert (doc != 0); (new Inkscape::UI::View::EditWidget (doc))->present(); - sp_document_unref (doc); + doc->doUnref (); SPDesktop *dt = getActiveDesktop(); reactivateDesktop (dt); return dt; diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 799167a72..ab3389ec6 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -417,7 +417,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state) ac->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); Inkscape::GC::release(repr); - ac->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + ac->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); ac->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); @@ -441,7 +441,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state) Geom::Point c = r.midpoint(); if (!ctrl_save) { if (fabs(dir[Geom::X]) > 1E-6 && fabs(dir[Geom::Y]) > 1E-6) { - Geom::Matrix const i2d (sp_item_i2d_affine (ac->item)); + Geom::Matrix const i2d ((ac->item)->i2d_affine ()); Geom::Point new_dir = pt * i2d - c; new_dir[Geom::X] *= dir[Geom::Y] / dir[Geom::X]; double lambda = new_dir.length() / dir[Geom::Y]; diff --git a/src/box3d.cpp b/src/box3d.cpp index aa2dc55e3..bdbbbfa7e 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -355,16 +355,16 @@ box3d_set_transform(SPItem *item, Geom::Matrix const &xform) SPItem *childitem = SP_ITEM(child); // Adjust stroke width - sp_item_adjust_stroke(childitem, sqrt(fabs(sw * sh))); + childitem->adjust_stroke(sqrt(fabs(sw * sh))); // Adjust pattern fill - sp_item_adjust_pattern(childitem, xform); + childitem->adjust_pattern(xform); // Adjust gradient fill - sp_item_adjust_gradient(childitem, xform); + childitem->adjust_gradient(xform); // Adjust LPE - sp_item_adjust_livepatheffect(childitem, xform); + childitem->adjust_livepatheffect(xform); } } @@ -393,7 +393,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { if (!box3d_get_perspective(box)) { return Geom::Point (NR_HUGE, NR_HUGE); } - Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + Geom::Matrix const i2d (SP_ITEM(box)->i2d_affine ()); if (item_coords) { return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_corner).affine() * i2d.inverse(); } else { @@ -417,7 +417,7 @@ box3d_get_center_screen (SPBox3D *box) { if (!box3d_get_perspective(box)) { return Geom::Point (NR_HUGE, NR_HUGE); } - Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + Geom::Matrix const i2d (SP_ITEM(box)->i2d_affine ()); return box3d_get_perspective(box)->perspective_impl->tmat.image(proj_center).affine() * i2d.inverse(); } @@ -1392,7 +1392,7 @@ box3d_convert_to_guides(SPItem *item) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/3dbox/convertguides", true)) { - sp_item_convert_to_guides(SP_ITEM(box)); + SP_ITEM(box)->convert_to_guides(); return; } diff --git a/src/color-profile-test.h b/src/color-profile-test.h index cdbf76b44..c479f78c0 100644 --- a/src/color-profile-test.h +++ b/src/color-profile-test.h @@ -25,7 +25,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 88c84a84c..21df27637 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -387,14 +387,14 @@ Geom::Point SPAvoidRef::getConnectionPointPos(const int type, const int id) { g_assert(item); Geom::Point pos; - const Geom::Matrix& transform = sp_item_i2doc_affine(item); + const Geom::Matrix& transform = item->i2doc_affine(); // TODO investigate why this was asking for the active desktop: SPDesktop *desktop = inkscape_active_desktop(); if ( type == ConnPointDefault ) { // For now, just default to the centre of the item - Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); pos = (bbox) ? bbox->midpoint() : Geom::Point(0, 0); } else @@ -504,7 +504,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) g_assert(desktop != NULL); double spacing = desktop->namedview->connector_spacing; - Geom::Matrix itd_mat = sp_item_i2doc_affine(item); + Geom::Matrix itd_mat = item->i2doc_affine(); std::vector hull_points; hull_points = approxItemWithPoints(item, itd_mat); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b0e192190..82be63de5 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -965,7 +965,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); // Update the hidden path - Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + Geom::Matrix i2d = (cc->clickeditem)->i2d_affine(); Geom::Matrix d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); SPCurve *curve = path->original_curve ? path->original_curve : path->curve; @@ -1088,7 +1088,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@ -1104,7 +1104,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con ConnectionPoint cp; cp.type = ConnPointUserDefined; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); @@ -1182,7 +1182,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) // Obtain original position ConnectionPoint const& cp = cc->connpthandles[cc->selected_handle]; SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - const Geom::Matrix& i2doc = sp_item_i2doc_affine(cc->active_shape); + const Geom::Matrix& i2doc = (cc->active_shape)->i2doc_affine(); sp_knot_set_position(cc->selected_handle, cp.pos * i2doc * desktop->doc2dt(), 0); cc->state = SP_CONNECTOR_CONTEXT_IDLE; desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, @@ -1204,7 +1204,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); sp_knot_set_position(cc->selected_handle, p, 0); ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cc->active_shape->avoidRef->updateConnectionPoint(cp); } @@ -1235,7 +1235,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) ConnectionPoint cp; cp.type = ConnPointUserDefined; - cp.pos = p * sp_item_dt2i_affine(cc->active_shape); + cp.pos = p * (cc->active_shape)->dt2i_affine(); cp.dir = Avoid::ConnDirAll; g_object_unref(cc->selected_handle); cc->active_shape->avoidRef->addConnectionPoint(cp); @@ -1431,7 +1431,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) /* Attach repr */ cc->newconn = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - cc->newconn->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); bool connection = false; sp_object_setAttribute(cc->newconn, "inkscape:connector-type", @@ -1593,7 +1593,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) // Show the red path for dragging. cc->red_curve = SP_PATH(cc->clickeditem)->original_curve ? SP_PATH(cc->clickeditem)->original_curve->copy() : SP_PATH(cc->clickeditem)->curve->copy(); - Geom::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + Geom::Matrix i2d = (cc->clickeditem)->i2d_affine(); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1752,7 +1752,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) g_assert( SP_IS_PATH(item) ); SPCurve *curve = SP_PATH(item)->original_curve ? SP_PATH(item)->original_curve : SP_PATH(item)->curve; - Geom::Matrix i2d = sp_item_i2d_affine(item); + Geom::Matrix i2d = item->i2d_affine(); if (cc->active_conn == item) { diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 26f29d172..19a45a285 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -121,7 +121,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) // Scale the style by the inverse of the accumulated parent transform in the paste context. { - Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o))); + Geom::Matrix const local(SP_ITEM(o)->i2doc_affine()); double const ex(local.descrim()); if ( ( ex != 0. ) && ( ex != 1. ) ) { @@ -416,7 +416,7 @@ stroke_average_width (GSList const *objects) if (!SP_IS_ITEM (l->data)) continue; - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data)); + Geom::Matrix i2d = (SP_ITEM(l->data))->i2d_affine (); SPObject *object = SP_OBJECT(l->data); @@ -717,7 +717,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) noneSet &= style->stroke.isNone(); - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); + Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine (); double sw = style->stroke_width.computed * i2d.descrim(); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) @@ -935,7 +935,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) if (!style) continue; texts ++; - size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here + size += style->font_size.computed * Geom::Matrix(SP_ITEM(obj)->i2d_affine()).descrim(); /// \todo FIXME: we assume non-% units here if (style->letter_spacing.normal) { if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing)) @@ -1381,7 +1381,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) if (!style) continue; if (!SP_IS_ITEM(obj)) continue; - Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); + Geom::Matrix i2d = SP_ITEM(obj)->i2d_affine (); items ++; diff --git a/src/desktop.cpp b/src/desktop.cpp index 52f172577..204807e98 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -190,7 +190,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid /* Setup Dialog Manager */ _dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance(); - dkey = sp_item_display_key_new (1); + dkey = SPItem::display_key_new (1); /* Connect document */ setDocument (document); @@ -277,7 +277,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); - NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (sp_document_root (document)), + NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); @@ -394,7 +394,7 @@ void SPDesktop::destroy() } if (drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (dkey); drawing = NULL; } @@ -552,7 +552,7 @@ bool SPDesktop::isLayer(SPObject *object) const { bool SPDesktop::isWithinViewport (SPItem *item) const { Geom::Rect const viewport = get_display_area(); - Geom::OptRect const bbox = sp_item_bbox_desktop(item); + Geom::OptRect const bbox = item->getBboxDesktop(); if (bbox) { return viewport.contains(*bbox); } else { @@ -1075,7 +1075,7 @@ SPDesktop::zoom_drawing() SPItem *docitem = SP_ITEM (sp_document_root (doc())); g_return_if_fail (docitem != NULL); - Geom::OptRect d = sp_item_bbox_desktop(docitem); + Geom::OptRect d = docitem->getBboxDesktop(); /* Note that the second condition here indicates that ** there are no items in the drawing. @@ -1474,7 +1474,7 @@ SPDesktop::setDocument (SPDocument *doc) { if (this->doc() && doc) { namedview->hide(this); - sp_item_invoke_hide (SP_ITEM (sp_document_root (this->doc())), dkey); + SP_ITEM (sp_document_root (this->doc()))->invoke_hide (dkey); } if (_layer_hierarchy) { @@ -1505,7 +1505,7 @@ SPDesktop::setDocument (SPDocument *doc) _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); number = namedview->getViewCount(); - ai = sp_item_invoke_show (SP_ITEM (sp_document_root (doc)), + ai = SP_ITEM (sp_document_root (doc))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 55884fe4a..550370e90 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -851,7 +851,7 @@ clonetiler_trace_hide_tiled_clones_recursively (SPObject *from) for (SPObject *o = sp_object_first_child(from); o != NULL; o = SP_OBJECT_NEXT(o)) { if (SP_IS_ITEM(o) && clonetiler_is_a_clone_of (o, NULL)) - sp_item_invoke_hide(SP_ITEM(o), trace_visionkey); // FIXME: hide each tiled clone's original too! + SP_ITEM(o)->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! clonetiler_trace_hide_tiled_clones_recursively (o); } } @@ -861,13 +861,12 @@ clonetiler_trace_setup (SPDocument *doc, gdouble zoom, SPItem *original) { trace_arena = NRArena::create(); /* Create ArenaItem and set transform */ - trace_visionkey = sp_item_display_key_new(1); + trace_visionkey = SPItem::display_key_new(1); trace_doc = doc; - trace_root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT (trace_doc)), - (NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); + trace_root = SP_ITEM(SP_DOCUMENT_ROOT (trace_doc))->invoke_show((NRArena *) trace_arena, trace_visionkey, SP_ITEM_SHOW_DISPLAY); // hide the (current) original and any tiled clones, we only want to pick the background - sp_item_invoke_hide(original, trace_visionkey); + original->invoke_hide(trace_visionkey); clonetiler_trace_hide_tiled_clones_recursively (SP_OBJECT(SP_DOCUMENT_ROOT (trace_doc))); sp_document_root (trace_doc)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -954,7 +953,7 @@ static void clonetiler_trace_finish () { if (trace_doc) { - sp_item_invoke_hide(SP_ITEM(sp_document_root(trace_doc)), trace_visionkey); + SP_ITEM(sp_document_root(trace_doc))->invoke_hide(trace_visionkey); } if (trace_arena) { ((NRObject *) trace_arena)->unreference(); @@ -1232,7 +1231,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) bool prefs_bbox = prefs->getBool("/tools/bounding_box", false); SPItem::BBoxType bbox_type = ( prefs_bbox ? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX ); - Geom::OptRect r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)), + Geom::OptRect r = SP_ITEM(obj)->getBounds(SP_ITEM(obj)->i2doc_affine(), bbox_type); if (r) { w = r->dimensions()[Geom::X]; diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index 696f38b77..463339534 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -780,7 +780,7 @@ sp_export_selection_modified ( Inkscape::Application */*inkscape*/, if ( SP_ACTIVE_DESKTOP ) { SPDocument *doc; doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); + Geom::OptRect bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); if (bbox) { sp_export_set_area (base, bbox->min()[Geom::X], bbox->min()[Geom::Y], @@ -861,7 +861,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base) /** \todo * This returns wrong values if the document has a viewBox. */ - bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); + bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); /* If the drawing is valid, then we'll use it and break otherwise we drop through to the page settings */ if (bbox) { @@ -1127,7 +1127,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } Geom::OptRect area; - sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), TRUE); + item->invoke_bbox( area, static_cast(item)->i2d_affine(), TRUE); if (area) { gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); @@ -1498,7 +1498,7 @@ sp_export_detect_size(GtkObject * base) { case SELECTION_DRAWING: { SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), SPItem::RENDERING_BBOX); + Geom::OptRect bbox = SP_ITEM (SP_DOCUMENT_ROOT (doc))->getBboxDesktop (SPItem::RENDERING_BBOX); // std::cout << "Drawing " << bbox2; if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) { diff --git a/src/dialogs/spellcheck.cpp b/src/dialogs/spellcheck.cpp index 1645218c6..24890f8eb 100644 --- a/src/dialogs/spellcheck.cpp +++ b/src/dialogs/spellcheck.cpp @@ -236,8 +236,8 @@ gint compare_text_bboxes (gconstpointer a, gconstpointer b) SPItem *i1 = SP_ITEM(a); SPItem *i2 = SP_ITEM(b); - Geom::OptRect bbox1 = i1->getBounds(sp_item_i2d_affine(i1)); - Geom::OptRect bbox2 = i2->getBounds(sp_item_i2d_affine(i2)); + Geom::OptRect bbox1 = i1->getBounds(i1->i2d_affine()); + Geom::OptRect bbox2 = i2->getBounds(i2->i2d_affine()); if (!bbox1 || !bbox2) { return 0; } @@ -570,7 +570,7 @@ spellcheck_next_word() // draw rect std::vector points = - _layout->createSelectionShape(_begin_w, _end_w, sp_item_i2d_affine(_text)); + _layout->createSelectionShape(_begin_w, _end_w, _text->i2d_affine()); Geom::Point tl, br; tl = br = points.front(); for (unsigned i = 0 ; i < points.size() ; i ++) { diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 4ad6982f3..215fc4d02 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -51,8 +51,8 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { // prep the document sp_document_ensure_up_to_date(document); NRArena* arena = NRArena::create(); - unsigned const key = sp_item_display_key_new(1); - NRArenaItem* ai = sp_item_invoke_show(SVGElem, arena, key, SP_ITEM_SHOW_DISPLAY); + unsigned const key = SPItem::display_key_new(1); + NRArenaItem* ai = SVGElem->invoke_show(arena, key, SP_ITEM_SHOW_DISPLAY); if (!ai) { g_warning("feImage renderer: error creating NRArenaItem for SVG Element"); nr_object_unref((NRObject *) arena); @@ -100,7 +100,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { { g_warning("FilterImage::render: not enough memory to create pixel buffer. Need %ld.", 4L * width * height); } - sp_item_invoke_hide(SVGElem, key); + SVGElem->invoke_hide(key); nr_object_unref((NRObject *) arena); } diff --git a/src/document.cpp b/src/document.cpp index eff6d6e81..0479569f6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -439,7 +439,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, * appears in document list. */ SPDocument * -sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) +SPDocument::createDoc(gchar const *uri, unsigned int keepalive, bool make_new) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -490,7 +490,7 @@ sp_document_new(gchar const *uri, unsigned int keepalive, bool make_new) } SPDocument * -sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepalive) +SPDocument::createDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -515,18 +515,18 @@ sp_document_new_from_mem(gchar const *buffer, gint length, unsigned int keepaliv } SPDocument * -sp_document_ref(SPDocument *doc) +SPDocument::doRef() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::anchor(doc); - return doc; + //g_return_val_if_fail(doc != NULL, NULL); + Inkscape::GC::anchor(this); + return this; } SPDocument * -sp_document_unref(SPDocument *doc) +SPDocument::doUnref() { - g_return_val_if_fail(doc != NULL, NULL); - Inkscape::GC::release(doc); + //g_return_val_if_fail(doc != NULL, NULL); + Inkscape::GC::release(this); return NULL; } @@ -1126,7 +1126,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); } else { SPItem *child = SP_ITEM(o); - Geom::OptRect box = sp_item_bbox_desktop(child); + Geom::OptRect box = child->getBboxDesktop(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s = g_slist_append(s, child); } @@ -1168,7 +1168,7 @@ sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GS if (!SP_IS_ITEM(o)) continue; SPItem *item = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(item, dkey); + NRArenaItem *arenaitem = item->get_arenaitem(dkey); if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { if (g_slist_find((GSList *) list, item) != NULL) @@ -1219,7 +1219,7 @@ find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gbool } else { SPItem *child = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(child, dkey); + NRArenaItem *arenaitem = child->get_arenaitem(dkey); // seen remembers the last (topmost) of items pickable at this point if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL @@ -1252,7 +1252,7 @@ find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) } if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { SPItem *child = SP_ITEM(o); - NRArenaItem *arenaitem = sp_item_get_arenaitem(child, dkey); + NRArenaItem *arenaitem = child->get_arenaitem(dkey); // seen remembers the last (topmost) of groups pickable at this point if (arenaitem && nr_arena_item_invoke_pick(arenaitem, p, delta, 1) != NULL) { diff --git a/src/document.h b/src/document.h index e70582006..2f9da7817 100644 --- a/src/document.h +++ b/src/document.h @@ -64,10 +64,11 @@ namespace Proj { class SPDocumentPrivate; /// Typed SVG document implementation. -struct SPDocument : public Inkscape::GC::Managed<>, +class SPDocument : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, public Inkscape::GC::Anchored { + public: typedef sigc::signal IDChangedSignal; typedef sigc::signal ResourcesChangedSignal; typedef sigc::signal ModifiedSignal; @@ -180,13 +181,17 @@ public: sigc::connection _desktop_activated_connection; void fitToRect(Geom::Rect const &rect, bool with_margins = false); + static SPDocument *createDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + SPDocument *doRef(); + SPDocument *doUnref(); }; -SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); -SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); +//SPDocument *sp_document_new(const gchar *uri, unsigned int keepalive, bool make_new = false); +//SPDocument *sp_document_new_from_mem(const gchar *buffer, gint length, unsigned int keepalive); -SPDocument *sp_document_ref(SPDocument *doc); -SPDocument *sp_document_unref(SPDocument *doc); +//SPDocument *sp_document_ref(SPDocument *doc); +//SPDocument *sp_document_unref(SPDocument *doc); SPDocument *sp_document_create(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 3049f3a6a..52118eb16 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -438,7 +438,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) /* Curve list */ /* We keep it in desktop coordinates to eliminate calculation errors */ SPCurve *norm = sp_path_get_curve_for_edit (SP_PATH(item)); - norm->transform(sp_item_i2d_affine(dc->white_item)); + norm->transform((dc->white_item)->i2d_affine()); g_return_if_fail( norm != NULL ); dc->white_curves = g_slist_reverse(norm->split()); norm->unref(); @@ -656,7 +656,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) /* Now we have to go back to item coordinates at last */ c->transform( dc->white_item - ? sp_item_dt2i_affine(dc->white_item) + ? (dc->white_item)->dt2i_affine() : SP_EVENT_CONTEXT_DESKTOP(dc)->dt2doc() ); SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); @@ -694,7 +694,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) dc->selection->set(repr); Inkscape::GC::release(repr); - item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); } @@ -836,8 +836,8 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons current stroke width, multiplied by the amount specified in the preferences */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Geom::Matrix const i2d (sp_item_i2d_affine (item)); - Geom::Point pp = pt * i2d.inverse(); + Geom::Matrix const i2d (item->i2d_affine ()); + Geom::Point pp = pt; double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0); if (event_state & GDK_MOD1_MASK) { /* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size @@ -856,6 +856,7 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons sp_repr_set_svg_double (repr, "sodipodi:rx", rad * stroke_width); sp_repr_set_svg_double (repr, "sodipodi:ry", rad * stroke_width); item->updateRepr(); + item->set_item_transform(i2d.inverse()); sp_desktop_selection(desktop)->set(item); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index bb8e69092..4d8ab2c11 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -599,7 +599,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, } // calculate pointer point in the guide item's coords - motion_to_curve = sp_item_dt2i_affine(selected) * sp_item_i2doc_affine(selected); + motion_to_curve = selected->dt2i_affine() * selected->i2doc_affine(); pointer = motion_dt * motion_to_curve; // calculate the nearest point on the guide path @@ -1012,7 +1012,7 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize, bool subtract) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); - item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); } Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc(); diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 6afa07d77..46efd403a 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -723,7 +723,7 @@ set_to_accumulated(SPEraserContext *dc) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); - item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); } Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc(); diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp index c81fdd029..d7b7cc862 100644 --- a/src/extension/internal/cairo-png-out.cpp +++ b/src/extension/internal/cairo-png-out.cpp @@ -59,8 +59,8 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) /* Create new arena */ SPItem *base = SP_ITEM(sp_document_root(doc)); NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); - NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + unsigned dkey = SPItem::display_key_new(1); + NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ renderer = new CairoRenderer(); @@ -76,7 +76,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename) renderer->destroyContext(ctx); /* Release arena */ - sp_item_invoke_hide(base, dkey); + base->invoke_hide(dkey); nr_object_unref((NRObject *) arena); /* end */ delete renderer; diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 61760e9d9..59daafb7e 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -86,8 +86,8 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l /* Create new arena */ NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); - sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + unsigned dkey = SPItem::display_key_new(1); + base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ CairoRenderer *renderer = new CairoRenderer(); @@ -110,7 +110,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l } /* Release arena */ - sp_item_invoke_hide(base, dkey); + base->invoke_hide(dkey); nr_object_unref((NRObject *) arena); renderer->destroyContext(ctx); diff --git a/src/extension/internal/cairo-ps-out.h b/src/extension/internal/cairo-ps-out.h index 019b6b810..40c7bf7e3 100644 --- a/src/extension/internal/cairo-ps-out.h +++ b/src/extension/internal/cairo-ps-out.h @@ -16,6 +16,7 @@ #define EXTENSION_INTERNAL_CAIRO_PS_OUT_H #include "extension/implementation/implementation.h" +#include "sp-item.h" #ifdef HAVE_CAIRO_PDF diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 28d1db9a4..5849230bf 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1063,14 +1063,14 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // create arena and group NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { - sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS); + SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS); _renderer->renderItem(pattern_ctx, SP_ITEM (child)); } } @@ -1099,7 +1099,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { if (SP_IS_ITEM (child)) { - sp_item_invoke_hide (SP_ITEM (child), dkey); + SP_ITEM (child)->invoke_hide (dkey); } } break; // do not go further up the chain if children are found diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index 808590e04..d7a034291 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -79,8 +79,8 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int /* Create new arena */ NRArena *arena = NRArena::create(); nr_arena_set_renderoffscreen (arena); - unsigned dkey = sp_item_display_key_new(1); - sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + unsigned dkey = SPItem::display_key_new(1); + base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); /* Create renderer and context */ CairoRenderer *renderer = new CairoRenderer(); @@ -102,7 +102,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int } /* Release arena */ - sp_item_invoke_hide(base, dkey); + base->invoke_hide(dkey); nr_object_unref((NRObject *) arena); renderer->destroyContext(ctx); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index ebdb82a69..5b05cd96b 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -186,7 +186,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) if (!shape->curve) return; - sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); + item->invoke_bbox( &pbox, Geom::identity(), TRUE); SPStyle* style = SP_OBJECT_STYLE (item); @@ -449,7 +449,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) // Get the bounding box of the selection in document coordinates. Geom::OptRect bbox = - item->getBounds(sp_item_i2d_affine(item), SPItem::RENDERING_BBOX); + item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX); if (!bbox) // no bbox, e.g. empty group return; @@ -480,7 +480,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) (Geom::Matrix)(Geom::Translate (shift_x, shift_y)); // ctx matrix already includes item transformation. We must substract. - Geom::Matrix t_item = sp_item_i2d_affine (item); + Geom::Matrix t_item = item->i2d_affine (); Geom::Matrix t = t_on_document * t_item.inverse(); // Do the export @@ -611,7 +611,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page d.x1 = sp_document_width(doc); d.y1 = sp_document_height(doc); } else { - sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX); + base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); } if (ctx->_vector_based_target) { diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index d69a60753..094922bbf 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -23,7 +23,7 @@ //#include "libnrtype/font-instance.h" #include "style.h" - +#include "sp-item.h" #include class SPClipPath; diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 9d25f3a7f..0d939427c 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -2366,7 +2366,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl; - SPDocument *doc = sp_document_new_from_mem(d.outsvg->c_str(), d.outsvg->length(), TRUE); + SPDocument *doc = SPDocument::createDocFromMem(d.outsvg->c_str(), d.outsvg->length(), TRUE); delete d.outsvg; delete d.path; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index d098f6466..21bb85331 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -147,7 +147,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) d.y1 = _height; } else { SPItem* doc_item = SP_ITEM(sp_document_root(doc)); - sp_item_invoke_bbox(doc_item, &d, sp_item_i2d_affine(doc_item), TRUE); + sp_item_invoke_bbox(doc_item, &d, doc_item->i2d_affine(), TRUE); } d.x0 *= IN_PER_PX; diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index a1295406c..2e10dae58 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -54,7 +54,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) mime_type = "image/png"; } - doc = sp_document_new(NULL, TRUE, TRUE); + doc = SPDocument::createDoc(NULL, TRUE, TRUE); bool saved = sp_document_get_undo_sensitive(doc); sp_document_set_undo_sensitive(doc, false); // no need to undo in this temporary document diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp index 5b3e0c16e..d33975f91 100644 --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@ -256,7 +256,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename) fclose(gradient); - return sp_document_new_from_mem(outsvg.c_str(), outsvg.length(), TRUE); + return SPDocument::createDocFromMem(outsvg.c_str(), outsvg.length(), TRUE); } error: diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index a4d348940..813a17264 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -493,7 +493,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) // convert the path to only lineto's and cubic curveto's: Geom::Scale yflip(1.0, -1.0); - Geom::Matrix tf = sp_item_i2d_affine(item) * yflip; + Geom::Matrix tf = item->i2d_affine() * yflip; Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); //Count the NR_CURVETOs/LINETOs (including closing line segment) @@ -635,7 +635,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) // convert the path to only lineto's and cubic curveto's: Geom::Scale yflip(1.0, -1.0); - Geom::Matrix tf = sp_item_i2d_affine(item) * yflip; + Geom::Matrix tf = item->i2d_affine() * yflip; Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); //Count the NR_CURVETOs/LINETOs (including closing line segment) diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp index 4a469a750..c2d14f6a5 100644 --- a/src/extension/internal/latex-pstricks-out.cpp +++ b/src/extension/internal/latex-pstricks-out.cpp @@ -68,14 +68,14 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons /* Create new arena */ mod->base = SP_ITEM (sp_document_root (doc)); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new (1); - mod->root = sp_item_invoke_show (mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new (1); + mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin (doc); - sp_item_invoke_print (mod->base, &context); + (mod->base)->invoke_print (&context); ret = mod->finish (); /* Release arena */ - sp_item_invoke_hide (mod->base, mod->dkey); + (mod->base)->invoke_hide (mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref ((NRObject *) mod->arena); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index bebc21f2f..cd712e477 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -311,7 +311,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item) } // get rotation - Geom::Matrix i2doc = sp_item_i2doc_affine(item); + Geom::Matrix i2doc = item->i2doc_affine(); Geom::Matrix wotransl = i2doc.without_translation(); double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis()); bool has_rotation = !Geom::are_near(degrees,0.); @@ -412,7 +412,7 @@ Flowing in rectangle is possible, not in arb shape. } // get rotation - Geom::Matrix i2doc = sp_item_i2doc_affine(item); + Geom::Matrix i2doc = item->i2doc_affine(); Geom::Matrix wotransl = i2doc.without_translation(); double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis()); bool has_rotation = !Geom::are_near(degrees,0.); @@ -498,7 +498,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem * d = Geom::Rect( Geom::Point(0,0), Geom::Point(sp_document_width(doc), sp_document_height(doc)) ); } else { - sp_item_invoke_bbox(base, d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX); + base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX); } if (!d) { g_message("LaTeXTextRenderer: could not retrieve boundingbox."); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 5331c072c..4e89ce7b2 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -945,7 +945,7 @@ static Glib::ustring formatTransform(Geom::Matrix &tf) static Geom::Matrix getODFTransform(const SPItem *item) { //### Get SVG-to-ODF transform - Geom::Matrix tf (sp_item_i2d_affine(item)); + Geom::Matrix tf (item->i2d_affine()); //Flip Y into document coordinates double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT); Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0)); @@ -964,7 +964,7 @@ static Geom::Matrix getODFTransform(const SPItem *item) */ static Geom::OptRect getODFBoundingBox(const SPItem *item) { - Geom::OptRect bbox_temp = sp_item_bbox_desktop((SPItem *)item); + Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop(); Geom::OptRect bbox; if (bbox_temp) { bbox = *bbox_temp; diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h index 3854ddfe1..08eda3767 100644 --- a/src/extension/internal/odf.h +++ b/src/extension/internal/odf.h @@ -47,7 +47,7 @@ #include #include - +#include "sp-item.h" namespace Inkscape { diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index 937fefb11..e3abc63d4 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -58,7 +58,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { cairo_destroy(cr); cairo_surface_destroy(surface); - SPDocument * doc = sp_document_new_from_mem(output->c_str(), output->length(), TRUE); + SPDocument * doc = SPDocument::createDocFromMem(output->c_str(), output->length(), TRUE); delete output; g_object_unref(page); diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index ba00fe343..e771d8b41 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -661,7 +661,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { Catalog *catalog = pdf_doc->getCatalog(); Page *page = catalog->getPage(page_num); - SPDocument *doc = sp_document_new(NULL, TRUE, TRUE); + SPDocument *doc = SPDocument::createDoc(NULL, TRUE, TRUE); bool saved = sp_document_get_undo_sensitive(doc); sp_document_set_undo_sensitive(doc, false); // No need to undo in this temporary document diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 16877c370..fc8c1a666 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -300,7 +300,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id) povShapes.push_back(shapeInfo); //passed all tests. save the info // convert the path to only lineto's and cubic curveto's: - Geom::Matrix tf = sp_item_i2d_affine(item); + Geom::Matrix tf = item->i2d_affine(); Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf ); /* diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index b10aa87ec..c063be46c 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -182,19 +182,19 @@ Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri) #ifdef WITH_GNOME_VFS if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { // Use built-in loader instead of VFS for this - return sp_document_new(uri, TRUE); + return SPDocument::createDoc(uri, TRUE); } gchar * buffer = _load_uri(uri); if (buffer == NULL) { g_warning("Error: Could not open file '%s' with VFS\n", uri); return NULL; } - SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1); + SPDocument * doc = SPDocument::createDocFromMem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else - return sp_document_new (uri, TRUE); + return SPDocument::createDoc(uri, TRUE); #endif } diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index c37d5705b..023bab879 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -86,7 +86,7 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) { //printf("I've got a doc: \n%s", painter.document.c_str()); - SPDocument * doc = sp_document_new_from_mem(output.cstr(), strlen(output.cstr()), TRUE); + SPDocument * doc = SPDocument::createDocFromMem(output.cstr(), strlen(output.cstr()), TRUE); delete input; return doc; } diff --git a/src/extension/print.h b/src/extension/print.h index 8ae71b8e6..bc275b3b5 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -14,7 +14,7 @@ #include "display/nr-arena-forward.h" #include "forward.h" - +#include "sp-item.h" namespace Inkscape { namespace Extension { diff --git a/src/file.cpp b/src/file.cpp index e0ecd5084..352362424 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -118,7 +118,7 @@ sp_file_new(const Glib::ustring &templ) char *templName = NULL; if (templ.size()>0) templName = (char *)templ.c_str(); - SPDocument *doc = sp_document_new(templName, TRUE, true); + SPDocument *doc = SPDocument::createDoc(templName, TRUE, true); g_return_val_if_fail(doc != NULL, NULL); SPDesktop *dt; @@ -128,7 +128,7 @@ sp_file_new(const Glib::ustring &templ) } else { SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); + doc->doUnref(); sp_create_window(dtw, TRUE); dt = static_cast(dtw->view); @@ -250,7 +250,7 @@ sp_file_open(const Glib::ustring &uri, doc->virgin = FALSE; // everyone who cares now has a reference, get rid of ours - sp_document_unref(doc); + doc->doUnref(); // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); @@ -1049,7 +1049,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // preserve parent and viewBox transformations // c2p is identity matrix at this point unless sp_document_ensure_up_to_date is called sp_document_ensure_up_to_date(doc); - Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * sp_item_i2doc_affine(SP_ITEM(place_to_insert)).inverse(); + Geom::Matrix affine = SP_ROOT(SP_DOCUMENT_ROOT(doc))->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false); // move to mouse pointer @@ -1063,7 +1063,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } } - sp_document_unref(doc); + doc->doUnref(); sp_document_done(in_doc, SP_VERB_FILE_IMPORT, _("Import")); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 363663ac3..3d5a795c7 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -319,7 +319,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo SPFilter * new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble radius) { - Geom::OptRect const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX); + Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX); double width; double height; @@ -330,7 +330,7 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod width = height = 0; } - Geom::Matrix i2d (sp_item_i2d_affine (item) ); + Geom::Matrix i2d (item->i2d_affine () ); return (new_filter_blend_gaussian_blur (document, mode, radius, i2d.descrim(), i2d.expansionX(), i2d.expansionY(), width, height)); } @@ -367,14 +367,14 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, } // Determine the required standard deviation value - Geom::Matrix i2d (sp_item_i2d_affine (item)); + Geom::Matrix i2d (item->i2d_affine ()); double expansion = i2d.descrim(); double stdDeviation = radius; if (expansion != 0) stdDeviation /= expansion; // Get the object size - Geom::OptRect const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX); + Geom::OptRect const r = item->getBboxDesktop(SPItem::GEOMETRIC_BBOX); double width; double height; if (r) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 612ae1cfc..f8c2e14a0 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -485,10 +485,10 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { - sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL); + SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL); // premultiply the item transform by the accumulated parent transform in the paste layer - Geom::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer()))); + Geom::Matrix local (SP_GROUP(desktop->currentLayer())->i2doc_affine()); if (!local.isIdentity()) { gchar const *t_str = pathRepr->attribute("transform"); Geom::Matrix item_t (Geom::identity()); @@ -774,7 +774,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even /* Create new arena */ NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); sp_document_ensure_up_to_date (document); @@ -807,7 +807,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = SP_ITEM(sp_document_root(document))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -850,7 +850,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_pixblock_release(&B); // Hide items - sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey); + SP_ITEM(sp_document_root(document))->invoke_hide(dkey); nr_object_unref((NRObject *) arena); diff --git a/src/forward.h b/src/forward.h index d4a98fbff..0388f8f63 100644 --- a/src/forward.h +++ b/src/forward.h @@ -64,15 +64,15 @@ class SPObjectClass; GType sp_object_get_type (); -class SPItem; -class SPItemClass; +//class SPItem; +//class SPItemClass; -#define SP_TYPE_ITEM (sp_item_get_type ()) -#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) -#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) -#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) +//#define SP_TYPE_ITEM (sp_item_get_type ()) +//#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) +//#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) +//#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) -GType sp_item_get_type (); +//GType sp_item_get_type (); class SPGroup; class SPGroupClass; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 979b53f1b..56d4813fb 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -767,7 +767,7 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, Geom gradient = sp_gradient_convert_to_userspace (gradient, item, fill_or_stroke? "fill" : "stroke"); - Geom::Matrix i2d (sp_item_i2d_affine (item)); + Geom::Matrix i2d (item->i2d_affine ()); Geom::Point p = p_w * i2d.inverse(); p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates @@ -1048,7 +1048,7 @@ sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool bbox->min()[Geom::X], bbox->min()[Geom::Y]); } } - p *= Geom::Matrix(gradient->gradientTransform) * (Geom::Matrix)sp_item_i2d_affine(item); + p *= Geom::Matrix(gradient->gradientTransform) * (Geom::Matrix)item->i2d_affine(); return from_2geom(p); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 227a5f003..6306278c5 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1100,7 +1100,7 @@ GrDragger::updateTip () if (g_slist_length (this->draggables) == 1) { GrDraggable *draggable = (GrDraggable *) this->draggables->data; - char *item_desc = sp_item_description(draggable->item); + char *item_desc = draggable->item->description(); switch (draggable->point_type) { case POINT_LG_MID: case POINT_RG_MID1: @@ -1738,7 +1738,7 @@ GrDrag::updateLevels () for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect rect = sp_item_bbox_desktop (item); + Geom::OptRect rect = item->getBboxDesktop (); if (rect) { // Remember the edges of the bbox and the center axis hor_levels.push_back(rect->min()[Geom::Y]); diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index a89af10af..13838d4cf 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -126,7 +126,7 @@ void graphlayout(GSList const *const items) { ++i) { SPItem *u=*i; - Geom::OptRect const item_box(sp_item_bbox_desktop(u)); + Geom::OptRect const item_box(u->getBboxDesktop()); if(item_box) { Geom::Point ll(item_box->min()); Geom::Point ur(item_box->max()); @@ -228,7 +228,7 @@ void graphlayout(GSList const *const items) { map::iterator i=nodelookup.find(u->getId()); if(i!=nodelookup.end()) { Rectangle* r=rs[i->second]; - Geom::OptRect item_box(sp_item_bbox_desktop(u)); + Geom::OptRect item_box(u->getBboxDesktop()); if(item_box) { Geom::Point const curr(item_box->midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 3be63aa68..ebcee1a64 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -51,7 +51,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) && !SP_IS_USE(o) && !g_slist_find(list, o) ) { - sp_item_invoke_hide(SP_ITEM(o), dkey); + SP_ITEM(o)->invoke_hide(dkey); } // recurse @@ -104,7 +104,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, /* Create new arena for offscreen rendering*/ NRArena *arena = NRArena::create(); nr_arena_set_renderoffscreen(arena); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); sp_document_ensure_up_to_date (doc); @@ -122,7 +122,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = SP_ITEM(sp_document_root(doc))->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); @@ -186,7 +186,7 @@ sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename*/, { g_warning("sp_generate_internal_bitmap: not enough memory to create pixel buffer. Need %lld.", size); } - sp_item_invoke_hide (SP_ITEM(sp_document_root(doc)), dkey); + SP_ITEM(sp_document_root(doc))->invoke_hide (dkey); nr_object_unref((NRObject *) arena); // gdk_pixbuf_save (pixbuf, "C:\\temp\\internal.jpg", "jpeg", NULL, "quality","100", NULL); diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b1c135db0..81c8612fb 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -371,7 +371,7 @@ hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) && !SP_IS_GROUP(o) && !g_slist_find(list, o) ) { - sp_item_invoke_hide(SP_ITEM(o), dkey); + SP_ITEM(o)->invoke_hide(dkey); } // recurse @@ -461,10 +461,10 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, NRArena *const arena = NRArena::create(); // export with maximum blur rendering quality nr_arena_set_renderoffscreen(arena); - unsigned const dkey = sp_item_display_key_new(1); + unsigned const dkey = SPItem::display_key_new(1); /* Create ArenaItems and set transform */ - ebp.root = sp_item_invoke_show(SP_ITEM(sp_document_root(doc)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + ebp.root = SP_ITEM(sp_document_root(doc))->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(ebp.root), affine); // We show all and then hide all items we don't want, instead of showing only requested items, @@ -490,7 +490,7 @@ sp_export_png_file(SPDocument *doc, gchar const *filename, } // Hide items, this releases arenaitem - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), dkey); + SP_ITEM(sp_document_root(doc))->invoke_hide(dkey); /* Free arena */ nr_object_unref((NRObject *) arena); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 1c184da72..72f97c6da 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -56,7 +56,7 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current if (!edoc && !doc) { gchar *markers = g_build_filename(INKSCAPE_MARKERSDIR, "/markers.svg", NULL); if (Inkscape::IO::file_test(markers, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(markers, FALSE); + doc = SPDocument::createDoc(markers, FALSE); } g_free(markers); if (doc) { @@ -94,12 +94,12 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) if (!edoc && !doc) { gchar *patterns = g_build_filename(INKSCAPE_PATTERNSDIR, "/patterns.svg", NULL); if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(patterns, FALSE); + doc = SPDocument::createDoc(patterns, FALSE); } if (!doc) { gchar *patterns = g_build_filename(CREATE_PATTERNSDIR, "/patterns.svg", NULL); if (Inkscape::IO::file_test(patterns, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(patterns, FALSE); + doc = SPDocument::createDoc(patterns, FALSE); } g_free(patterns); if (doc) { @@ -137,12 +137,12 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) if (!edoc && !doc) { gchar *gradients = g_build_filename(INKSCAPE_GRADIENTSDIR, "/gradients.svg", NULL); if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(gradients, FALSE); + doc = SPDocument::createDoc(gradients, FALSE); } if (!doc) { gchar *gradients = g_build_filename(CREATE_GRADIENTSDIR, "/gradients.svg", NULL); if (Inkscape::IO::file_test(gradients, G_FILE_TEST_IS_REGULAR)) { - doc = sp_document_new(gradients, FALSE); + doc = SPDocument::createDoc(gradients, FALSE); } g_free(gradients); if (doc) { diff --git a/src/inkview.cpp b/src/inkview.cpp index c151991dd..1a13e356f 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -273,7 +273,7 @@ main (int argc, const char **argv) ss.slides = g_renew (char *, ss.slides, ss.size); } - ss.doc = sp_document_new_from_mem ((const gchar *)gba->data, + ss.doc = SPDocument::createDocFromMem ((const gchar *)gba->data, gba->len, TRUE); gchar *last_filename = jar_file_reader.get_last_filename(); @@ -299,7 +299,7 @@ main (int argc, const char **argv) ss.slides[ss.length++] = strdup (argv[i]); if (!ss.doc) { - ss.doc = sp_document_new (ss.slides[ss.current], TRUE, false); + ss.doc = SPDocument::createDoc (ss.slides[ss.current], TRUE, false); if (!ss.doc) ++ss.current; } @@ -325,7 +325,7 @@ main (int argc, const char **argv) sp_document_ensure_up_to_date (ss.doc); ss.view = sp_svg_view_widget_new (ss.doc); - sp_document_unref (ss.doc); + (ss.doc)->doUnref (); sp_svg_view_widget_set_resize (SP_SVG_VIEW_WIDGET (ss.view), FALSE, sp_document_width (ss.doc), sp_document_height (ss.doc)); gtk_widget_show (ss.view); @@ -459,7 +459,7 @@ sp_svgview_show_next (struct SPSlideShow *ss) SPDocument *doc = NULL; int current = ss->current; while (!doc && (current < ss->length - 1)) { - doc = sp_document_new (ss->slides[++current], TRUE, false); + doc = SPDocument::createDoc (ss->slides[++current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -475,7 +475,7 @@ sp_svgview_show_prev (struct SPSlideShow *ss) SPDocument *doc = NULL; int current = ss->current; while (!doc && (current > 0)) { - doc = sp_document_new (ss->slides[--current], TRUE, false); + doc = SPDocument::createDoc (ss->slides[--current], TRUE, false); } sp_svgview_set_document(ss, doc, current); @@ -493,7 +493,7 @@ sp_svgview_goto_first (struct SPSlideShow *ss) while ( !doc && (current < ss->length - 1)) { if (current == ss->current) break; - doc = sp_document_new (ss->slides[current++], TRUE, false); + doc = SPDocument::createDoc (ss->slides[current++], TRUE, false); } sp_svgview_set_document(ss, doc, current - 1); @@ -511,7 +511,7 @@ sp_svgview_goto_last (struct SPSlideShow *ss) while (!doc && (current >= 0)) { if (current == ss->current) break; - doc = sp_document_new (ss->slides[current--], TRUE, false); + doc = SPDocument::createDoc (ss->slides[current--], TRUE, false); } sp_svgview_set_document(ss, doc, current + 1); diff --git a/src/interface.cpp b/src/interface.cpp index b33443d1b..4b3126680 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1318,7 +1318,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 + to_2geom(item->i2d_affine()).descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -1421,7 +1421,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 + to_2geom(item->i2d_affine()).descrim() * 0.5 : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); diff --git a/src/interface.h b/src/interface.h index 099fdd277..a9cf58471 100644 --- a/src/interface.h +++ b/src/interface.h @@ -17,7 +17,7 @@ #include #include "forward.h" - +#include "sp-item.h" /** * Create a new document window. diff --git a/src/jabber_whiteboard/session-manager.cpp b/src/jabber_whiteboard/session-manager.cpp index a04ab05f0..7a39b6d81 100644 --- a/src/jabber_whiteboard/session-manager.cpp +++ b/src/jabber_whiteboard/session-manager.cpp @@ -393,7 +393,7 @@ makeInkboardDesktop(SPDocument* doc) { SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); g_return_val_if_fail(dtw != NULL, NULL); - sp_document_unref(doc); + doc->doUnref(); sp_create_window(dtw, TRUE); dt = static_cast(dtw->view); diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 2d0d5eb02..9e3a3babc 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -77,7 +77,7 @@ KnotHolderEntity::~KnotHolderEntity() void KnotHolderEntity::update_knot() { - Geom::Matrix const i2d(sp_item_i2d_affine(item)); + Geom::Matrix const i2d(item->i2d_affine()); Geom::Point dp(knot_get() * i2d); @@ -89,7 +89,7 @@ KnotHolderEntity::update_knot() Geom::Point KnotHolderEntity::snap_knot_position(Geom::Point const &p) { - Geom::Matrix const i2d (sp_item_i2d_affine(item)); + Geom::Matrix const i2d (item->i2d_affine()); Geom::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; @@ -103,7 +103,7 @@ KnotHolderEntity::snap_knot_position(Geom::Point const &p) Geom::Point KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine const &constraint) { - Geom::Matrix const i2d (sp_item_i2d_affine(item)); + Geom::Matrix const i2d (item->i2d_affine()); Geom::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; @@ -170,7 +170,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori if (state) { Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat); - sp_item_adjust_pattern(item, Geom::Matrix(Geom::Translate(q))); + item->adjust_pattern(Geom::Matrix(Geom::Translate(q))); } item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -220,7 +220,7 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const & Geom::Point const t = sp_pattern_extract_trans(pat); rot[4] = t[Geom::X]; rot[5] = t[Geom::Y]; - sp_item_adjust_pattern(item, rot, true); + item->adjust_pattern(rot, true); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -254,7 +254,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const & Geom::Point const t = sp_pattern_extract_trans(pat); rot[4] = t[Geom::X]; rot[5] = t[Geom::Y]; - sp_item_adjust_pattern(item, rot, true); + item->adjust_pattern(rot, true); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 314ad807c..af11d5acb 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -83,7 +83,7 @@ KnotHolder::~KnotHolder() { void KnotHolder::update_knots() { - Geom::Matrix const i2d(sp_item_i2d_affine(item)); + Geom::Matrix const i2d(item->i2d_affine()); for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -163,8 +163,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { - Geom::Point const q = p * sp_item_i2d_affine(item).inverse(); - e->knot_set(q, e->knot->drag_origin * sp_item_i2d_affine(item).inverse(), state); + Geom::Point const q = p * item->i2d_affine().inverse(); + e->knot_set(q, e->knot->drag_origin * item->i2d_affine().inverse(), state); break; } } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index a3a0faf37..dabeb5682 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -46,7 +46,7 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem) using namespace Geom; SPItem *item = SP_ITEM(lpeitem); - Geom::Matrix t = sp_item_i2d_affine(item); + Geom::Matrix t = item->i2d_affine(); Geom::Rect bbox = *item->getBounds(t); // fixme: what happens if getBounds does not return a valid rect? Point A(bbox.left(), bbox.bottom()); diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 3820b5ba7..6eac43c43 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -31,7 +31,7 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) Geom::Matrix transform; if (absolute) { - transform = sp_item_i2doc_affine(item); + transform = item->i2doc_affine(); } else { transform = Geom::identity(); diff --git a/src/live_effects/parameter/path-reference.h b/src/live_effects/parameter/path-reference.h index 67508e531..53b9ade04 100644 --- a/src/live_effects/parameter/path-reference.h +++ b/src/live_effects/parameter/path-reference.h @@ -10,6 +10,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index d8d5b0a7c..e662f7d95 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -209,7 +209,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt) ShapeRecord r; r.role = SHAPE_ROLE_LPE_PARAM; - r.edit_transform = sp_item_i2d_affine(item); // TODO is it right? + r.edit_transform = item->i2d_affine(); // TODO is it right? if (!href) { r.item = reinterpret_cast(param_effect->getLPEObj()); r.lpe_key = param_key; diff --git a/src/main.cpp b/src/main.cpp index 9f7bc9ad3..5cb317a44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1201,7 +1201,7 @@ do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const g SPItem *item = ((SPItem *) o); // "true" SVG bbox for scripting - Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect area = item->getBounds(item->i2doc_affine()); if (area) { Inkscape::SVGOStringStream os; if (extent) { @@ -1234,7 +1234,7 @@ do_query_all_recurse (SPObject *o) { SPItem *item = ((SPItem *) o); if (o->getId() && SP_IS_ITEM(item)) { - Geom::OptRect area = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect area = item->getBounds(item->i2doc_affine()); if (area) { Inkscape::SVGOStringStream os; os << o->getId(); @@ -1329,7 +1329,7 @@ sp_do_export_png(SPDocument *doc) // write object bbox to area sp_document_ensure_up_to_date (doc); Geom::OptRect areaMaybe; - sp_item_invoke_bbox((SPItem *) o_area, areaMaybe, sp_item_i2d_affine((SPItem *) o_area), TRUE); + static_cast(o_area)->invoke_bbox( areaMaybe, static_cast(o_area)->i2d_affine(), TRUE); if (areaMaybe) { area = *areaMaybe; } else { diff --git a/src/marker.cpp b/src/marker.cpp index e4c2e0c30..e02276215 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -740,7 +740,7 @@ generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::M dup_transform = Geom::identity(); dup_transform *= move; - sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform); + copy->doWriteTransform(SP_OBJECT_REPR(copy), dup_transform); } Inkscape::GC::release(repr); diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 1d81aa7f5..4cd365bb8 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -483,7 +483,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom g_assert(item != NULL); SPBox3D *box = SP_BOX3D(item); - Geom::Matrix const i2d (sp_item_i2d_affine (item)); + Geom::Matrix const i2d (item->i2d_affine ()); Box3D::Axis movement; if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { @@ -659,7 +659,7 @@ Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point co Geom::Point const s = snap_knot_position(new_pos); SPBox3D *box = SP_BOX3D(item); - Geom::Matrix const i2d (sp_item_i2d_affine (item)); + Geom::Matrix const i2d (item->i2d_affine ()); box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, state & GDK_CONTROL_MASK); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index bced0ac44..cbf1dab6f 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -122,11 +122,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, // we should also consider that path or mask for snapping to obj = SP_OBJECT(item->clip_ref->getObject()); if (obj) { - _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item)); + _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); } obj = SP_OBJECT(item->mask_ref->getObject()); if (obj) { - _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item)); + _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->i2doc_affine()); } } } @@ -138,12 +138,11 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, if (clip_or_mask) { // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to // insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine) - sp_item_invoke_bbox(item, - bbox_of_item, - sp_item_i2doc_affine(item) * additional_affine * _snapmanager->getDesktop()->doc2dt(), + item->invoke_bbox(bbox_of_item, + item->i2doc_affine() * additional_affine * _snapmanager->getDesktop()->doc2dt(), true); } else { - sp_item_invoke_bbox(item, bbox_of_item, sp_item_i2d_affine(item), true); + item->invoke_bbox( bbox_of_item, item->i2d_affine(), true); } if (bbox_of_item) { // See if the item is within range @@ -227,7 +226,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, _snapmanager->snapprefs.setSnapIntersectionCS(false); } - sp_item_snappoints(root_item, *_points_to_snap_to, &_snapmanager->snapprefs); + root_item->getSnappoints(*_points_to_snap_to, &_snapmanager->snapprefs); if (_snapmanager->snapprefs.getSnapToItemPath()) { _snapmanager->snapprefs.setSnapIntersectionCS(old_pref); @@ -239,7 +238,7 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::SnapSourceType const &t, // Discard the bbox of a clipped path / mask, because we don't want to snap to both the bbox // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { - Geom::OptRect b = sp_item_bbox_desktop(root_item, bbox_type); + Geom::OptRect b = root_item->getBboxDesktop(bbox_type); getBBoxPoints(b, _points_to_snap_to, true, _snapmanager->snapprefs.getSnapToBBoxNode(), _snapmanager->snapprefs.getSnapBBoxEdgeMidpoints(), _snapmanager->snapprefs.getSnapBBoxMidpoints()); } } @@ -351,7 +350,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const & root_item = sp_use_root(SP_USE((*i).item)); g_return_if_fail(root_item); } else { - i2doc = sp_item_i2doc_affine((*i).item); + i2doc = (*i).item->i2doc_affine(); root_item = (*i).item; } @@ -398,10 +397,10 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::SnapCandidatePoint const & // of the item AND the bbox of the clipping path at the same time if (!(*i).clip_or_mask) { Geom::OptRect rect; - sp_item_invoke_bbox(root_item, rect, i2doc, TRUE, bbox_type); + root_item->invoke_bbox( rect, i2doc, TRUE, bbox_type); if (rect) { Geom::PathVector *path = _getPathvFromRect(*rect); - rect = sp_item_bbox_desktop(root_item, bbox_type); + rect = root_item->getBboxDesktop(bbox_type); _paths_to_snap_to->push_back(Inkscape::SnapCandidatePath(path, SNAPTARGET_BBOX_EDGE, rect)); } } diff --git a/src/print.cpp b/src/print.cpp index ed9b8d19c..7b582b0d1 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -104,14 +104,14 @@ sp_print_preview_document(SPDocument *doc) /* Create new arena */ mod->base = SP_ITEM(sp_document_root(doc)); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new(1); - mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); + (mod->base)->invoke_print(&context); ret = mod->finish(); /* Release arena */ - sp_item_invoke_hide(mod->base, mod->dkey); + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref((NRObject *) mod->arena); @@ -129,9 +129,9 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) // Build arena SPItem *base = SP_ITEM(sp_document_root(doc)); NRArena *arena = NRArena::create(); - unsigned int dkey = sp_item_display_key_new(1); + unsigned int dkey = SPItem::display_key_new(1); // TODO investigate why we are grabbing root and then ignoring it. - NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY); // Run print dialog Inkscape::UI::Dialog::Print printop(doc,base); @@ -139,7 +139,7 @@ sp_print_document(Gtk::Window& parentWindow, SPDocument *doc) (void)res; // TODO handle this // Release arena - sp_item_invoke_hide(base, dkey); + base->invoke_hide(dkey); nr_object_unref((NRObject *) arena); } @@ -165,14 +165,14 @@ sp_print_document_to_file(SPDocument *doc, gchar const *filename) /* Create new arena */ mod->base = SP_ITEM(sp_document_root(doc)); mod->arena = NRArena::create(); - mod->dkey = sp_item_display_key_new(1); - mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); + mod->dkey = SPItem::display_key_new(1); + mod->root = (mod->base)->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY); /* Print document */ ret = mod->begin(doc); - sp_item_invoke_print(mod->base, &context); + (mod->base)->invoke_print(&context); ret = mod->finish(); /* Release arena */ - sp_item_invoke_hide(mod->base, mod->dkey); + (mod->base)->invoke_hide(mod->dkey); mod->base = NULL; mod->root = NULL; nr_object_unref((NRObject *) mod->arena); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 7ae27c13d..b232a340a 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -471,7 +471,7 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state) rc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); Inkscape::GC::release(repr); - rc.item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + rc.item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); rc.item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 975b4becb..a804ceb5f 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -48,7 +48,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG ++it) { using Geom::X; using Geom::Y; - Geom::OptRect item_box(sp_item_bbox_desktop(*it)); + Geom::OptRect item_box((*it)->getBboxDesktop()); if (item_box) { Geom::Point min(item_box->min() - .5*gap); Geom::Point max(item_box->max() + .5*gap); diff --git a/src/selcue.cpp b/src/selcue.cpp index 8756524dd..0b28a8aef 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -84,7 +84,7 @@ void Inkscape::SelCue::_updateItemBboxes() SPCanvasItem* box = _item_bboxes[bcount ++]; if (box) { - Geom::OptRect const b = sp_item_bbox_desktop(item, bbox_type); + Geom::OptRect const b = item->getBboxDesktop(bbox_type); if (b) { sp_canvas_item_show(box); @@ -125,7 +125,7 @@ void Inkscape::SelCue::_newItemBboxes() for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { SPItem *item = (SPItem *) l->data; - Geom::OptRect const b = sp_item_bbox_desktop(item, bbox_type); + Geom::OptRect const b = item->getBboxDesktop(bbox_type); SPCanvasItem* box = NULL; @@ -192,7 +192,7 @@ void Inkscape::SelCue::_newTextBaselines() NULL); sp_canvas_item_show(baseline_point); - SP_CTRL(baseline_point)->moveto((*pt) * sp_item_i2d_affine(item)); + SP_CTRL(baseline_point)->moveto((*pt) * item->i2d_affine()); sp_canvas_item_move_to_z(baseline_point, 0); } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index cc153aa71..8237537c8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -241,7 +241,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D // Copy item reprs: for (GSList *i = (GSList *) sorted_items; i != NULL; i = i->next) { - sp_selection_copy_one(SP_OBJECT_REPR(i->data), sp_item_i2doc_affine(SP_ITEM(i->data)), clip, xml_doc); + sp_selection_copy_one(SP_OBJECT_REPR(i->data), SP_ITEM(i->data)->i2doc_affine(), clip, xml_doc); } *clip = g_slist_reverse(*clip); @@ -259,7 +259,7 @@ GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip Inkscape::XML::Node *copy = repr->duplicate(xml_doc); // premultiply the item transform by the accumulated parent transform in the paste layer - Geom::Matrix local(sp_item_i2doc_affine(SP_ITEM(parent))); + Geom::Matrix local(SP_ITEM(parent)->i2doc_affine()); if (!local.isIdentity()) { gchar const *t_str = copy->attribute("transform"); Geom::Matrix item_t(Geom::identity()); @@ -584,7 +584,7 @@ void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XM Geom::Matrix item_t(Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); - item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent()))); + item_t *= SP_ITEM(doc->getObjectByRepr(current->parent()))->i2doc_affine(); // FIXME: when moving both clone and original from a transformed group (either by // grouping into another parent, or by cut/paste) the transform from the original's // parent becomes embedded into original itself, and this affects its clones. Fix @@ -770,7 +770,7 @@ enclose_items(GSList const *items) Geom::OptRect r; for (GSList const *i = items; i; i = i->next) { - r = Geom::unify(r, sp_item_bbox_desktop((SPItem *) i->data)); + r = Geom::unify(r, ((SPItem *) i->data)->getBboxDesktop()); } return r; } @@ -826,7 +826,7 @@ sp_selection_raise(SPDesktop *desktop) for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, if (SP_IS_ITEM(newref)) { - Geom::OptRect newref_bbox = sp_item_bbox_desktop(SP_ITEM(newref)); + Geom::OptRect newref_bbox = SP_ITEM(newref)->getBboxDesktop(); if ( newref_bbox && selected->intersects(*newref_bbox) ) { // AND if it's not one of our selected objects, if (!g_slist_find((GSList *) items, newref)) { @@ -923,7 +923,7 @@ sp_selection_lower(SPDesktop *desktop) for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, if (SP_IS_ITEM(newref)) { - Geom::OptRect ref_bbox = sp_item_bbox_desktop(SP_ITEM(newref)); + Geom::OptRect ref_bbox = SP_ITEM(newref)->getBboxDesktop(); if ( ref_bbox && selected->intersects(*ref_bbox) ) { // AND if it's not one of our selected objects, if (!g_slist_find((GSList *) items, newref)) { @@ -1047,7 +1047,7 @@ take_style_from_item(SPItem *item) } // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive - double ex = to_2geom(sp_item_i2doc_affine(item)).descrim(); + double ex = to_2geom(item->i2doc_affine()).descrim(); if (ex != 1.0) { css = sp_css_attr_scale(css, ex); } @@ -1383,7 +1383,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons continue; for (SPObject *use = region->firstChild() ; use ; use = SP_OBJECT_NEXT(use)) { if (!SP_IS_USE(use)) continue; - sp_item_write_transform(SP_USE(use), SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); + SP_USE(use)->doWriteTransform(SP_OBJECT_REPR(use), item->transform.inverse(), NULL, compensate); } } } else if (transform_clone_with_original) { @@ -1395,7 +1395,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons sp_object_read_attr(SP_OBJECT(item), "transform"); // calculate the matrix we need to apply to the clone to cancel its induced transform from its original - Geom::Matrix parent2dt = sp_item_i2d_affine(SP_ITEM(SP_OBJECT_PARENT(item))); + Geom::Matrix parent2dt = SP_ITEM(SP_OBJECT_PARENT(item))->i2d_affine(); Geom::Matrix t = parent2dt * affine * parent2dt.inverse(); Geom::Matrix t_inv = t.inverse(); Geom::Matrix result = t_inv * item->transform * t; @@ -1409,25 +1409,25 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons if (prefs_parallel) { Geom::Matrix move = result * clone_move * t_inv; - sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &move, compensate); + item->doWriteTransform(SP_OBJECT_REPR(item), move, &move, compensate); } else if (prefs_unmoved) { //if (SP_IS_USE(sp_use_get_original(SP_USE(item)))) // clone_move = Geom::identity(); Geom::Matrix move = result * clone_move; - sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &t, compensate); + item->doWriteTransform(SP_OBJECT_REPR(item), move, &t, compensate); } } else { // just apply the result - sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t, compensate); + item->doWriteTransform(SP_OBJECT_REPR(item), result, &t, compensate); } } else { if (set_i2d) { - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine); + item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine); } - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, NULL, compensate); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, NULL, compensate); } // if we're moving the actual object, not just updating the repr, we can transform the @@ -1993,7 +1993,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, void scroll_to_show_item(SPDesktop *desktop, SPItem *item) { Geom::Rect dbox = desktop->get_display_area(); - Geom::OptRect sbox = sp_item_bbox_desktop(item); + Geom::OptRect sbox = item->getBboxDesktop(); if ( sbox && dbox.contains(*sbox) == false ) { Geom::Point const s_dt = sbox->midpoint(); @@ -2224,8 +2224,8 @@ sp_select_clone_original(SPDesktop *desktop) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool highlight = prefs->getBool("/options/highlightoriginal/value"); if (highlight) { - Geom::OptRect a = item->getBounds(sp_item_i2d_affine(item)); - Geom::OptRect b = original->getBounds(sp_item_i2d_affine(original)); + Geom::OptRect a = item->getBounds(item->i2d_affine()); + Geom::OptRect b = original->getBounds(original->i2d_affine()); if ( a && b ) { // draw a flashing line between the objects SPCurve *curve = new SPCurve(); @@ -2284,7 +2284,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT(items->data); - Geom::Matrix parent_transform(sp_item_i2doc_affine(SP_ITEM(parent))); + Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine()); // remember the position of the first item gint pos = SP_OBJECT_REPR(items->data)->position(); @@ -2338,7 +2338,7 @@ static void sp_selection_to_guides_recursive(SPItem *item, bool deleteitem, bool sp_selection_to_guides_recursive(SP_ITEM(i->data), deleteitem, wholegroups); } } else { - sp_item_convert_item_to_guides(item); + item->convert_item_to_guides(); if (deleteitem) { SP_OBJECT(item)->deleteObject(true); @@ -2407,7 +2407,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT(items->data); - Geom::Matrix parent_transform(sp_item_i2doc_affine(SP_ITEM(parent))); + Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine()); // remember the position of the first item gint pos = SP_OBJECT_REPR(items->data)->position(); @@ -2531,7 +2531,7 @@ sp_selection_untile(SPDesktop *desktop) sp_document_ensure_up_to_date(doc); Geom::Matrix transform( i->transform * pat_transform ); - sp_item_write_transform(i, SP_OBJECT_REPR(i), transform); + i->doWriteTransform(SP_OBJECT_REPR(i), transform); new_select = g_slist_prepend(new_select, i); } @@ -2744,7 +2744,7 @@ sp_selection_create_bitmap_copy(SPDesktop *desktop) } // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects - Geom::Matrix eek(sp_item_i2d_affine(SP_ITEM(parent_object))); + Geom::Matrix eek(SP_ITEM(parent_object)->i2d_affine()); Geom::Matrix t; double shift_x = bbox.x0; @@ -3128,7 +3128,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { // transform mask, so it is moved the same spot where mask was applied Geom::Matrix transform(mask_item->transform); transform *= (*it).second->transform; - sp_item_write_transform(mask_item, SP_OBJECT_REPR(mask_item), transform); + mask_item->doWriteTransform(SP_OBJECT_REPR(mask_item), transform); } g_slist_free(items_to_move); @@ -3205,7 +3205,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) sp_document_ensure_up_to_date(doc); SPItem const *const root = SP_ITEM(doc->root); - Geom::OptRect const bbox(root->getBounds(sp_item_i2d_affine(root))); + Geom::OptRect const bbox(root->getBounds(root->i2d_affine())); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 1f975975a..48d1a2d16 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -17,6 +17,7 @@ */ #include "forward.h" +#include "sp-item.h" #include "2geom/forward.h" namespace Inkscape { class Selection; } diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 9321ea0ef..bd8d8e12e 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -182,7 +182,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free (parent_name); if (!items->next) { // one item - char *item_desc = sp_item_description(item); + char *item_desc = item->description(); if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, diff --git a/src/selection.cpp b/src/selection.cpp index 96c66e0c5..acf6a8e6e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -374,7 +374,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect bbox; for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox = unify(bbox, sp_item_bbox_desktop(SP_ITEM(i->data), type)); + bbox = unify(bbox, SP_ITEM(i->data)->getBboxDesktop(type)); } return bbox; } @@ -393,8 +393,8 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { SPItem *item=SP_ITEM(iter->data); - Geom::Matrix i2doc(sp_item_i2doc_affine(item)); - sp_item_invoke_bbox(item, bbox, i2doc, FALSE, type); + Geom::Matrix i2doc(item->i2doc_affine()); + item->invoke_bbox( bbox, i2doc, FALSE, type); } return bbox; @@ -436,7 +436,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { SPItem *this_item = SP_ITEM(iter->data); - sp_item_snappoints(this_item, p, &snapprefs_dummy); + this_item->getSnappoints(p, &snapprefs_dummy); //Include the transformation origin for snapping //For a selection or group only the overall origin is considered @@ -458,7 +458,7 @@ std::vector Selection::getSnapPointsConvexHull(Sna std::vector p; for (GSList const *iter = items; iter != NULL; iter = iter->next) { - sp_item_snappoints(SP_ITEM(iter->data), p, &snapprefs_dummy); + SP_ITEM(iter->data)->getSnappoints(p, &snapprefs_dummy); } std::vector pHull; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 05f47d4ab..89799246c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -265,7 +265,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s SPItem *it = (SPItem *)sp_object_ref(SP_OBJECT(l->data), NULL); _items.push_back(it); _items_const.push_back(it); - _items_affines.push_back(sp_item_i2d_affine(it)); + _items_affines.push_back(it->i2d_affine()); _items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers } @@ -333,7 +333,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s // More than 50 items will produce at least 200 bbox points, which might make Inkscape crawl // (see the comment a few lines above). In that case we will use the bbox of the selection as a whole for (unsigned i = 0; i < _items.size(); i++) { - getBBoxPoints(sp_item_bbox_desktop(_items[i], _snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp); + getBBoxPoints(_items[i]->getBboxDesktop(_snap_bbox_type), &_bbox_points_for_translating, false, true, emp, mp); } } else { _bbox_points_for_translating = _bbox_points; // use the bbox points of the selection as a whole @@ -444,7 +444,7 @@ void Inkscape::SelTrans::transform(Geom::Matrix const &rel_affine, Geom::Point c for (unsigned i = 0; i < _items.size(); i++) { SPItem &item = *_items[i]; Geom::Matrix const &prev_transform = _items_affines[i]; - sp_item_set_i2d_affine(&item, prev_transform * affine); + item.set_i2d_affine(prev_transform * affine); } } else { if (_bbox) { @@ -599,15 +599,15 @@ void Inkscape::SelTrans::stamp() Geom::Matrix const *new_affine; if (_show == SHOW_OUTLINE) { - Geom::Matrix const i2d(sp_item_i2d_affine(original_item)); + Geom::Matrix const i2d(original_item->i2d_affine()); Geom::Matrix const i2dnew( i2d * _current_relative_affine ); - sp_item_set_i2d_affine(copy_item, i2dnew); + copy_item->set_i2d_affine(i2dnew); new_affine = ©_item->transform; } else { new_affine = &original_item->transform; } - sp_item_write_transform(copy_item, copy_repr, *new_affine); + copy_item->doWriteTransform(copy_repr, *new_affine); if ( copy_item->isCenterSet() && _center ) { copy_item->setCenter(*_center * _current_relative_affine); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 4bbabc965..9cd2b2ca4 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -166,8 +166,7 @@ sp_clippath_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape:: if (SP_IS_ITEM(ochild)) { SPClipPath *cp = SP_CLIPPATH(object); for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { - NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(ochild), - NR_ARENA_ITEM_ARENA(v->arenaitem), + NRArenaItem *ac = SP_ITEM(ochild)->invoke_show( NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, SP_ITEM_REFERENCE_FLAGS); if (ac) { @@ -267,7 +266,7 @@ sp_clippath_show(SPClipPath *cp, NRArena *arena, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { - NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(child), arena, key, SP_ITEM_REFERENCE_FLAGS); + NRArenaItem *ac = SP_ITEM(child)->invoke_show(arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ nr_arena_item_add_child(ai, ac, NULL); @@ -293,7 +292,7 @@ sp_clippath_hide(SPClipPath *cp, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM(child)) { - sp_item_invoke_hide(SP_ITEM(child), key); + SP_ITEM(child)->invoke_hide(key); } } @@ -331,13 +330,13 @@ sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, Geom::Matrix const &transform for (i = sp_object_first_child(SP_OBJECT(cp)); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i)){}; if (!i) return; - sp_item_invoke_bbox_full(SP_ITEM(i), bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); + SP_ITEM(i)->invoke_bbox_full( bbox, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); SPObject *i_start = i; while (i != NULL) { if (i != i_start) { NRRect i_box; - sp_item_invoke_bbox_full(SP_ITEM(i), &i_box, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); + SP_ITEM(i)->invoke_bbox_full( &i_box, Geom::Matrix(SP_ITEM(i)->transform) * transform, SPItem::GEOMETRIC_BBOX, FALSE); nr_rect_d_union (bbox, bbox, &i_box); } i = SP_OBJECT_NEXT(i); @@ -400,7 +399,7 @@ sp_clippath_create (GSList *reprs, SPDocument *document, Geom::Matrix const* app if (NULL != applyTransform) { Geom::Matrix transform (item->transform); transform *= (*applyTransform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), transform); + item->doWriteTransform(SP_OBJECT_REPR(item), transform); } } diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 7f019979a..24c7e7e5c 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -405,7 +405,7 @@ SPConnEndPair::reroutePathFromLibavoid(void) recreateCurve( curve, _connRef, _connCurvature ); - Geom::Matrix doc2item = sp_item_i2doc_affine(SP_ITEM(_path)).inverse(); + Geom::Matrix doc2item = SP_ITEM(_path)->i2doc_affine().inverse(); curve->transform(doc2item); return true; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 88fc59f17..86b6106c5 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -281,7 +281,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, std::vectori2d_affine(); // figure out if we have a slice, while guarding against rounding errors bool slice = false; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index b01146d60..5f3517f92 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -177,7 +177,7 @@ sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) group->rebuildLayout(); NRRect paintbox; - sp_item_invoke_bbox(group, &paintbox, Geom::identity(), TRUE); + group->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView *v = group->display; v != NULL; v = v->next) { group->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -199,7 +199,7 @@ sp_flowtext_modified(SPObject *object, guint flags) if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPFlowtext *text = SP_FLOWTEXT(object); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); + text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -351,9 +351,9 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) SPFlowtext *group = SP_FLOWTEXT(item); NRRect pbox; - sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); + item->invoke_bbox( &pbox, Geom::identity(), TRUE); NRRect bbox; - Geom::OptRect bbox_maybe = sp_item_bbox_desktop(item); + Geom::OptRect bbox_maybe = item->getBboxDesktop(); if (!bbox_maybe) { return; } @@ -364,7 +364,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = sp_document_width(SP_OBJECT_DOCUMENT(item)); dbox.y1 = sp_document_height(SP_OBJECT_DOCUMENT(item)); - Geom::Matrix const ctm (sp_item_i2d_affine(item)); + Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx, &pbox, &dbox, &bbox, ctm); } @@ -392,7 +392,7 @@ static void sp_flowtext_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); } } } @@ -408,7 +408,7 @@ sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flag // pass the bbox of the flowtext object as paintbox (used for paintserver fills) NRRect paintbox; - sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE); + item->invoke_bbox( &paintbox, Geom::identity(), TRUE); group->layout.show(flowed, &paintbox); return flowed; @@ -742,7 +742,7 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, Inkscape::GC::release(para_repr); Inkscape::GC::release(rect_repr); - ft_item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + ft_item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); return ft_item; } diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h index bc188401b..209bc7efb 100644 --- a/src/sp-gradient-test.h +++ b/src/sp-gradient-test.h @@ -25,7 +25,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/sp-guide-attachment.h b/src/sp-guide-attachment.h index 277b435b6..5e3688b88 100644 --- a/src/sp-guide-attachment.h +++ b/src/sp-guide-attachment.h @@ -2,6 +2,7 @@ #define __SP_GUIDE_ATTACHMENT_H__ #include +#include "sp-item.h" class SPGuideAttachment { public: diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 68bafdeab..367d2e489 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -569,7 +569,7 @@ sp_image_get_type (void) (GInstanceInitFunc) sp_image_init, NULL, /* value_table */ }; - image_type = g_type_register_static (sp_item_get_type (), "SPImage", &image_info, (GTypeFlags)0); + image_type = g_type_register_static (SPItem::getType (), "SPImage", &image_info, (GTypeFlags)0); } return image_type; } @@ -585,7 +585,7 @@ sp_image_class_init (SPImageClass * klass) sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - parent_class = (SPItemClass*)g_type_class_ref (sp_item_get_type ()); + parent_class = (SPItemClass*)g_type_class_ref (SPItem::getType ()); sp_object_class->build = sp_image_build; sp_object_class->release = sp_image_release; @@ -1352,7 +1352,7 @@ static void sp_image_snappoints(SPItem const *item, std::vectori2d_affine ()); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y0) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x0, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(x1, y1) * i2d, Inkscape::SNAPSOURCE_CORNER, Inkscape::SNAPTARGET_CORNER)); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 588427752..2369ce38a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -331,7 +331,7 @@ static void sp_group_snappoints (SPItem const *item, std::vectorgetSnappoints(p, snapprefs); } } } @@ -353,7 +353,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch")); // this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse - sp_item_adjust_paint_recursive (gitem, Geom::identity(), Geom::identity(), false); + gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem)); Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem); @@ -377,7 +377,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) /* Merging of style */ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // it here _before_ the new transform is set, so as to use the pre-transform bbox - sp_item_adjust_paint_recursive (citem, Geom::identity(), Geom::identity(), false); + citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem)); /* @@ -487,7 +487,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) // fill in the children list if non-null SPItem *item = (SPItem *) doc->getObjectByRepr(repr); - sp_item_write_transform(item, repr, item->transform, NULL, false); + item->doWriteTransform(repr, item->transform, NULL, false); Inkscape::GC::release(repr); if (children && SP_IS_ITEM (item)) @@ -604,7 +604,7 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) { NRArenaItem *ac; for (v = _group->display; v != NULL; v = v->next) { - ac = sp_item_invoke_show (SP_ITEM (ochild), NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); + ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); if (ac) { nr_arena_item_append_child (v->arenaitem, ac); @@ -618,10 +618,10 @@ void CGroup::onChildAdded(Inkscape::XML::Node *child) { SPItemView *v; NRArenaItem *ac; - unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild)); + unsigned position = SP_ITEM(ochild)->pos_in_parent(); for (v = _group->display; v != NULL; v = v->next) { - ac = sp_item_invoke_show (SP_ITEM (ochild), NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); + ac = SP_ITEM (ochild)->invoke_show (NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, v->flags); if (ac) { nr_arena_item_add_child (v->arenaitem, ac, NULL); @@ -709,7 +709,7 @@ void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); Geom::Matrix const ct(to_2geom(child->transform) * transform); - sp_item_invoke_bbox_full(child, dummy_bbox, ct, flags, FALSE); + child->invoke_bbox_full( dummy_bbox, ct, flags, FALSE); } l = g_slist_remove (l, o); } @@ -722,7 +722,7 @@ void CGroup::onPrint(SPPrintContext *ctx) { while (l) { SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM(o)) { - sp_item_invoke_print (SP_ITEM (o), ctx); + SP_ITEM(o)->invoke_print (ctx); } l = g_slist_remove (l, o); } @@ -771,7 +771,7 @@ void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, u SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM (o)) { child = SP_ITEM (o); - ac = sp_item_invoke_show (child, arena, key, flags); + ac = child->invoke_show (arena, key, flags); if (ac) { nr_arena_item_add_child (ai, ac, ar); ar = ac; @@ -789,7 +789,7 @@ void CGroup::hide (unsigned int key) { SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM (o)) { child = SP_ITEM (o); - sp_item_invoke_hide (child, key); + child->invoke_hide (key); } l = g_slist_remove (l, o); } @@ -804,7 +804,7 @@ void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *, if ( ochild && SP_IS_ITEM(ochild) ) { /* TODO: this should be moved into SPItem somehow */ SPItemView *v; - unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild)); + unsigned position = SP_ITEM(ochild)->pos_in_parent(); for ( v = SP_ITEM (ochild)->display ; v != NULL ; v = v->next ) { nr_arena_item_set_order (v->arenaitem, position); } diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 628d77956..340aac1ac 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -25,7 +25,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin g_return_if_fail( dir_lensq != 0 ); std::vector snappoints; - sp_item_snappoints(&item, snappoints, NULL); + item.getSnappoints(snappoints, NULL); g_return_if_fail( snappoint_ix < int(snappoints.size()) ); double const pos0 = dot(dir, snappoints[snappoint_ix].getPoint()); @@ -41,7 +41,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin s = (position - pos0) / dot(dir, dir). */ Geom::Translate const tr( ( position - pos0 ) * ( dir / dir_lensq ) ); - sp_item_set_i2d_affine(&item, sp_item_i2d_affine(&item) * tr); + item.set_i2d_affine(item.i2d_affine() * tr); /// \todo Reget snappoints, check satisfied. if (commit) { @@ -49,7 +49,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin /* Commit repr. */ { - sp_item_write_transform(&item, SP_OBJECT_REPR(&item), item.transform); + item.doWriteTransform(SP_OBJECT_REPR(&item), item.transform); } sp_item_rm_unsatisfied_cns(item); diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index 792a9d3bf..e92a573f1 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -15,7 +15,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item) return; } std::vector snappoints; - sp_item_snappoints(&item, snappoints, NULL); + item.getSnappoints(snappoints, NULL); for (unsigned i = item.constraints.size(); i--;) { g_assert( i < item.constraints.size() ); SPGuideConstraint const &cn = item.constraints[i]; diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 23c0bdf33..275d6b046 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -25,9 +25,9 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s); // Rotate item. - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine); + item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine); // Use each item's own transform writer, consistent with sp_selection_apply_affine() - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); // Restore the center position (it's changed because the bbox center changed) if (item->isCenterSet()) { @@ -39,11 +39,11 @@ sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) { - Geom::OptRect bbox = sp_item_bbox_desktop(item); + Geom::OptRect bbox = item->getBboxDesktop(); if (bbox) { Geom::Translate const s(bbox->midpoint()); // use getCenter? - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s); - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); } } @@ -56,8 +56,8 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) Geom::Matrix const skew(1, skewY, skewX, 1, 0, 0); Geom::Matrix affine = Geom::Matrix(s).inverse() * skew * Geom::Matrix(s); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->set_i2d_affine(item->i2d_affine() * affine); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); // Restore the center position (it's changed because the bbox center changed) if (item->isCenterSet()) { @@ -68,9 +68,9 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) { - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * tr); + item->set_i2d_affine(item->i2d_affine() * tr); - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); } /* diff --git a/src/sp-item-update-cns.cpp b/src/sp-item-update-cns.cpp index 51da1679d..e1b3989dc 100644 --- a/src/sp-item-update-cns.cpp +++ b/src/sp-item-update-cns.cpp @@ -10,7 +10,7 @@ using std::vector; void sp_item_update_cns(SPItem &item, SPDesktop const &desktop) { std::vector snappoints; - sp_item_snappoints(&item, snappoints, NULL); + item.getSnappoints(snappoints, NULL); /* TODO: Implement the ordering. */ vector found_cns; satisfied_guide_cns(desktop, snappoints, found_cns); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5a2dfb2f0..e5f8eade1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -80,38 +80,40 @@ #define noSP_ITEM_DEBUG_IDLE -static void sp_item_class_init(SPItemClass *klass); -static void sp_item_init(SPItem *item); +//static void sp_item_class_init(SPItemClass *klass); +//static void sp_item_init(SPItem *item); -static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -static void sp_item_release(SPObject *object); -static void sp_item_set(SPObject *object, unsigned key, gchar const *value); -static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); -static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +//static void sp_item_release(SPObject *object); +//static void sp_item_set(SPObject *object, unsigned key, gchar const *value); +//static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); +//static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar *sp_item_private_description(SPItem *item); -static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); +//static gchar *sp_item_private_description(SPItem *item); +//static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); -static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); +//static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); +//static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); -static SPObjectClass *parent_class; +//static SPObjectClass *parent_class; -static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); -static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); +//static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); +//static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); + +SPObjectClass * SPItemClass::static_parent_class=0; /** * Registers SPItem class and returns its type number. */ GType -sp_item_get_type(void) +SPItem::getType(void) { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPItemClass), NULL, NULL, - (GClassInitFunc) sp_item_class_init, + (GClassInitFunc) SPItemClass::sp_item_class_init, NULL, NULL, sizeof(SPItem), 16, @@ -126,28 +128,28 @@ sp_item_get_type(void) /** * SPItem vtable initialization. */ -static void -sp_item_class_init(SPItemClass *klass) +void +SPItemClass::sp_item_class_init(SPItemClass *klass) { SPObjectClass *sp_object_class = (SPObjectClass *) klass; - parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); + static_parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT); - sp_object_class->build = sp_item_build; - sp_object_class->release = sp_item_release; - sp_object_class->set = sp_item_set; - sp_object_class->update = sp_item_update; - sp_object_class->write = sp_item_write; + sp_object_class->build = SPItem::sp_item_build; + sp_object_class->release = SPItem::sp_item_release; + sp_object_class->set = SPItem::sp_item_set; + sp_object_class->update = SPItem::sp_item_update; + sp_object_class->write = SPItem::sp_item_write; - klass->description = sp_item_private_description; - klass->snappoints = sp_item_private_snappoints; + klass->description = SPItem::sp_item_private_description; + klass->snappoints = SPItem::sp_item_private_snappoints; } /** * Callback for SPItem object initialization. */ -static void -sp_item_init(SPItem *item) +void +SPItem::sp_item_init(SPItem *item) { item->init(); } @@ -296,7 +298,7 @@ SPItem::setCenter(Geom::Point object_centre) { // for getBounds() to work sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); - Geom::OptRect bbox = getBounds(sp_item_i2d_affine(this)); + Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { transform_center_x = object_centre[Geom::X] - bbox->midpoint()[Geom::X]; if (fabs(transform_center_x) < 1e-5) // rounding error @@ -321,7 +323,7 @@ Geom::Point SPItem::getCenter() const { // for getBounds() to work sp_document_ensure_up_to_date(SP_OBJECT_DOCUMENT(this)); - Geom::OptRect bbox = getBounds(sp_item_i2d_affine(this)); + Geom::OptRect bbox = getBounds(i2d_affine()); if (bbox) { return to_2geom(bbox->midpoint()) + Geom::Point (this->transform_center_x, this->transform_center_y); } else { @@ -400,8 +402,8 @@ void SPItem::lowerToBottom() { } } -static void -sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +void +SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { sp_object_read_attr(object, "style"); sp_object_read_attr(object, "transform"); @@ -414,13 +416,13 @@ sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) sp_object_read_attr(object, "inkscape:connector-avoid"); sp_object_read_attr(object, "inkscape:connection-points"); - if (((SPObjectClass *) (parent_class))->build) { - (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->build) { + (* ((SPObjectClass *) (SPItemClass::static_parent_class))->build)(object, document, repr); } } -static void -sp_item_release(SPObject *object) +void +SPItem::sp_item_release(SPObject *object) { SPItem *item = (SPItem *) object; @@ -447,8 +449,8 @@ sp_item_release(SPObject *object) item->mask_ref = NULL; } - if (((SPObjectClass *) (parent_class))->release) { - ((SPObjectClass *) parent_class)->release(object); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->release) { + ((SPObjectClass *) SPItemClass::static_parent_class)->release(object); } while (item->display) { @@ -459,8 +461,8 @@ sp_item_release(SPObject *object) item->_transformed_signal.~signal(); } -static void -sp_item_set(SPObject *object, unsigned key, gchar const *value) +void +SPItem::sp_item_set(SPObject *object, unsigned key, gchar const *value) { SPItem *item = (SPItem *) object; @@ -468,9 +470,9 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value) case SP_ATTR_TRANSFORM: { Geom::Matrix t; if (value && sp_svg_transform_read(value, &t)) { - sp_item_set_item_transform(item, t); + item->set_item_transform(t); } else { - sp_item_set_item_transform(item, Geom::identity()); + item->set_item_transform(Geom::identity()); } break; } @@ -546,16 +548,16 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value) sp_style_read_from_object(object->style, object); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { - if (((SPObjectClass *) (parent_class))->set) { - (* ((SPObjectClass *) (parent_class))->set)(object, key, value); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->set) { + (* ((SPObjectClass *) (SPItemClass::static_parent_class))->set)(object, key, value); } } break; } } -static void -clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) +void +SPItem::clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) { if (old_clip) { SPItemView *v; @@ -567,10 +569,10 @@ clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) } if (SP_IS_CLIPPATH(clip)) { NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + item->invoke_bbox( &bbox, Geom::identity(), TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3)); + NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); } NRArenaItem *ai = sp_clippath_show(SP_CLIPPATH(clip), NR_ARENA_ITEM_ARENA(v->arenaitem), @@ -583,8 +585,8 @@ clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item) } } -static void -mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) +void +SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) { if (old_mask) { /* Hide mask */ @@ -595,10 +597,10 @@ mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } if (SP_IS_MASK(mask)) { NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + item->invoke_bbox( &bbox, Geom::identity(), TRUE); for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3)); + NR_ARENA_ITEM_SET_KEY(v->arenaitem, SPItem::display_key_new(3)); } NRArenaItem *ai = sp_mask_show(SP_MASK(mask), NR_ARENA_ITEM_ARENA(v->arenaitem), @@ -611,13 +613,13 @@ mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) } } -static void -sp_item_update(SPObject *object, SPCtx *ctx, guint flags) +void +SPItem::sp_item_update(SPObject *object, SPCtx *ctx, guint flags) { SPItem *item = SP_ITEM(object); - if (((SPObjectClass *) (parent_class))->update) - (* ((SPObjectClass *) (parent_class))->update)(object, ctx, flags); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->update) + (* ((SPObjectClass *) (SPItemClass::static_parent_class))->update)(object, ctx, flags); if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) { if (flags & SP_OBJECT_MODIFIED_FLAG) { @@ -631,7 +633,7 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags) if ( clip_path || mask ) { NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + item->invoke_bbox( &bbox, Geom::identity(), TRUE); if (clip_path) { for (SPItemView *v = item->display; v != NULL; v = v->next) { sp_clippath_set_bbox(clip_path, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox); @@ -655,7 +657,7 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags) /* Update bounding box data used by filters */ if (item->style->filter.set && item->display) { Geom::OptRect item_bbox; - sp_item_invoke_bbox(item, item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + item->invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); SPItemView *itemview = item->display; do { @@ -669,8 +671,8 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags) item->avoidRef->handleSettingChange(); } -static Inkscape::XML::Node * -sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPItem::sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPObject *child; SPItem *item = SP_ITEM(object); @@ -725,8 +727,8 @@ sp_item_write(SPObject *const object, Inkscape::XML::Document *xml_doc, Inkscape g_free ((void *) value); } - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write(object, xml_doc, repr, flags); + if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) { + ((SPObjectClass *) (SPItemClass::static_parent_class))->write(object, xml_doc, repr, flags); } return repr; @@ -741,21 +743,21 @@ Geom::OptRect SPItem::getBounds(Geom::Matrix const &transform, unsigned int /*dkey*/) const { Geom::OptRect r; - sp_item_invoke_bbox_full(this, r, transform, type, TRUE); + SP_ITEM(this)->invoke_bbox_full( r, transform, type, TRUE); return r; } void -sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) +SPItem::invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, type, clear); + invoke_bbox_full( bbox, transform, type, clear); } // DEPRECATED to phase out the use of NRRect in favor of Geom::OptRect void -sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) +SPItem::invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, type, clear); + invoke_bbox_full( bbox, transform, type, clear); } /** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and @@ -766,10 +768,10 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transf * function returns. If this item does not have a boundingbox, this might well be empty. */ void -sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) +SPItem::invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); if (clear) { bbox = Geom::OptRect(); @@ -782,14 +784,14 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c temp_bbox.x1 = temp_bbox.y1 = -NR_HUGE; // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &temp_bbox, transform, flags); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &temp_bbox, transform, flags); } // unless this is geometric bbox, extend by filter area and crop the bbox by clip path, if any if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) { - if (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href) { - SPObject *filter = SP_OBJECT_STYLE(item)->getFilter(); + if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href) { + SPObject *filter = SP_OBJECT_STYLE(this)->getFilter(); if (filter && SP_IS_FILTER(filter)) { // default filer area per the SVG spec: double x = -0.1; @@ -829,7 +831,7 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c } // transform the expansions by the item's transform: - Geom::Matrix i2d(sp_item_i2d_affine (item)); + Geom::Matrix i2d(i2d_affine ()); dx0 *= i2d.expansionX(); dx1 *= i2d.expansionX(); dy0 *= i2d.expansionY(); @@ -842,9 +844,9 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c temp_bbox.y1 += dy1; } } - if (item->clip_ref->getObject()) { + if (this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); + sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); nr_rect_d_intersect (&temp_bbox, &temp_bbox, &b); } } @@ -874,10 +876,10 @@ sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix c * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, * clones), in turn, call this function in their bbox methods. */ void -sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) +SPItem::invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); g_assert(bbox != NULL); if (clear) { @@ -890,14 +892,14 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &t this_bbox.x1 = this_bbox.y1 = -1e18; // call the subclass method - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &this_bbox, transform, flags); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox) { + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->bbox(this, &this_bbox, transform, flags); } // unless this is geometric bbox, crop the bbox by clip path, if any - if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && item->clip_ref->getObject()) { + if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && this->clip_ref->getObject()) { NRRect b; - sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); + sp_clippath_get_bbox(SP_CLIPPATH(this->clip_ref->getObject()), &b, transform, flags); nr_rect_d_intersect (&this_bbox, &this_bbox, &b); } @@ -907,16 +909,16 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &t } } -unsigned sp_item_pos_in_parent(SPItem *item) +unsigned SPItem::pos_in_parent() { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - SPObject *parent = SP_OBJECT_PARENT(item); + SPObject *parent = SP_OBJECT_PARENT(this); g_assert(parent != NULL); g_assert(SP_IS_OBJECT(parent)); - SPObject *object = SP_OBJECT(item); + SPObject *object = SP_OBJECT(this); unsigned pos=0; for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = SP_OBJECT_NEXT(iter)) { @@ -933,30 +935,30 @@ unsigned sp_item_pos_in_parent(SPItem *item) } void -sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type) +SPItem::getBboxDesktop(NRRect *bbox, SPItem::BBoxType type) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(item != NULL); + //g_assert(SP_IS_ITEM(item)); g_assert(bbox != NULL); - sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( bbox, i2d_affine(), TRUE, type); } -Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type) +Geom::OptRect SPItem::getBboxDesktop(SPItem::BBoxType type) { Geom::OptRect rect = Geom::OptRect(); - sp_item_invoke_bbox(item, rect, sp_item_i2d_affine(item), TRUE, type); + invoke_bbox( rect, i2d_affine(), TRUE, type); return rect; } -static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) +void SPItem::sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const */*snapprefs*/) { /* This will only be called if the derived class doesn't override this. * see for example sp_genericellipse_snappoints in sp-ellipse.cpp * We don't know what shape we could be dealing with here, so we'll just * return the corners of the bounding box */ - Geom::OptRect bbox = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect bbox = item->getBounds(item->i2d_affine()); if (bbox) { Geom::Point p1, p2; @@ -970,27 +972,27 @@ static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs) +void SPItem::getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { - g_assert (item != NULL); - g_assert (SP_IS_ITEM(item)); + //g_assert (this != NULL); + //g_assert (SP_IS_ITEM(this)); // Get the snappoints of the item - SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item); + SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(this); if (item_class.snappoints) { - item_class.snappoints(item, p, snapprefs); + item_class.snappoints(this, p, snapprefs); } // Get the snappoints at the item's center if (snapprefs != NULL && snapprefs->getIncludeItemCenter()) { - p.push_back(Inkscape::SnapCandidatePoint(item->getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); + p.push_back(Inkscape::SnapCandidatePoint(getCenter(), Inkscape::SNAPSOURCE_ROTATION_CENTER, Inkscape::SNAPTARGET_ROTATION_CENTER)); } // Get the snappoints of clipping paths and mask, if any std::list clips_and_masks; - clips_and_masks.push_back(SP_OBJECT(item->clip_ref->getObject())); - clips_and_masks.push_back(SP_OBJECT(item->mask_ref->getObject())); + clips_and_masks.push_back(SP_OBJECT(clip_ref->getObject())); + clips_and_masks.push_back(SP_OBJECT(mask_ref->getObject())); SPDesktop *desktop = inkscape_active_desktop(); for (std::list::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); o++) { @@ -1000,12 +1002,12 @@ void sp_item_snappoints(SPItem const *item, std::vector p_clip_or_mask; // Please note the recursive call here! - sp_item_snappoints(SP_ITEM(child), p_clip_or_mask, snapprefs); + SP_ITEM(child)->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 // in document coordinates. Hence the awkward construction below - Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * sp_item_i2d_affine(item); + Geom::Point pt = desktop->dt2doc((*p_orig).getPoint()) * i2d_affine(); p.push_back(Inkscape::SnapCandidatePoint(pt, (*p_orig).getSourceType(), (*p_orig).getTargetType())); } } @@ -1015,25 +1017,25 @@ void sp_item_snappoints(SPItem const *item, std::vectorisHidden()) { - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) { - if (!item->transform.isIdentity() - || SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX) + if (!this->isHidden()) { + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->print) { + if (!this->transform.isIdentity() + || SP_OBJECT_STYLE(this)->opacity.value != SP_SCALE24_MAX) { - sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)); - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); + sp_print_bind(ctx, this->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->print(this, ctx); sp_print_release(ctx); } else { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx); + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->print(this, ctx); } } } } -static gchar * -sp_item_private_description(SPItem */*item*/) +gchar * +SPItem::sp_item_private_description(SPItem */*item*/) { return g_strdup(_("Object")); } @@ -1044,25 +1046,25 @@ sp_item_private_description(SPItem */*item*/) * Must be freed by caller. */ gchar * -sp_item_description(SPItem *item) +SPItem::description() { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) { - gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item); - if (s && item->clip_ref->getObject()) { + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { + gchar *s = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->description(this); + if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); g_free (s); s = snew; } - if (s && item->mask_ref->getObject()) { + if (s && mask_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; masked"), s); g_free (s); s = snew; } - if (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href && SP_OBJECT_STYLE(item)->filter.href->getObject()) { - const gchar *label = SP_OBJECT_STYLE(item)->filter.href->getObject()->label(); + if (SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->filter.href && SP_OBJECT_STYLE(this)->filter.href->getObject()) { + const gchar *label = SP_OBJECT_STYLE(this)->filter.href->getObject()->label(); gchar *snew; if (label) { snew = g_strdup_printf (_("%s; filtered (%s)"), s, _(label)); @@ -1086,7 +1088,7 @@ sp_item_description(SPItem *item) * you can use n, n + 1, ..., n + (numkeys - 1) */ unsigned -sp_item_display_key_new(unsigned numkeys) +SPItem::display_key_new(unsigned numkeys) { static unsigned dkey = 0; @@ -1096,31 +1098,31 @@ sp_item_display_key_new(unsigned numkeys) } NRArenaItem * -sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) +SPItem::invoke_show(NRArena *arena, unsigned key, unsigned flags) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); g_assert(arena != NULL); g_assert(NR_IS_ARENA(arena)); NRArenaItem *ai = NULL; - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->show) { - ai = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->show(item, arena, key, flags); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->show) { + ai = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->show(this, arena, key, flags); } if (ai != NULL) { - item->display = sp_item_view_new_prepend(item->display, item, flags, key, ai); - nr_arena_item_set_transform(ai, item->transform); - nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)); - nr_arena_item_set_visible(ai, !item->isHidden()); - nr_arena_item_set_sensitive(ai, item->sensitive); - if (item->clip_ref->getObject()) { - SPClipPath *cp = item->clip_ref->getObject(); - - if (!item->display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3)); + display = sp_item_view_new_prepend(display, this, flags, key, ai); + nr_arena_item_set_transform(ai, transform); + nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(this)->opacity.value)); + nr_arena_item_set_visible(ai, !isHidden()); + nr_arena_item_set_sensitive(ai, sensitive); + if (clip_ref->getObject()) { + SPClipPath *cp = clip_ref->getObject(); + + if (!display->arenaitem->key) { + NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); } - int clip_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem); + int clip_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); // Show and set clip NRArenaItem *ac = sp_clippath_show(cp, arena, clip_key); @@ -1129,17 +1131,17 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) // Update bbox, in case the clip uses bbox units NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + invoke_bbox( &bbox, Geom::identity(), TRUE); sp_clippath_set_bbox(SP_CLIPPATH(cp), clip_key, &bbox); SP_OBJECT(cp)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - if (item->mask_ref->getObject()) { - SPMask *mask = item->mask_ref->getObject(); + if (mask_ref->getObject()) { + SPMask *mask = mask_ref->getObject(); - if (!item->display->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3)); + if (!display->arenaitem->key) { + NR_ARENA_ITEM_SET_KEY(display->arenaitem, display_key_new(3)); } - int mask_key = NR_ARENA_ITEM_GET_KEY(item->display->arenaitem); + int mask_key = NR_ARENA_ITEM_GET_KEY(display->arenaitem); // Show and set mask NRArenaItem *ac = sp_mask_show(mask, arena, mask_key); @@ -1148,13 +1150,13 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) // Update bbox, in case the mask uses bbox units NRRect bbox; - sp_item_invoke_bbox(item, &bbox, Geom::identity(), TRUE); + invoke_bbox( &bbox, Geom::identity(), TRUE); sp_mask_set_bbox(SP_MASK(mask), mask_key, &bbox); SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } - NR_ARENA_ITEM_SET_DATA(ai, item); + NR_ARENA_ITEM_SET_DATA(ai, this); Geom::OptRect item_bbox; - sp_item_invoke_bbox(item, item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + invoke_bbox( item_bbox, Geom::identity(), TRUE, SPItem::GEOMETRIC_BBOX); nr_arena_item_set_item_bbox(ai, item_bbox); } @@ -1162,30 +1164,30 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) } void -sp_item_invoke_hide(SPItem *item, unsigned key) +SPItem::invoke_hide(unsigned key) { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(this != NULL); + //g_assert(SP_IS_ITEM(this)); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide(item, key); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide) { + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->hide(this, key); } SPItemView *ref = NULL; - SPItemView *v = item->display; + SPItemView *v = display; while (v != NULL) { SPItemView *next = v->next; if (v->key == key) { - if (item->clip_ref->getObject()) { - sp_clippath_hide(item->clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + if (clip_ref->getObject()) { + sp_clippath_hide(clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_clip(v->arenaitem, NULL); } - if (item->mask_ref->getObject()) { - sp_mask_hide(item->mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); + if (mask_ref->getObject()) { + sp_mask_hide(mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem)); nr_arena_item_set_mask(v->arenaitem, NULL); } if (!ref) { - item->display = v->next; + display = v->next; } else { ref->next = v->next; } @@ -1202,22 +1204,22 @@ sp_item_invoke_hide(SPItem *item, unsigned key) // Adjusters void -sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_pattern (Geom::Matrix const &postmul, bool set) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item); + SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (this); if (SP_IS_PATTERN (server)) { - SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "fill"); + SPPattern *pattern = sp_pattern_clone_if_necessary (this, SP_PATTERN (server), "fill"); sp_pattern_transform_multiply (pattern, postmul, set); } } if (style && (style->stroke.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item); + SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (this); if (SP_IS_PATTERN (server)) { - SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "stroke"); + SPPattern *pattern = sp_pattern_clone_if_necessary (this, SP_PATTERN (server), "stroke"); sp_pattern_transform_multiply (pattern, postmul, set); } } @@ -1225,12 +1227,12 @@ sp_item_adjust_pattern (SPItem *item, Geom::Matrix const &postmul, bool set) } void -sp_item_adjust_gradient (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_gradient (Geom::Matrix const &postmul, bool set) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && (style->fill.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item); + SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(this); if (SP_IS_GRADIENT (server)) { /** @@ -1242,25 +1244,25 @@ sp_item_adjust_gradient (SPItem *item, Geom::Matrix 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), item, "fill"); + SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), this, "fill"); sp_gradient_transform_multiply (gradient, postmul, set); } } if (style && (style->stroke.isPaintserver())) { - SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item); + SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(this); if (SP_IS_GRADIENT (server)) { - SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "stroke"); + SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), this, "stroke"); sp_gradient_transform_multiply (gradient, postmul, set); } } } void -sp_item_adjust_stroke (SPItem *item, gdouble ex) +SPItem::adjust_stroke (gdouble ex) { - SPStyle *style = SP_OBJECT_STYLE (item); + SPStyle *style = SP_OBJECT_STYLE (this); if (style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) { @@ -1275,7 +1277,7 @@ sp_item_adjust_stroke (SPItem *item, gdouble ex) style->stroke_dash.offset *= ex; } - SP_OBJECT(item)->updateRepr(); + SP_OBJECT(this)->updateRepr(); } } @@ -1302,17 +1304,17 @@ sp_item_transform_repr (SPItem *item) * Recursively scale stroke width in \a item and its children by \a expansion. */ void -sp_item_adjust_stroke_width_recursive(SPItem *item, double expansion) +SPItem::adjust_stroke_width_recursive(double expansion) { - sp_item_adjust_stroke (item, expansion); + adjust_stroke (expansion); // A clone's child is the ghost of its original - we must not touch it, skip recursion - if (item && SP_IS_USE(item)) + if (this && SP_IS_USE(this)) return; - for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { + for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) - sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion); + SP_ITEM(o)->adjust_stroke_width_recursive(expansion); } } @@ -1336,23 +1338,23 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Matrix advertized_transform) * Recursively compensate pattern or gradient transform. */ void -sp_item_adjust_paint_recursive (SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern) +SPItem::adjust_paint_recursive (Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern) { // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors // _After_ full pattern/gradient transform: t_paint_new * t_item * t_ancestors * advertised_transform // By equating these two expressions we get t_paint_new = t_paint * paint_delta, where: - Geom::Matrix t_item = sp_item_transform_repr (item); + Geom::Matrix t_item = sp_item_transform_repr (this); Geom::Matrix paint_delta = t_item * t_ancestors * advertized_transform * t_ancestors.inverse() * t_item.inverse(); // 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 (!(item && (SP_IS_TEXT(item) || SP_IS_USE(item)))) { - for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { + if (!(this && (SP_IS_TEXT(this) || SP_IS_USE(this)))) { + for (SPObject *o = SP_OBJECT(this)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) { // 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_adjust_paint_recursive (SP_ITEM(o), advertized_transform, t_item * t_ancestors, is_pattern); + SP_ITEM(o)->adjust_paint_recursive (advertized_transform, t_item * t_ancestors, is_pattern); } } } @@ -1363,19 +1365,19 @@ sp_item_adjust_paint_recursive (SPItem *item, Geom::Matrix advertized_transform, // before ancestors themselves are adjusted, probably differently (bug 1286535) if (is_pattern) - sp_item_adjust_pattern (item, paint_delta); + adjust_pattern (paint_delta); else - sp_item_adjust_gradient (item, paint_delta); + adjust_gradient (paint_delta); } void -sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool set) +SPItem::adjust_livepatheffect (Geom::Matrix const &postmul, bool set) { - if ( !SP_IS_LPE_ITEM(item) ) + if ( !SP_IS_LPE_ITEM(this) ) return; - SPLPEItem *lpeitem = SP_LPE_ITEM (item); + SPLPEItem *lpeitem = SP_LPE_ITEM (this); if ( sp_lpe_item_has_path_effect(lpeitem) ) { sp_lpe_item_fork_path_effects_if_necessary(lpeitem); @@ -1401,10 +1403,10 @@ sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool s * the repr is updated with the new transform. */ void -sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) +SPItem::doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv, bool compensate) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); g_return_if_fail(repr != NULL); // calculate the relative transform, if not given by the adv attribute @@ -1412,7 +1414,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co if (adv != NULL) { advertized_transform = *adv; } else { - advertized_transform = sp_item_transform_repr (item).inverse() * transform; + advertized_transform = sp_item_transform_repr (this).inverse() * transform; } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1421,26 +1423,26 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co // recursively compensate for stroke scaling, depending on user preference if (!prefs->getBool("/options/transform/stroke", true)) { double const expansion = 1. / advertized_transform.descrim(); - sp_item_adjust_stroke_width_recursive(item, expansion); + adjust_stroke_width_recursive(expansion); } // recursively compensate rx/ry of a rect if requested if (!prefs->getBool("/options/transform/rectcorners", true)) { - sp_item_adjust_rects_recursive(item, advertized_transform); + sp_item_adjust_rects_recursive(this, advertized_transform); } // recursively compensate pattern fill if it's not to be transformed if (!prefs->getBool("/options/transform/pattern", true)) { - sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), true); + adjust_paint_recursive (advertized_transform.inverse(), Geom::identity(), true); } /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well /// recursively compensate gradient fill if it's not to be transformed if (!prefs->getBool("/options/transform/gradient", true)) { - sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), Geom::identity(), false); + adjust_paint_recursive (advertized_transform.inverse(), Geom::identity(), false); } else { // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // it here _before_ the new transform is set, so as to use the pre-transform bbox - sp_item_adjust_paint_recursive (item, Geom::identity(), Geom::identity(), false); + adjust_paint_recursive (Geom::identity(), Geom::identity(), false); } } // endif(compensate) @@ -1448,36 +1450,36 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix co gint preserve = prefs->getBool("/options/preservetransform/value", 0); Geom::Matrix transform_attr (transform); if ( // run the object's set_transform (i.e. embed transform) only if: - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method + ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform && // it does have a set_transform method !preserve && // user did not chose to preserve all transforms - !item->clip_ref->getObject() && // the object does not have a clippath - !item->mask_ref->getObject() && // the object does not have a mask - !(!transform.isTranslation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter()) + !clip_ref->getObject() && // the object does not have a clippath + !mask_ref->getObject() && // the object does not have a mask + !(!transform.isTranslation() && SP_OBJECT_STYLE(this) && SP_OBJECT_STYLE(this)->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { - transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform); + transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(this))->set_transform(this, transform); } - sp_item_set_item_transform(item, transform_attr); + set_item_transform(transform_attr); // Note: updateRepr comes before emitting the transformed signal since // it causes clone SPUse's copy of the original object to brought up to // date with the original. Otherwise, sp_use_bbox returns incorrect // values if called in code handling the transformed signal. - SP_OBJECT(item)->updateRepr(); + SP_OBJECT(this)->updateRepr(); // send the relative transform with a _transformed_signal - item->_transformed_signal.emit(&advertized_transform, item); + _transformed_signal.emit(&advertized_transform, this); } gint -sp_item_event(SPItem *item, SPEvent *event) +SPItem::emitEvent(SPEvent &event) { - g_return_val_if_fail(item != NULL, FALSE); - g_return_val_if_fail(SP_IS_ITEM(item), FALSE); - g_return_val_if_fail(event != NULL, FALSE); + //g_return_val_if_fail(this != NULL, FALSE); + //g_return_val_if_fail(SP_IS_ITEM(this), FALSE); + //g_return_val_if_fail((&event) != NULL, FALSE); - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->event) - return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->event(item, event); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->event) + return ((SPItemClass *) G_OBJECT_GET_CLASS(this))->event(this, &event); return FALSE; } @@ -1487,34 +1489,34 @@ sp_item_event(SPItem *item, SPEvent *event) * gradients, patterns as sp_item_write_transform does. */ void -sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform) +SPItem::set_item_transform(Geom::Matrix const &transform_matrix) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); - if (!matrix_equalp(transform, item->transform, NR_EPSILON)) { - item->transform = transform; + if (!matrix_equalp(transform_matrix, transform, NR_EPSILON)) { + transform = transform_matrix; /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a transformation. It's apparently not used anywhere else. */ - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); - sp_item_rm_unsatisfied_cns(*item); + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B); + sp_item_rm_unsatisfied_cns(*this); } } void -sp_item_convert_item_to_guides(SPItem *item) { - g_return_if_fail(item != NULL); - g_return_if_fail(SP_IS_ITEM(item)); +SPItem::convert_item_to_guides() { + g_return_if_fail(this != NULL); + g_return_if_fail(SP_IS_ITEM(this)); /* Use derived method if present ... */ - if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides) { - (*((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides)(item); + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides) { + (*((SPItemClass *) G_OBJECT_GET_CLASS(this))->convert_to_guides)(this); return; } /* .. otherwise simply place the guides around the item's bounding box */ - sp_item_convert_to_guides(item); + convert_to_guides(); } @@ -1554,40 +1556,40 @@ Geom::Matrix SPItem::getRelativeTransform(SPObject const *dest) const { * Returns the accumulated transformation of the item and all its ancestors, including root's viewport. * \pre (item != NULL) and SP_IS_ITEM(item). */ -Geom::Matrix sp_item_i2doc_affine(SPItem const *item) +Geom::Matrix SPItem::i2doc_affine() const { - return i2anc_affine(item, NULL); + return i2anc_affine(this, NULL); } /** * Returns the transformation from item to desktop coords */ -Geom::Matrix sp_item_i2d_affine(SPItem const *item) +Geom::Matrix SPItem::i2d_affine() const { - g_assert(item != NULL); - g_assert(SP_IS_ITEM(item)); + //g_assert(item != NULL); + //g_assert(SP_IS_ITEM(item)); - Geom::Matrix const ret( sp_item_i2doc_affine(item) + Geom::Matrix const ret( i2doc_affine() * Geom::Scale(1, -1) - * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) ); + * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(this))) ); return ret; } -void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) +void SPItem::set_i2d_affine(Geom::Matrix const &i2dt) { - g_return_if_fail( item != NULL ); - g_return_if_fail( SP_IS_ITEM(item) ); + //g_return_if_fail( item != NULL ); + //g_return_if_fail( SP_IS_ITEM(item) ); Geom::Matrix dt2p; /* desktop to item parent transform */ - if (SP_OBJECT_PARENT(item)) { - dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse(); + if (SP_OBJECT_PARENT(this)) { + dt2p = static_cast(SP_OBJECT_PARENT(this))->i2d_affine().inverse(); } else { - dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) + dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(this))) * Geom::Scale(1, -1) ); } Geom::Matrix const i2p( i2dt * dt2p ); - sp_item_set_item_transform(item, i2p); + set_item_transform(i2p); } @@ -1595,16 +1597,16 @@ void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa) */ Geom::Matrix -sp_item_dt2i_affine(SPItem const *item) +SPItem::dt2i_affine() const { /* fixme: Implement the right way (Lauris) */ - return sp_item_i2d_affine(item).inverse(); + return i2d_affine().inverse(); } /* Item views */ -static SPItemView * -sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) +SPItemView * +SPItem::sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem) { SPItemView *new_view; @@ -1623,8 +1625,8 @@ sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigne return new_view; } -static SPItemView * -sp_item_view_list_remove(SPItemView *list, SPItemView *view) +SPItemView * +SPItem::sp_item_view_list_remove(SPItemView *list, SPItemView *view) { if (view == list) { list = list->next; @@ -1646,9 +1648,9 @@ sp_item_view_list_remove(SPItemView *list, SPItemView *view) * with the given key */ NRArenaItem * -sp_item_get_arenaitem(SPItem *item, unsigned key) +SPItem::get_arenaitem(unsigned key) { - for ( SPItemView *iv = item->display ; iv ; iv = iv->next ) { + for ( SPItemView *iv = display ; iv ; iv = iv->next ) { if ( iv->key == key ) { return iv->arenaitem; } @@ -1675,7 +1677,7 @@ sp_item_first_item_child (SPObject *obj) } void -sp_item_convert_to_guides(SPItem *item) { +SPItem::convert_to_guides() { SPDesktop *dt = inkscape_active_desktop(); SPNamedView *nv = sp_desktop_namedview(dt); (void)nv; @@ -1685,7 +1687,7 @@ sp_item_convert_to_guides(SPItem *item) { SPItem::BBoxType bbox_type = (prefs_bbox ==0)? SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX; - Geom::OptRect bbox = sp_item_bbox_desktop(item, bbox_type); + Geom::OptRect bbox = getBboxDesktop(bbox_type); if (!bbox) { g_warning ("Cannot determine item's bounding box during conversion to guides.\n"); return; diff --git a/src/sp-item.h b/src/sp-item.h index faf64846e..d2c24baf0 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -53,13 +53,17 @@ enum { * Also, this probably goes to SPObject base class. * */ -struct SPEvent { +//struct SPEvent { +class SPEvent { + public: unsigned int type; gpointer data; }; /// SPItemView -struct SPItemView { +//struct SPItemView { +class SPItemView { + public: SPItemView *next; unsigned int flags; unsigned int key; @@ -79,7 +83,9 @@ struct SPItemView { #define SP_ITEM_REFERENCE_FLAGS (1 << 1) /// Contains transformations to document/viewport and the viewport size. -struct SPItemCtx { +//struct SPItemCtx { +class SPItemCtx { + public: SPCtx ctx; /** Item to document transformation */ Geom::Matrix i2doc; @@ -89,8 +95,20 @@ struct SPItemCtx { Geom::Matrix i2vp; }; +class SPItem; +class SPItemClass; + +#define SP_TYPE_ITEM (SPItem::getType ()) +#define SP_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ITEM, SPItem)) +#define SP_ITEM_CLASS(clazz) (G_TYPE_CHECK_CLASS_CAST((clazz), SP_TYPE_ITEM, SPItemClass)) +#define SP_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ITEM)) + + /** Abstract base class for all visible shapes. */ -struct SPItem : public SPObject { +//struct SPItem : public SPObject { +class SPItem : public SPObject { + public: + static GType getType (); enum BBoxType { // legacy behavior: includes crude stroke, markers; excludes long miters, blur margin; is known to be wrong for caps APPROXIMATE_BBOX, @@ -160,7 +178,36 @@ struct SPItem : public SPObject { sigc::connection connectTransformed(sigc::slot slot) { return _transformed_signal.connect(slot); } - + void invoke_bbox( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + void invoke_bbox( NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); + void invoke_bbox_full( Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); + void invoke_bbox_full( NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); + + unsigned pos_in_parent(); + gchar *description(); + void invoke_print(SPPrintContext *ctx); + static unsigned int display_key_new(unsigned int numkeys); + NRArenaItem *invoke_show(NRArena *arena, unsigned int key, unsigned int flags); + void invoke_hide(unsigned int key); + void getSnappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs=0) const; + void adjust_pattern(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); + void adjust_gradient(/* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); + void adjust_stroke(gdouble ex); + void adjust_stroke_width_recursive(gdouble ex); + void adjust_paint_recursive(Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); + void adjust_livepatheffect(Geom::Matrix const &postmul, bool set = false); + void doWriteTransform(Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); + void set_item_transform(Geom::Matrix const &transform_matrix); + void convert_item_to_guides(); + gint emitEvent (SPEvent &event); + NRArenaItem *get_arenaitem(unsigned int key); + void getBboxDesktop(NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); + Geom::OptRect getBboxDesktop(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); + Geom::Matrix i2doc_affine() const; + Geom::Matrix i2d_affine() const; + void set_i2d_affine(Geom::Matrix const &transform); + Geom::Matrix dt2i_affine() const; + void convert_to_guides(); private: enum EvaluatedStatus { @@ -169,10 +216,30 @@ private: mutable bool _is_evaluated; mutable EvaluatedStatus _evaluated_status; + + static void sp_item_init(SPItem *item); + + static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); + static void sp_item_release(SPObject *object); + static void sp_item_set(SPObject *object, unsigned key, gchar const *value); + static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags); + static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + static gchar *sp_item_private_description(SPItem *item); + static void sp_item_private_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); + + static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem); + static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view); + static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); + static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item); + + friend class SPItemClass; }; /// The SPItem vtable. -struct SPItemClass { +//struct SPItemClass { +class SPItemClass { + public: SPObjectClass parent_class; /** BBox union in given coordinate system */ @@ -201,6 +268,12 @@ struct SPItemClass { /** Emit event, if applicable */ gint (* event) (SPItem *item, SPEvent *event); + + private: + static SPObjectClass *static_parent_class; + static void sp_item_class_init(SPItemClass *klass); + + friend class SPItem; }; /* Flag testing macros */ @@ -209,49 +282,49 @@ struct SPItemClass { /* Methods */ -void sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); -void sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); -void sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); -void sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); +//void sp_item_invoke_bbox(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); +//void sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const clear, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); +//void sp_item_invoke_bbox_full(SPItem const *item, Geom::OptRect &bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear); +//void sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags, unsigned const clear) __attribute__ ((deprecated)); -unsigned sp_item_pos_in_parent(SPItem *item); +//unsigned sp_item_pos_in_parent(SPItem *item); -gchar *sp_item_description(SPItem * item); -void sp_item_invoke_print(SPItem *item, SPPrintContext *ctx); +//gchar *sp_item_description(SPItem * item); +//void sp_item_invoke_print(SPItem *item, SPPrintContext *ctx); /** Shows/Hides item on given arena display list */ -unsigned int sp_item_display_key_new(unsigned int numkeys); -NRArenaItem *sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); -void sp_item_invoke_hide(SPItem *item, unsigned int key); +//unsigned int sp_item_display_key_new(unsigned int numkeys); +//NRArenaItem *sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); +//void sp_item_invoke_hide(SPItem *item, unsigned int key); -void sp_item_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); +//void sp_item_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); -void sp_item_adjust_pattern(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); -void sp_item_adjust_gradient(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); -void sp_item_adjust_stroke(SPItem *item, gdouble ex); -void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); -void sp_item_adjust_paint_recursive(SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); -void sp_item_adjust_livepatheffect(SPItem *item, Geom::Matrix const &postmul, bool set = false); +//void sp_item_adjust_pattern(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); +//void sp_item_adjust_gradient(SPItem *item, /* Geom::Matrix const &premul, */ Geom::Matrix const &postmul, bool set = false); +//void sp_item_adjust_stroke(SPItem *item, gdouble ex); +//void sp_item_adjust_stroke_width_recursive(SPItem *item, gdouble ex); +//void sp_item_adjust_paint_recursive(SPItem *item, Geom::Matrix advertized_transform, Geom::Matrix t_ancestors, bool is_pattern); +//void sp_item_adjust_livepatheffect(SPItem *item, Geom::Matrix const &postmul, bool set = false); -void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); +//void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const &transform, Geom::Matrix const *adv = NULL, bool compensate = true); -void sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform); +//void sp_item_set_item_transform(SPItem *item, Geom::Matrix const &transform); -void sp_item_convert_item_to_guides(SPItem *item); +//void sp_item_convert_item_to_guides(SPItem *item); -gint sp_item_event (SPItem *item, SPEvent *event); +//gint sp_item_event (SPItem *item, SPEvent *event); /* Utility */ -NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); +//NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); -void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); -Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); +//void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); +//Geom::OptRect sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); Geom::Matrix i2anc_affine(SPObject const *item, SPObject const *ancestor); Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest); -Geom::Matrix sp_item_i2doc_affine(SPItem const *item); +//Geom::Matrix sp_item_i2doc_affine(SPItem const *item); /* fixme: - these are evil, but OK */ @@ -261,13 +334,13 @@ Geom::Matrix sp_item_i2doc_affine(SPItem const *item); * * \return TRANSFORM. */ -Geom::Matrix sp_item_i2d_affine(SPItem const *item); -void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); -Geom::Matrix sp_item_dt2i_affine(SPItem const *item); +//Geom::Matrix sp_item_i2d_affine(SPItem const *item); +//void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); +//Geom::Matrix sp_item_dt2i_affine(SPItem const *item); int sp_item_repr_compare_position(SPItem *first, SPItem *second); SPItem *sp_item_first_item_child (SPObject *obj); -void sp_item_convert_to_guides(SPItem *item); +//void sp_item_convert_to_guides(SPItem *item); #endif diff --git a/src/sp-line.cpp b/src/sp-line.cpp index d0ce32397..878fceb67 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -25,24 +25,25 @@ #include "document.h" #include "inkscape.h" -static void sp_line_class_init (SPLineClass *klass); -static void sp_line_init (SPLine *line); +//static void sp_line_class_init (SPLineClass *klass); +//static void sp_line_init (SPLine *line); -static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); -static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +//static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); +//static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar *sp_line_description (SPItem * item); -static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); +//static gchar *sp_line_description (SPItem * item); +//static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); -static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); -static void sp_line_set_shape (SPShape *shape); -static void sp_line_convert_to_guides(SPItem *item); +//static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); +//static void sp_line_set_shape (SPShape *shape); +//static void sp_line_convert_to_guides(SPItem *item); -static SPShapeClass *parent_class; +//static SPShapeClass *static_parent_class; +SPShapeClass * SPLineClass::static_parent_class=0; GType -sp_line_get_type (void) +SPLine::sp_line_get_type (void) { static GType line_type = 0; @@ -51,7 +52,7 @@ sp_line_get_type (void) sizeof (SPLineClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_line_class_init, + (GClassInitFunc) SPLineClass::sp_line_class_init, NULL, /* klass_finalize */ NULL, /* klass_data */ sizeof (SPLine), @@ -64,29 +65,30 @@ sp_line_get_type (void) return line_type; } -static void -sp_line_class_init (SPLineClass *klass) + +void +SPLineClass::sp_line_class_init (SPLineClass *klass) { - parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); + SPLineClass::static_parent_class = (SPShapeClass *) g_type_class_ref (SP_TYPE_SHAPE); SPObjectClass *sp_object_class = (SPObjectClass *) klass; - sp_object_class->build = sp_line_build; - sp_object_class->set = sp_line_set; - sp_object_class->write = sp_line_write; + sp_object_class->build = SPLine::sp_line_build; + sp_object_class->set = SPLine::sp_line_set; + sp_object_class->write = SPLine::sp_line_write; SPItemClass *item_class = (SPItemClass *) klass; - item_class->description = sp_line_description; - item_class->set_transform = sp_line_set_transform; - item_class->convert_to_guides = sp_line_convert_to_guides; + item_class->description = SPLine::sp_line_description; + item_class->set_transform = SPLine::sp_line_set_transform; + item_class->convert_to_guides = SPLine::sp_line_convert_to_guides; - sp_object_class->update = sp_line_update; + sp_object_class->update = SPLine::sp_line_update; SPShapeClass *shape_class = (SPShapeClass *) klass; - shape_class->set_shape = sp_line_set_shape; + shape_class->set_shape = SPLine::sp_line_set_shape; } -static void -sp_line_init (SPLine * line) +void +SPLine::sp_line_init (SPLine * line) { line->x1.unset(); line->y1.unset(); @@ -95,11 +97,11 @@ sp_line_init (SPLine * line) } -static void -sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +void +SPLine::sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) SPLineClass::static_parent_class)->build) { + ((SPObjectClass *) SPLineClass::static_parent_class)->build (object, document, repr); } sp_object_read_attr (object, "x1"); @@ -108,8 +110,8 @@ sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * r sp_object_read_attr (object, "y2"); } -static void -sp_line_set (SPObject *object, unsigned int key, const gchar *value) +void +SPLine::sp_line_set (SPObject *object, unsigned int key, const gchar *value) { SPLine * line = SP_LINE (object); @@ -133,14 +135,14 @@ sp_line_set (SPObject *object, unsigned int key, const gchar *value) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) SPLineClass::static_parent_class)->set) + ((SPObjectClass *) SPLineClass::static_parent_class)->set (object, key, value); break; } } -static void -sp_line_update (SPObject *object, SPCtx *ctx, guint flags) +void +SPLine::sp_line_update (SPObject *object, SPCtx *ctx, guint flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPLine *line = SP_LINE (object); @@ -159,13 +161,13 @@ sp_line_update (SPObject *object, SPCtx *ctx, guint flags) sp_shape_set_shape ((SPShape *) object); } - if (((SPObjectClass *) parent_class)->update) - ((SPObjectClass *) parent_class)->update (object, ctx, flags); + if (((SPObjectClass *) SPLineClass::static_parent_class)->update) + ((SPObjectClass *) SPLineClass::static_parent_class)->update (object, ctx, flags); } -static Inkscape::XML::Node * -sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPLine::sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPLine *line = SP_LINE (object); @@ -182,25 +184,25 @@ sp_line_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML sp_repr_set_svg_double(repr, "x2", line->x2.computed); sp_repr_set_svg_double(repr, "y2", line->y2.computed); - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (SPLineClass::static_parent_class))->write) + ((SPObjectClass *) (SPLineClass::static_parent_class))->write (object, xml_doc, repr, flags); return repr; } -static gchar * -sp_line_description(SPItem */*item*/) +gchar * +SPLine::sp_line_description(SPItem */*item*/) { return g_strdup(_("Line")); } -static void -sp_line_convert_to_guides(SPItem *item) +void +SPLine::sp_line_convert_to_guides(SPItem *item) { SPLine *line = SP_LINE(item); Geom::Point points[2]; - Geom::Matrix const i2d (sp_item_i2d_affine(item)); + Geom::Matrix const i2d (item->i2d_affine()); points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d; points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d; @@ -208,8 +210,8 @@ sp_line_convert_to_guides(SPItem *item) sp_guide_create(inkscape_active_desktop(), points[0], points[1]); } -static Geom::Matrix -sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) +Geom::Matrix +SPLine::sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) { SPLine *line = SP_LINE (item); Geom::Point points[2]; @@ -225,15 +227,15 @@ sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) line->x2.computed = points[1][Geom::X]; line->y2.computed = points[1][Geom::Y]; - sp_item_adjust_stroke(item, xform.descrim()); + item->adjust_stroke(xform.descrim()); SP_OBJECT (item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); return Geom::identity(); } -static void -sp_line_set_shape (SPShape *shape) +void +SPLine::sp_line_set_shape (SPShape *shape) { SPLine *line = SP_LINE (shape); diff --git a/src/sp-line.h b/src/sp-line.h index cc6802b7f..114b0ea7c 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -17,7 +17,7 @@ -#define SP_TYPE_LINE (sp_line_get_type ()) +#define SP_TYPE_LINE (SPLine::sp_line_get_type ()) #define SP_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_LINE, SPLine)) #define SP_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_LINE, SPLineClass)) #define SP_IS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_LINE)) @@ -26,18 +26,43 @@ class SPLine; class SPLineClass; -struct SPLine : public SPShape { - SVGLength x1; - SVGLength y1; - SVGLength x2; - SVGLength y2; +//static void sp_line_class_init (SPLineClass *klass); + +class SPLine : public SPShape { + public: + SVGLength x1; + SVGLength y1; + SVGLength x2; + SVGLength y2; + static GType sp_line_get_type (void); + private: + static void sp_line_init (SPLine *line); + + static void sp_line_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); + static void sp_line_set (SPObject *object, unsigned int key, const gchar *value); + static Inkscape::XML::Node *sp_line_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + static gchar *sp_line_description (SPItem * item); + static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xform); + + static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); + static void sp_line_set_shape (SPShape *shape); + static void sp_line_convert_to_guides(SPItem *item); + + friend class SPLineClass; }; -struct SPLineClass { - SPShapeClass parent_class; +class SPLineClass { + public: + SPShapeClass parent_class; + private: + static SPShapeClass *static_parent_class; + static void sp_line_class_init (SPLineClass *klass); + + friend class SPLine; }; -GType sp_line_get_type (void); +//GType sp_line_get_type (void); diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 20cb38297..b0369efe5 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -180,8 +180,7 @@ sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML if (SP_IS_ITEM (ochild)) { SPMask *cp = SP_MASK (object); for (SPMaskView *v = cp->display; v != NULL; v = v->next) { - NRArenaItem *ac = sp_item_invoke_show (SP_ITEM (ochild), - NR_ARENA_ITEM_ARENA (v->arenaitem), + NRArenaItem *ac = SP_ITEM (ochild)->invoke_show ( NR_ARENA_ITEM_ARENA (v->arenaitem), v->key, SP_ITEM_REFERENCE_FLAGS); if (ac) { @@ -289,7 +288,7 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Matrix const* applyTr if (NULL != applyTransform) { Geom::Matrix transform (item->transform); transform *= (*applyTransform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), transform); + item->doWriteTransform(SP_OBJECT_REPR(item), transform); } } @@ -313,7 +312,7 @@ sp_mask_show (SPMask *mask, NRArena *arena, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(mask)) ; child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM (child)) { - NRArenaItem *ac = sp_item_invoke_show (SP_ITEM (child), arena, key, SP_ITEM_REFERENCE_FLAGS); + NRArenaItem *ac = SP_ITEM (child)->invoke_show (arena, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in mask */ nr_arena_item_add_child (ai, ac, NULL); @@ -339,7 +338,7 @@ sp_mask_hide (SPMask *cp, unsigned int key) for (SPObject *child = sp_object_first_child(SP_OBJECT(cp)); child != NULL; child = SP_OBJECT_NEXT(child)) { if (SP_IS_ITEM (child)) { - sp_item_invoke_hide (SP_ITEM (child), key); + SP_ITEM(child)->invoke_hide (key); } } diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 556778676..30626695e 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -510,7 +510,7 @@ sp_offset_set_shape(SPShape *shape) theRes->ConvertToForme (orig, 1, originaux); SPItem *item = shape; - Geom::OptRect bbox = sp_item_bbox_desktop (item); + Geom::OptRect bbox = item->getBboxDesktop (); if ( bbox ) { gdouble size = L2(bbox->dimensions()); gdouble const exp = item->transform.descrim(); @@ -1049,7 +1049,7 @@ sp_offset_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPOffset item->transform *= compensate; // commit the compensation - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, &advertized_move); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 54d2a201a..39ed4c657 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -171,7 +171,7 @@ sp_path_convert_to_guides(SPItem *item) std::list > pts; - Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path))); + Geom::Matrix const i2d (SP_ITEM(path)->i2d_affine()); Geom::PathVector const & pv = curve->get_pathvector(); for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) { @@ -392,16 +392,16 @@ sp_path_set_transform(SPItem *item, Geom::Matrix const &xform) } // Adjust stroke - sp_item_adjust_stroke(item, xform.descrim()); + item->adjust_stroke(xform.descrim()); // Adjust pattern fill - sp_item_adjust_pattern(item, xform); + item->adjust_pattern(xform); // Adjust gradient fill - sp_item_adjust_gradient(item, xform); + item->adjust_gradient(xform); // Adjust LPE - sp_item_adjust_livepatheffect(item, xform); + item->adjust_livepatheffect(xform); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ec0d0d576..56e7956b6 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -327,12 +327,12 @@ sp_pattern_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape:: if (SP_IS_ITEM (ochild)) { SPPaintServer *ps = SP_PAINT_SERVER (pat); - unsigned position = sp_item_pos_in_parent(SP_ITEM(ochild)); + unsigned position = SP_ITEM(ochild)->pos_in_parent(); for (SPPainter *p = ps->painters; p != NULL; p = p->next) { SPPatPainter *pp = (SPPatPainter *) p; - NRArenaItem *ai = sp_item_invoke_show (SP_ITEM (ochild), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); + NRArenaItem *ai = SP_ITEM (ochild)->invoke_show (pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); if (ai) { nr_arena_item_add_child (pp->root, ai, NULL); @@ -524,7 +524,7 @@ pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Matr dup_transform = Geom::identity(); dup_transform *= move; - sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform, NULL, false); + copy->doWriteTransform(SP_OBJECT_REPR(copy), dup_transform, NULL, false); } Inkscape::GC::release(repr); @@ -645,7 +645,7 @@ sp_pattern_painter_release (SPObject *obj, SPPatPainter *painter) painter->_release_connections->erase(obj); } - sp_item_invoke_hide(SP_ITEM(obj), painter->dkey); + SP_ITEM(obj)->invoke_hide(painter->dkey); } /** @@ -727,7 +727,7 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, G /* Create arena */ pp->arena = NRArena::create(); - pp->dkey = sp_item_display_key_new (1); + pp->dkey = SPItem::display_key_new (1); /* Create group */ pp->root = NRArenaGroup::create(pp->arena); @@ -741,7 +741,7 @@ sp_pattern_painter_new (SPPaintServer *ps, Geom::Matrix const &full_transform, G // for each item in pattern, NRArenaItem *cai; // show it on our arena, - cai = sp_item_invoke_show (SP_ITEM (child), pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); + cai = SP_ITEM (child)->invoke_show (pp->arena, pp->dkey, SP_ITEM_REFERENCE_FLAGS); // add to the group, nr_arena_item_append_child (pp->root, cai); // and connect to the release signal in case the item gets deleted diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f15285e27..be926aabb 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -15,7 +15,7 @@ #include #include "forward.h" - +#include "sp-item.h" #define SP_TYPE_PATTERN (sp_pattern_get_type ()) #define SP_PATTERN(o) (GTK_CHECK_CAST ((o), SP_TYPE_PATTERN, SPPattern)) #define SP_PATTERN_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_PATTERN, SPPatternClass)) diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 08f446d61..110fb4d01 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -20,19 +20,21 @@ #include "xml/repr.h" #include "document.h" -static void sp_polyline_class_init (SPPolyLineClass *klass); -static void sp_polyline_init (SPPolyLine *polyline); +//static void sp_polyline_class_init (SPPolyLineClass *klass); +//static void sp_polyline_init (SPPolyLine *polyline); -static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); -static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); -static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); +//static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); +//static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); +//static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static gchar * sp_polyline_description (SPItem * item); +//static gchar * sp_polyline_description (SPItem * item); -static SPShapeClass *parent_class; +//static SPShapeClass *parent_class; + +SPShapeClass * SPPolyLineClass::static_parent_class=0; GType -sp_polyline_get_type (void) +SPPolyLine::sp_polyline_get_type (void) { static GType polyline_type = 0; @@ -41,7 +43,7 @@ sp_polyline_get_type (void) sizeof (SPPolyLineClass), NULL, /* base_init */ NULL, /* base_finalize */ - (GClassInitFunc) sp_polyline_class_init, + (GClassInitFunc) SPPolyLineClass::sp_polyline_class_init, NULL, /* klass_finalize */ NULL, /* klass_data */ sizeof (SPPolyLine), @@ -54,8 +56,8 @@ sp_polyline_get_type (void) return polyline_type; } -static void -sp_polyline_class_init (SPPolyLineClass *klass) +void +SPPolyLineClass::sp_polyline_class_init (SPPolyLineClass *klass) { GObjectClass * gobject_class; SPObjectClass * sp_object_class; @@ -65,33 +67,33 @@ sp_polyline_class_init (SPPolyLineClass *klass) sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); + static_parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE); - sp_object_class->build = sp_polyline_build; - sp_object_class->set = sp_polyline_set; - sp_object_class->write = sp_polyline_write; + sp_object_class->build = SPPolyLine::sp_polyline_build; + sp_object_class->set = SPPolyLine::sp_polyline_set; + sp_object_class->write = SPPolyLine::sp_polyline_write; - item_class->description = sp_polyline_description; + item_class->description = SPPolyLine::sp_polyline_description; } -static void -sp_polyline_init (SPPolyLine * /*polyline*/) +void +SPPolyLine::sp_polyline_init (SPPolyLine * /*polyline*/) { /* Nothing here */ } -static void -sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) +void +SPPolyLine::sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr) { - if (((SPObjectClass *) parent_class)->build) - ((SPObjectClass *) parent_class)->build (object, document, repr); + if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->build) + ((SPObjectClass *) SPPolyLineClass::static_parent_class)->build (object, document, repr); sp_object_read_attr (object, "points"); } -static void -sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) +void +SPPolyLine::sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) { SPPolyLine *polyline; @@ -144,14 +146,14 @@ sp_polyline_set (SPObject *object, unsigned int key, const gchar *value) break; } default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + if (((SPObjectClass *) SPPolyLineClass::static_parent_class)->set) + ((SPObjectClass *) SPPolyLineClass::static_parent_class)->set (object, key, value); break; } } -static Inkscape::XML::Node * -sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +Inkscape::XML::Node * +SPPolyLine::sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPPolyLine *polyline; @@ -165,14 +167,14 @@ sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape: repr->mergeFrom(SP_OBJECT_REPR (object), "id"); } - if (((SPObjectClass *) (parent_class))->write) - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write) + ((SPObjectClass *) (SPPolyLineClass::static_parent_class))->write (object, xml_doc, repr, flags); return repr; } -static gchar * -sp_polyline_description(SPItem */*item*/) +gchar * +SPPolyLine::sp_polyline_description(SPItem */*item*/) { return g_strdup(_("Polyline")); } diff --git a/src/sp-polyline.h b/src/sp-polyline.h index 3ee18d6a5..b7657288c 100644 --- a/src/sp-polyline.h +++ b/src/sp-polyline.h @@ -5,7 +5,7 @@ -#define SP_TYPE_POLYLINE (sp_polyline_get_type ()) +#define SP_TYPE_POLYLINE (SPPolyLine::sp_polyline_get_type ()) #define SP_POLYLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_POLYLINE, SPPolyLine)) #define SP_POLYLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_POLYLINE, SPPolyLineClass)) #define SP_IS_POLYLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_POLYLINE)) @@ -14,14 +14,32 @@ class SPPolyLine; class SPPolyLineClass; -struct SPPolyLine : public SPShape { +class SPPolyLine : public SPShape { + public: + static GType sp_polyline_get_type (void); + private: + static void sp_polyline_init (SPPolyLine *polyline); + + static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr); + static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value); + static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); + + static gchar * sp_polyline_description (SPItem * item); + + friend class SPPolyLineClass; + }; -struct SPPolyLineClass { - SPShapeClass parent_class; +class SPPolyLineClass { + public: + SPShapeClass parent_class; + private: + static SPShapeClass *static_parent_class; + static void sp_polyline_class_init (SPPolyLineClass *klass); + + friend class SPPolyLine; }; -GType sp_polyline_get_type (void); diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index bdfae7c99..f4993cdc9 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -379,13 +379,13 @@ sp_rect_set_transform(SPItem *item, Geom::Matrix const &xform) sp_rect_set_shape(rect); // Adjust stroke width - sp_item_adjust_stroke(item, sqrt(fabs(sw * sh))); + item->adjust_stroke(sqrt(fabs(sw * sh))); // Adjust pattern fill - sp_item_adjust_pattern(item, xform * ret.inverse()); + item->adjust_pattern(xform * ret.inverse()); // Adjust gradient fill - sp_item_adjust_gradient(item, xform * ret.inverse()); + item->adjust_gradient(xform * ret.inverse()); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); @@ -570,7 +570,7 @@ static void sp_rect_snappoints(SPItem const *item, std::vectori2d_affine ()); Geom::Point p0 = Geom::Point(rect->x.computed, rect->y.computed) * i2d; Geom::Point p1 = Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d; @@ -603,13 +603,13 @@ sp_rect_convert_to_guides(SPItem *item) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (!prefs->getBool("/tools/shapes/rect/convertguides", true)) { - sp_item_convert_to_guides(SP_ITEM(rect)); + SP_ITEM(rect)->convert_to_guides(); return; } std::list > pts; - Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(rect))); + Geom::Matrix const i2d (SP_ITEM(rect)->i2d_affine()); Geom::Point A1(Geom::Point(rect->x.computed, rect->y.computed) * i2d); Geom::Point A2(Geom::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 3064341b6..4de6aeb80 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -297,7 +297,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) /* Dimension marker views */ for (SPItemView *v = item->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (v->arenaitem, sp_item_display_key_new (SP_MARKER_LOC_QTY)); + NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { if (shape->marker[i]) { @@ -609,7 +609,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -637,7 +637,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } // MID position @@ -664,7 +664,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + marker_item->invoke_bbox ( &marker_bbox, from_2geom(tr), true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -685,7 +685,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); + marker_item->invoke_bbox ( &marker_bbox, tr, true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } } @@ -720,7 +720,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); + marker_item->invoke_bbox ( &marker_bbox, tr, true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -749,7 +749,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Matrix tr, SPStyle* s Geom::Matrix old_tr = marker_item->transform; marker_item->transform = tr; - sp_item_invoke_print (marker_item, ctx); + marker_item->invoke_print (ctx); marker_item->transform = old_tr; } /** @@ -777,13 +777,13 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) } /* fixme: Think (Lauris) */ - sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); + item->invoke_bbox( &pbox, Geom::identity(), TRUE); dbox.x0 = 0.0; dbox.y0 = 0.0; dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - sp_item_bbox_desktop (item, &bbox); - Geom::Matrix const i2d(sp_item_i2d_affine(item)); + item->getBboxDesktop (&bbox); + Geom::Matrix const i2d(item->i2d_affine()); SPStyle* style = SP_OBJECT_STYLE (item); @@ -899,7 +899,7 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /* provide key and dimension the marker views */ if (!arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (arenaitem, sp_item_display_key_new (SP_MARKER_LOC_QTY)); + NR_ARENA_ITEM_SET_KEY (arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0; i < SP_MARKER_LOC_QTY; i++) { @@ -1197,10 +1197,10 @@ static void sp_shape_snappoints(SPItem const *item, std::vectori2d_affine ()); if (snapprefs->getSnapObjectMidpoints()) { - Geom::OptRect bbox = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect bbox = item->getBounds(item->i2d_affine()); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 11e84d9b2..fd44cc4ba 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -533,7 +533,7 @@ static void sp_spiral_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - Geom::Matrix const i2d (sp_item_i2d_affine (item)); + Geom::Matrix const i2d (item->i2d_affine ()); SPSpiral *spiral = SP_SPIRAL(item); p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(spiral->cx, spiral->cy) * i2d, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); // This point is the start-point of the spiral, which is also returned when _snap_to_itemnode has been set diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 16c71d030..618d4520e 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -560,7 +560,7 @@ static void sp_star_snappoints(SPItem const *item, std::vectorgetSnapObjectMidpoints()) { - Geom::Matrix const i2d (sp_item_i2d_affine (item)); + Geom::Matrix const i2d (item->i2d_affine ()); p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2d,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } } diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 6e24ee28c..6d0b59daa 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -23,7 +23,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); } } diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 37be6f75e..07575c4f0 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -168,7 +168,7 @@ void CSwitch::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, if (SP_IS_ITEM (o)) { child = SP_ITEM (o); child->setEvaluated(o == evaluated_child); - ac = sp_item_invoke_show (child, arena, key, flags); + ac = child->invoke_show (arena, key, flags); if (ac) { nr_arena_item_add_child (ai, ac, ar); ar = ac; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index bae625f58..8f28ee255 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -249,7 +249,7 @@ sp_text_update (SPObject *object, SPCtx *ctx, guint flags) text->rebuildLayout(); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); + text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -275,7 +275,7 @@ sp_text_modified (SPObject *object, guint flags) if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPText *text = SP_TEXT (object); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); + text->invoke_bbox( &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -387,7 +387,7 @@ sp_text_show(SPItem *item, NRArena *arena, unsigned /* key*/, unsigned /*flags*/ // pass the bbox of the text object as paintbox (used for paintserver fills) NRRect paintbox; - sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE); + item->invoke_bbox( &paintbox, Geom::identity(), TRUE); group->layout.show(flowed, &paintbox); return flowed; @@ -442,7 +442,7 @@ static void sp_text_snappoints(SPItem const *item, std::vectoroutputExists()) { boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - p.push_back(Inkscape::SnapCandidatePoint((*pt) * sp_item_i2d_affine(item), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); + p.push_back(Inkscape::SnapCandidatePoint((*pt) * item->i2d_affine(), Inkscape::SNAPSOURCE_TEXT_BASELINE, Inkscape::SNAPTARGET_TEXT_BASELINE)); } } } @@ -483,13 +483,13 @@ sp_text_set_transform (SPItem *item, Geom::Matrix const &xform) text->_adjustFontsizeRecursive (item, ex); // Adjust stroke width - sp_item_adjust_stroke_width_recursive (item, ex); + item->adjust_stroke_width_recursive (ex); // Adjust pattern fill - sp_item_adjust_pattern(item, xform * ret.inverse()); + item->adjust_pattern(xform * ret.inverse()); // Adjust gradient fill - sp_item_adjust_gradient(item, xform * ret.inverse()); + item->adjust_gradient(xform * ret.inverse()); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); @@ -502,13 +502,13 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) NRRect pbox, dbox, bbox; SPText *group = SP_TEXT (item); - sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); - sp_item_bbox_desktop (item, &bbox); + item->invoke_bbox( &pbox, Geom::identity(), TRUE); + item->getBboxDesktop (&bbox); dbox.x0 = 0.0; dbox.y0 = 0.0; dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - Geom::Matrix const ctm (sp_item_i2d_affine(item)); + Geom::Matrix const ctm (item->i2d_affine()); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } diff --git a/src/sp-tref-reference.h b/src/sp-tref-reference.h index 37a5e21ce..f3c645942 100644 --- a/src/sp-tref-reference.h +++ b/src/sp-tref-reference.h @@ -12,6 +12,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 83f9ecfa6..382b55740 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -359,7 +359,7 @@ sp_tref_description(SPItem *item) char *child_desc; if (SP_IS_ITEM(referred)) { - child_desc = sp_item_description(SP_ITEM(referred)); + child_desc = SP_ITEM(referred)->description(); } else { child_desc = g_strdup(""); } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 89a86218e..db2fe6fed 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -578,7 +578,7 @@ sp_textpath_to_text(SPObject *tp) SPObject *text = SP_OBJECT_PARENT(tp); NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); + SP_ITEM(text)->invoke_bbox( &bbox, SP_ITEM(text)->i2doc_affine(), TRUE); Geom::Point xy(bbox.x0, bbox.y0); // make a list of textpath children diff --git a/src/sp-use-reference.h b/src/sp-use-reference.h index b30819a5b..73d46c8aa 100644 --- a/src/sp-use-reference.h +++ b/src/sp-use-reference.h @@ -10,6 +10,7 @@ */ #include +#include "sp-item.h" #include #include diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 9cd38e4b3..1125550c8 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -289,7 +289,7 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, uns use->y.computed) * transform ); Geom::OptRect optbbox; - sp_item_invoke_bbox_full(child, optbbox, ct, flags, FALSE); + child->invoke_bbox_full( optbbox, ct, flags, FALSE); if (optbbox) { bbox->x0 = (*optbbox)[0][0]; bbox->y0 = (*optbbox)[1][0]; @@ -312,7 +312,7 @@ sp_use_print(SPItem *item, SPPrintContext *ctx) } if (use->child && SP_IS_ITEM(use->child)) { - sp_item_invoke_print(SP_ITEM(use->child), ctx); + SP_ITEM(use->child)->invoke_print(ctx); } if (translated) { @@ -336,7 +336,7 @@ sp_use_description(SPItem *item) * a , and giving its description. */ } ++recursion_depth; - char *child_desc = sp_item_description(SP_ITEM(use->child)); + char *child_desc = SP_ITEM(use->child)->description(); --recursion_depth; ret = g_strdup_printf(_("Clone of: %s"), child_desc); @@ -357,7 +357,7 @@ sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(item)); if (use->child) { - NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(use->child), arena, key, flags); + NRArenaItem *ac = SP_ITEM(use->child)->invoke_show(arena, key, flags); if (ac) { nr_arena_item_add_child(ai, ac, NULL); } @@ -375,7 +375,7 @@ sp_use_hide(SPItem *item, unsigned key) SPUse *use = SP_USE(item); if (use->child) { - sp_item_invoke_hide(SP_ITEM(use->child), key); + SP_ITEM(use->child)->invoke_hide(key); } if (((SPItemClass *) parent_class)->hide) { @@ -512,7 +512,7 @@ sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self // commit the compensation SPItem *item = SP_ITEM(self); item->transform *= clone_move; - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, &advertized_move); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, &advertized_move); SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -543,7 +543,7 @@ sp_use_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPUse *use) for (SPItemView *v = item->display; v != NULL; v = v->next) { NRArenaItem *ai; - ai = sp_item_invoke_show(SP_ITEM(use->child), NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, v->flags); + ai = SP_ITEM(use->child)->invoke_show(NR_ARENA_ITEM_ARENA(v->arenaitem), v->key, v->flags); if (ai) { nr_arena_item_add_child(v->arenaitem, ai, NULL); } @@ -736,7 +736,7 @@ sp_use_unlink(SPUse *use) { Geom::Matrix nomove(Geom::identity()); // Advertise ourselves as not moving. - sp_item_write_transform(item, SP_OBJECT_REPR(item), t, &nomove); + item->doWriteTransform(SP_OBJECT_REPR(item), t, &nomove); } return item; } diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 7ce9d4710..2eb8daf89 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -420,7 +420,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) sc->item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); Inkscape::GC::release(repr); - sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); sc->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db9f72975..db5ceaa8e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -451,11 +451,11 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // adjust style properties that depend on a possible transform in the source object in order // to get a correct style attribute for the new path SPItem* item_source = SP_ITEM(source); - Geom::Matrix i2doc(sp_item_i2doc_affine(item_source)); - sp_item_adjust_stroke(item_source, i2doc.descrim()); - sp_item_adjust_pattern(item_source, i2doc); - sp_item_adjust_gradient(item_source, i2doc); - sp_item_adjust_livepatheffect(item_source, i2doc); + Geom::Matrix i2doc(item_source->i2doc_affine()); + item_source->adjust_stroke(i2doc.descrim()); + item_source->adjust_pattern(i2doc); + item_source->adjust_gradient(i2doc); + item_source->adjust_livepatheffect(i2doc); Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source); @@ -484,7 +484,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // premultiply by the inverse of parent's repr SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent)); - Geom::Matrix local (sp_item_i2doc_affine(parent_item)); + Geom::Matrix local (parent_item->i2doc_affine()); gchar *transform = sp_svg_transform_write(local.inverse()); // now that we have the result, add it on the canvas @@ -620,7 +620,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc); g_repr->appendChild(m_repr); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); - sp_item_write_transform(marker_item, m_repr, tr); + marker_item->doWriteTransform(m_repr, tr); } } @@ -1089,7 +1089,7 @@ sp_selected_path_outline(SPDesktop *desktop) // restore title, description, id, transform repr->setAttribute("id", id); SPItem *newitem = (SPItem *) doc->getObjectByRepr(repr); - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); if (title) { newitem->setTitle(title); } @@ -1189,7 +1189,7 @@ sp_selected_path_outline(SPDesktop *desktop) repr->setAttribute("id", id); SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); if (title) { newitem->setTitle(title); } @@ -1321,7 +1321,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat Geom::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); @@ -1472,11 +1472,11 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { // on conserve l'original // we reapply the transform to the original (offset will feel it) - sp_item_write_transform(item, SP_OBJECT_REPR(item), transform); + item->doWriteTransform(SP_OBJECT_REPR(item), transform); } else { // delete original, apply the transform to the offset SP_OBJECT(item)->deleteObject(false); - sp_item_write_transform(nitem, repr, transform); + nitem->doWriteTransform(repr, transform); } // The object just created from a temporary repr is only a seed. @@ -1546,7 +1546,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) Geom::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); @@ -1719,7 +1719,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); // reapply the transform - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); repr->setAttribute("id", id); @@ -1788,7 +1788,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, } // correct virtual size by full transform (bug #166937) - size /= sp_item_i2doc_affine(item).descrim(); + size /= item->i2doc_affine().descrim(); // save the transform, to re-apply it after simplification Geom::Matrix const transform(item->transform); @@ -1798,7 +1798,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, this is necessary so that the item is transformed twice back and forth, allowing all compensations to cancel out regardless of the preferences */ - sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask")); @@ -1878,7 +1878,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, SPItem *newitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); // reapply the transform - sp_item_write_transform(newitem, repr, transform); + newitem->doWriteTransform(repr, transform); // restore title & description if (title) { @@ -1943,7 +1943,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect itemBbox = item->getBounds(item->i2d_affine()); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { @@ -2088,7 +2088,7 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t if (doTransformation) { if (transformFull) { - *dest *= extraPreAffine * sp_item_i2doc_affine(item) * extraPostAffine; + *dest *= extraPreAffine * item->i2doc_affine() * extraPostAffine; } else { *dest *= extraPreAffine * (Geom::Matrix)item->transform * extraPostAffine; } diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 2bdac197f..8c30f5a5a 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -151,9 +151,9 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom Geom::Translate const s(c); Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s); // Rotate item. - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine); + item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine); // Use each item's own transform writer, consistent with sp_selection_apply_affine() - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); // Restore the center position (it's changed because the bbox center changed) if (item->isCenterSet()) { item->setCenter(c); @@ -165,8 +165,8 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Scale const &scale) { Geom::Translate const s(c); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s ); - sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); + item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s ); + item->doWriteTransform(SP_OBJECT_REPR(item), item->transform); } static void sp_spray_context_init(SPSprayContext *tc) @@ -479,7 +479,7 @@ bool sp_spray_recursive(SPDesktop *desktop, dr=dr*radius; if (mode == SPRAY_MODE_COPY) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { SPItem *item_copied; if(_fid<=population) @@ -531,7 +531,7 @@ bool sp_spray_recursive(SPDesktop *desktop, Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father); Inkscape::XML::Node *parent = old_repr->parent(); - Geom::OptRect a = father->getBounds(sp_item_i2doc_affine(father)); + Geom::OptRect a = father->getBounds(father->i2doc_affine()); if (a) { if (i==2) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); @@ -569,7 +569,7 @@ bool sp_spray_recursive(SPDesktop *desktop, } } } else if (mode == SPRAY_MODE_CLONE) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { if(_fid<=population) { SPItem *item_copied; diff --git a/src/star-context.cpp b/src/star-context.cpp index 63a15545f..69d711722 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -432,7 +432,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) sc->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); Inkscape::GC::release(repr); - sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); sc->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/style-test.h b/src/style-test.h index a2d5fcf24..0bc47906c 100644 --- a/src/style-test.h +++ b/src/style-test.h @@ -22,7 +22,7 @@ public: { if ( _doc ) { - sp_document_unref( _doc ); + _doc->doUnref(); _doc = 0; } } diff --git a/src/svg-view.cpp b/src/svg-view.cpp index bd46dd17a..31b54b36d 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -41,7 +41,7 @@ SPSVGView::~SPSVGView() { if (doc() && _drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (_dkey); _drawing = NULL; } } @@ -152,7 +152,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG spev.type = SP_EVENT_ACTIVATE; if ( spitem != 0 ) { - sp_item_event (spitem, &spev); + spitem->emitEvent (spev); } } } @@ -166,7 +166,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG spev.data = svgview; if ( spitem != 0 ) { - sp_item_event (spitem, &spev); + spitem->emitEvent (spev); } break; case GDK_LEAVE_NOTIFY: @@ -174,7 +174,7 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG spev.data = svgview; if ( spitem != 0 ) { - sp_item_event (spitem, &spev); + spitem->emitEvent (spev); } break; default: @@ -191,7 +191,7 @@ void SPSVGView::setDocument (SPDocument *document) { if (doc()) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (_dkey); } if (!_drawing) { @@ -200,8 +200,7 @@ SPSVGView::setDocument (SPDocument *document) } if (document) { - NRArenaItem *ai = sp_item_invoke_show ( - SP_ITEM (sp_document_root (document)), + NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( SP_CANVAS_ARENA (_drawing)->arena, _dkey, SP_ITEM_SHOW_DISPLAY); diff --git a/src/test-helpers.h b/src/test-helpers.h index 8dba0c942..4ec1d4dc1 100644 --- a/src/test-helpers.h +++ b/src/test-helpers.h @@ -32,7 +32,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) static_cast(g_object_new(inkscape_get_type(), NULL)); } - SPDocument* tmp = sp_document_new( NULL, TRUE, true ); + SPDocument* tmp = SPDocument::createDoc( NULL, TRUE, true ); if ( tmp ) { fun( suite ); if ( suite ) @@ -41,7 +41,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) ) } else { - sp_document_unref( tmp ); + tmp->doUnref(); } } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index f574b69fb..166799e38 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -133,7 +133,7 @@ text_put_on_path() parent->appendChild(repr); SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - sp_item_write_transform(new_item, repr, text->transform); + new_item->doWriteTransform(repr, text->transform); SP_OBJECT(new_item)->updateRepr(); Inkscape::GC::release(repr); @@ -433,7 +433,7 @@ text_unflow () rtext->setAttribute("style", SP_OBJECT_REPR(flowtext)->attribute("style")); // fixme: transfer style attrs too; and from descendants NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE); + SP_ITEM(flowtext)->invoke_bbox( &bbox, SP_ITEM(flowtext)->i2doc_affine(), TRUE); Geom::Point xy(bbox.x0, bbox.y0); if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) { sp_repr_set_svg_double(rtext, "x", xy[Geom::X]); @@ -518,7 +518,7 @@ flowtext_to_text() parent->addChild(repr, SP_OBJECT_REPR(item)); SPItem *new_item = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - sp_item_write_transform(new_item, repr, item->transform); + new_item->doWriteTransform(repr, item->transform); SP_OBJECT(new_item)->updateRepr(); Inkscape::GC::release(repr); diff --git a/src/text-context.cpp b/src/text-context.cpp index 4f89bd1e1..b37c97311 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -432,7 +432,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve } else { SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0); } - Geom::OptRect ibbox = sp_item_bbox_desktop(item_ungrouped); + Geom::OptRect ibbox = item_ungrouped->getBboxDesktop(); if (ibbox) { SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox); } @@ -498,7 +498,7 @@ sp_text_context_setup_text(SPTextContext *tc) /* yes, it's immediate .. why does it matter? */ sp_desktop_selection(ec->desktop)->set(text_item); Inkscape::GC::release(rtext); - text_item->transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentLayer())).inverse(); + text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse(); text_item->updateRepr(); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, @@ -1570,8 +1570,8 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) if (tc->text) { Geom::Point p0, p1; sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1); - Geom::Point const d0 = p0 * sp_item_i2d_affine(SP_ITEM(tc->text)); - Geom::Point const d1 = p1 * sp_item_i2d_affine(SP_ITEM(tc->text)); + Geom::Point const d0 = p0 * SP_ITEM(tc->text)->i2d_affine(); + Geom::Point const d1 = p1 * SP_ITEM(tc->text)->i2d_affine(); // scroll to show cursor if (scroll_to_see) { @@ -1612,7 +1612,7 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0); } sp_canvas_item_show(tc->frame); - Geom::OptRect frame_bbox = sp_item_bbox_desktop(frame); + Geom::OptRect frame_bbox = frame->getBboxDesktop(); if (frame_bbox) { SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox); } @@ -1652,7 +1652,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc) std::vector quads; if (tc->text != NULL) - quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, sp_item_i2d_affine(tc->text)); + quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, (tc->text)->i2d_affine()); for (unsigned i = 0 ; i < quads.size() ; i += 4) { SPCanvasItem *quad_canvasitem; quad_canvasitem = sp_canvas_item_new(sp_desktop_controls(tc->desktop), SP_TYPE_CTRLQUADR, NULL); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 372f5026d..600059303 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -80,7 +80,7 @@ sp_te_input_is_empty (SPObject const *item) Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, Geom::Point const &i_p) { - Geom::Matrix im (sp_item_i2d_affine (item)); + Geom::Matrix im (item->i2d_affine ()); im = im.inverse(); Geom::Point p = i_p * im; @@ -956,7 +956,7 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons // divide increment by zoom // divide increment by matrix expansion gdouble factor = 1 / desktop->current_zoom(); - Geom::Matrix t (sp_item_i2doc_affine(item)); + Geom::Matrix t (item->i2doc_affine()); factor = factor / t.descrim(); by = factor * by; @@ -1008,7 +1008,7 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons // divide increment by zoom // divide increment by matrix expansion gdouble factor = 1 / desktop->current_zoom(); - Geom::Matrix t (sp_item_i2doc_affine(text)); + Geom::Matrix t (text->i2doc_affine()); factor = factor / t.descrim(); Inkscape::Text::Layout const *layout = te_get_layout(text); if (layout == NULL) return; @@ -1112,7 +1112,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it gdouble const zoom = desktop->current_zoom(); gdouble const zby = (by / (zoom * (nb_let > 1 ? nb_let - 1 : 1)) - / to_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))).descrim()); + / to_2geom(SP_ITEM(source_obj)->i2doc_affine()).descrim()); val += zby; if (start == end) { @@ -1184,7 +1184,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count)); // divide increment by matrix expansion - Geom::Matrix t (sp_item_i2doc_affine (SP_ITEM(text))); + Geom::Matrix t (SP_ITEM(text)->i2doc_affine ()); zby = zby / t.descrim(); switch (style->line_height.unit) { @@ -1861,7 +1861,7 @@ void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &sta SPCSSAttr *css_set = sp_repr_css_attr_new(); sp_repr_css_merge(css_set, (SPCSSAttr*) css); { - Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(common_ancestor))); + Geom::Matrix const local(SP_ITEM(common_ancestor)->i2doc_affine()); double const ex(local.descrim()); if ( ( ex != 0. ) && ( ex != 1. ) ) { diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index e2bd0e9f5..0c7f075b9 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -246,7 +246,7 @@ Tracer::sioxProcessImage(SPImage *img, return Glib::RefPtr(NULL); } - NRArenaItem *aImg = sp_item_get_arenaitem(img, desktop->dkey); + NRArenaItem *aImg = img->get_arenaitem(desktop->dkey); //g_message("img: %d %d %d %d\n", aImg->bbox.x0, aImg->bbox.y0, // aImg->bbox.x1, aImg->bbox.y1); @@ -264,7 +264,7 @@ Tracer::sioxProcessImage(SPImage *img, for (iter = sioxShapes.begin() ; iter!=sioxShapes.end() ; iter++) { SPItem *item = *iter; - NRArenaItem *aItem = sp_item_get_arenaitem(item, desktop->dkey); + NRArenaItem *aItem = item->get_arenaitem(desktop->dkey); arenaItems.push_back(aItem); } @@ -549,7 +549,7 @@ void Tracer::traceThread() if (reprobj) { SPItem *newItem = SP_ITEM(reprobj); - sp_item_write_transform(newItem, pathRepr, tf, NULL); + newItem->doWriteTransform(pathRepr, tf, NULL); } if (nrPaths == 1) { diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 904d0cb23..e77d2d465 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -442,7 +442,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else { if (mode == TWEAK_MODE_MOVE) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -455,7 +455,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MOVE_IN_OUT) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -469,7 +469,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MOVE_JITTER) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double dp = g_random_double_range(0, M_PI*2); double dr = g_random_double_range(0, radius); @@ -484,7 +484,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_SCALE) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -497,7 +497,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_ROTATE) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -510,7 +510,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } else if (mode == TWEAK_MODE_MORELESS) { - Geom::OptRect a = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect a = item->getBounds(item->i2doc_affine()); if (a) { double x = Geom::L2(a->midpoint() - p)/radius; if (a->contains(p)) x = 0; @@ -562,7 +562,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P // skip those paths whose bboxes are entirely out of reach with our radius - Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect bbox = item->getBounds(item->i2doc_affine()); if (bbox) { bbox->expandBy(radius); if (!bbox->contains(p)) { @@ -580,7 +580,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P Shape *theShape = new Shape; Shape *theRes = new Shape; - Geom::Matrix i2doc(sp_item_i2doc_affine(item)); + Geom::Matrix i2doc(item->i2doc_affine()); orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059 orig->Fill(theShape, 0); @@ -801,7 +801,7 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke, if (!gradient || !SP_IS_GRADIENT(gradient)) return; - Geom::Matrix i2d (sp_item_i2doc_affine (item)); + Geom::Matrix i2d (item->i2doc_affine ()); Geom::Point p = p_w * i2d.inverse(); p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates @@ -940,7 +940,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if (!style) { return false; } - Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item), + Geom::OptRect bbox = item->getBounds(item->i2doc_affine(), SPItem::GEOMETRIC_BBOX); if (!bbox) { return false; @@ -970,14 +970,14 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if (this_force > 0.002) { if (do_blur) { - Geom::OptRect bbox = item->getBounds(sp_item_i2doc_affine(item), + Geom::OptRect bbox = item->getBounds(item->i2doc_affine(), SPItem::GEOMETRIC_BBOX); if (!bbox) { return did; } double blur_now = 0; - Geom::Matrix i2d = sp_item_i2d_affine (item); + Geom::Matrix i2d = item->i2d_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives SPObject *primitive_obj = style->getFilter()->children; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 9ce2ac5ba..d92d35ae1 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -335,7 +335,7 @@ bool ClipboardManagerImpl::paste(SPDesktop *desktop, bool in_place) } _pasteDocument(desktop, tempdoc, in_place); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return true; } @@ -421,7 +421,7 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop) _userWarn(desktop, _("No style on the clipboard.")); } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -467,7 +467,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { for (GSList *i = const_cast(selection->itemList()) ; i ; i = i->next) { SPItem *item = SP_ITEM(i->data); - Geom::OptRect obj_size = sp_item_bbox_desktop(item); + Geom::OptRect obj_size = item->getBboxDesktop(); if ( !obj_size ) { continue; } @@ -484,7 +484,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a } pasted = true; } - sp_document_unref(tempdoc); + tempdoc->doUnref(); return pasted; } @@ -549,7 +549,7 @@ Glib::ustring ClipboardManagerImpl::getPathParameter(SPDesktop* desktop) *path = sp_repr_lookup_name(root, "svg:path", -1); // unlimited search depth if ( path == NULL ) { _userWarn(desktop, _("Clipboard does not contain a path.")); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return ""; } gchar const *svgd = path->attribute("d"); @@ -577,7 +577,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) if ( repr == NULL ) { _userWarn(desktop, _("Clipboard does not contain a path.")); - sp_document_unref(tempdoc); + tempdoc->doUnref(); return ""; } gchar const *svgd = repr->attribute("id"); @@ -615,7 +615,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // write the complete accumulated transform passed to us // (we're dealing with unattached representations, so we write to their attributes // instead of using sp_item_set_transform) - gchar *transform_str = sp_svg_transform_write(sp_item_i2doc_affine(SP_ITEM(i->data))); + gchar *transform_str = sp_svg_transform_write(SP_ITEM(i->data)->i2doc_affine()); obj_copy->setAttribute("transform", transform_str); g_free(transform_str); } @@ -847,7 +847,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDesktop *desktop, SPDocument *clipdo selection->setReprList(pasted_objects); // invers apply parent transform - Geom::Matrix doc2parent = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + Geom::Matrix doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false); // Update (among other things) all curves in paths, for bounds() to work @@ -1254,7 +1254,7 @@ void ClipboardManagerImpl::_onClear() void ClipboardManagerImpl::_createInternalClipboard() { if ( _clipboardSPDoc == NULL ) { - _clipboardSPDoc = sp_document_new(NULL, false, true); + _clipboardSPDoc = SPDocument::createDoc(NULL, false, true); //g_assert( _clipboardSPDoc != NULL ); _defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(_clipboardSPDoc)); _doc = sp_document_repr_doc(_clipboardSPDoc); @@ -1279,7 +1279,7 @@ void ClipboardManagerImpl::_createInternalClipboard() void ClipboardManagerImpl::_discardInternalClipboard() { if ( _clipboardSPDoc != NULL ) { - sp_document_unref(_clipboardSPDoc); + _clipboardSPDoc->doUnref(); _clipboardSPDoc = NULL; _defs = NULL; _doc = NULL; diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 8d467d53f..7ed00ad19 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -147,7 +147,7 @@ Gtk::Widget *build_splash_widget() { // should be in UTF-*8.. char *about=g_build_filename(INKSCAPE_SCREENSDIR, _("about.svg"), NULL); - SPDocument *doc=sp_document_new (about, TRUE); + SPDocument *doc=SPDocument::createDoc (about, TRUE); g_free(about); g_return_val_if_fail(doc != NULL, NULL); @@ -162,7 +162,7 @@ Gtk::Widget *build_splash_widget() { double width=sp_document_width(doc); double height=sp_document_height(doc); - sp_document_unref(doc); + doc->doUnref(); sp_svg_view_widget_set_resize(SP_SVG_VIEW_WIDGET(v), FALSE, (int)width, (int)height); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index a75a8d68d..d7e3d1766 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -152,7 +152,7 @@ private : selected.erase(master); /*}*/ //Compute the anchor point - Geom::OptRect b = sp_item_bbox_desktop (thing); + Geom::OptRect b = thing->getBboxDesktop (); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -169,8 +169,7 @@ private : case AlignAndDistribute::DRAWING: { - Geom::OptRect b = sp_item_bbox_desktop - ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) ); + Geom::OptRect b = static_cast( sp_document_root (sp_desktop_document (desktop)))->getBboxDesktop(); if (b) { mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); @@ -218,7 +217,7 @@ private : { sp_document_ensure_up_to_date(sp_desktop_document (desktop)); if (!sel_as_group) - b = sp_item_bbox_desktop (*it); + b = (*it)->getBboxDesktop(); if (b) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); @@ -322,7 +321,7 @@ private : it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); } @@ -623,7 +622,7 @@ private : ++it) { sp_document_ensure_up_to_date(sp_desktop_document (desktop)); - Geom::OptRect item_box = sp_item_bbox_desktop (*it); + Geom::OptRect item_box = (*it)->getBboxDesktop (); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@ -708,7 +707,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * sp_item_i2d_affine(*it); + Geom::Point base = *pt * (*it)->i2d_affine(); if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; @@ -751,7 +750,7 @@ private : Inkscape::Text::Layout const *layout = te_get_layout(*it); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * sp_item_i2d_affine(*it); + Geom::Point base = *pt * (*it)->i2d_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; sp_item_move_rel(*it, Geom::Translate(t)); @@ -1108,7 +1107,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = sp_item_bbox_desktop (*it); + Geom::OptRect b = (*it)->getBboxDesktop (); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim > max) { @@ -1125,7 +1124,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { - Geom::OptRect b = sp_item_bbox_desktop (*it); + Geom::OptRect b = (*it)->getBboxDesktop (); if (b) { gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); if (dim < max) { diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 6f83a706f..eb2d33eee 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -123,9 +123,9 @@ findExpanderWidgets(Gtk::Container *parent, bool SVGPreview::setDocument(SPDocument *doc) { if (document) - sp_document_unref(document); + document->doUnref(); - sp_document_ref(doc); + doc->doRef(); document = doc; //This should remove it from the box, and free resources @@ -151,7 +151,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) * I don't know why passing false to keepalive is bad. But it * prevents the display of an svg with a non-ascii filename */ - SPDocument *doc = sp_document_new (fileName.c_str(), true); + SPDocument *doc = SPDocument::createDoc (fileName.c_str(), true); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -159,7 +159,7 @@ bool SVGPreview::setFileName(Glib::ustring &theFileName) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -172,7 +172,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -180,7 +180,7 @@ bool SVGPreview::setFromMem(char const *xmlBuffer) setDocument(doc); - sp_document_unref(doc); + doc->doUnref(); Inkscape::GC::request_early_collection(); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 0f3672f25..8a0c70f7c 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -887,14 +887,14 @@ bool FileOpenDialogImplWin32::set_svg_preview() gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string, _MAX_PATH, NULL, NULL, NULL); - SPDocument *svgDoc = sp_document_new (utf8string, true); + SPDocument *svgDoc = SPDocument::createDoc (utf8string, true); g_free(utf8string); // Check the document loaded properly if(svgDoc == NULL) return false; if(svgDoc->root == NULL) { - sp_document_unref(svgDoc); + svgDoc->doUnref(); return false; } @@ -918,8 +918,8 @@ bool FileOpenDialogImplWin32::set_svg_preview() // write object bbox to area Geom::OptRect maybeArea(area); sp_document_ensure_up_to_date (svgDoc); - sp_item_invoke_bbox((SPItem *) svgDoc->root, maybeArea, - sp_item_i2d_affine((SPItem *)(svgDoc->root)), TRUE); + static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea, + static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE); NRArena *const arena = NRArena::create(); @@ -949,7 +949,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() // Fail if the pixblock failed to allocate if(pixBlock.data.px == NULL) { - sp_document_unref(svgDoc); + svgDoc->doUnref(); return false; } @@ -961,7 +961,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() nr_arena_item_invoke_render(NULL, root, &bbox, &pixBlock, /*0*/NR_ARENA_ITEM_RENDER_NO_CACHE); // Tidy up - sp_document_unref(svgDoc); + svgDoc->doUnref(); sp_item_invoke_hide((SPItem*)(svgDoc->root), key); nr_object_unref((NRObject *) arena); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 9a46254ab..e74e47ca3 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -378,10 +378,9 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ - unsigned int visionkey = sp_item_display_key_new(1); + unsigned int visionkey = SPItem::display_key_new(1); - root = sp_item_invoke_show ( SP_ITEM( SP_DOCUMENT_ROOT(doc) ), - arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + root = SP_ITEM( SP_DOCUMENT_ROOT(doc) )->invoke_show ( arena, visionkey, SP_ITEM_SHOW_DISPLAY ); for ( int i = 0; i < numEntries; i++ ) { guchar * px = sp_icon_doc_icon( doc, root, id, sizes[i] ); @@ -397,7 +396,7 @@ void IconPreviewPanel::renderPreview( SPObject* obj ) } updateMagnify(); - sp_item_invoke_hide(SP_ITEM(sp_document_root(doc)), visionkey); + SP_ITEM(sp_document_root(doc))->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 6be346582..dfb319f90 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -46,8 +46,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using Geom::X; using Geom::Y; - Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first)); - Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second)); + Geom::OptRect a = first->getBounds(first->i2doc_affine()); + Geom::OptRect b = second->getBounds(second->i2doc_affine()); if ( !a || !b ) { // FIXME? @@ -86,8 +86,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - Geom::OptRect a = first->getBounds(sp_item_i2doc_affine(first)); - Geom::OptRect b = second->getBounds(sp_item_i2doc_affine(second)); + Geom::OptRect a = first->getBounds(first->i2doc_affine()); + Geom::OptRect b = second->getBounds(second->i2doc_affine()); if ( !a || !b ) { // FIXME? @@ -166,7 +166,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); if (!b) { continue; } @@ -209,7 +209,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); if (b) { width = b->dimensions()[Geom::X]; height = b->dimensions()[Geom::Y]; @@ -316,7 +316,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = SP_OBJECT_REPR(item); - Geom::OptRect b = item->getBounds(sp_item_i2doc_affine(item)); + Geom::OptRect b = item->getBounds(item->i2doc_affine()); Geom::Point min; if (b) { width = b->dimensions()[Geom::X]; @@ -336,8 +336,8 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); Geom::Matrix const affine = Geom::Matrix(Geom::Translate(move)); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); - sp_item_write_transform(item, repr, item->transform, NULL); + item->set_i2d_affine(item->i2d_affine() * affine); + item->doWriteTransform(repr, item->transform, NULL); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 1cab38d98..f74c5d6e0 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -626,7 +626,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -650,7 +650,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - Geom::OptRect bbox = sp_item_bbox_desktop(*it); + Geom::OptRect bbox = (*it)->getBboxDesktop(); if (bbox) { sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -694,7 +694,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) Geom::Scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { - Geom::OptRect bbox(sp_item_bbox_desktop(item)); + Geom::OptRect bbox(item->getBboxDesktop()); if (bbox) { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object @@ -781,7 +781,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); - Geom::OptRect bbox(sp_item_bbox_desktop(item)); + Geom::OptRect bbox(item->getBboxDesktop()); if (bbox) { double width = bbox->dimensions()[Geom::X]; double height = bbox->dimensions()[Geom::Y]; @@ -835,7 +835,7 @@ Transformation::applyPageTransform(Inkscape::Selection *selection) if (_check_replace_matrix.get_active()) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - sp_item_set_item_transform(item, displayed); + item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); } } else { diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp index 450ca96f0..570d53f05 100644 --- a/src/ui/tool/node-tool.cpp +++ b/src/ui/tool/node-tool.cpp @@ -374,7 +374,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh ShapeRecord r; r.item = item; // TODO add support for objectBoundingBox - r.edit_transform = base ? sp_item_i2doc_affine(base) : Geom::identity(); + r.edit_transform = base ? base->i2doc_affine() : Geom::identity(); r.role = role; if (s.insert(r).second) { // this item was encountered the first time @@ -467,7 +467,7 @@ gint ink_node_tool_root_handler(SPEventContext *event_context, GdkEvent *event) nt->flashed_item = over_item; SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(over_item)); - c->transform(sp_item_i2d_affine(over_item)); + c->transform(over_item->i2d_affine()); SPCanvasItem *flash = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), c); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 66f72f379..8e37b2c85 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -119,7 +119,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _lpe_key(lpe_key) { if (_lpe_key.empty()) { - _i2d_transform = sp_item_i2d_affine(SP_ITEM(path)); + _i2d_transform = SP_ITEM(path)->i2d_affine(); } else { _i2d_transform = Geom::identity(); } @@ -988,7 +988,7 @@ void PathManipulator::_externalChange(unsigned type) } break; case PATH_CHANGE_TRANSFORM: { Geom::Matrix i2d_change = _d2i_transform; - _i2d_transform = sp_item_i2d_affine(SP_ITEM(_path)); + _i2d_transform = SP_ITEM(_path)->i2d_affine(); _d2i_transform = _i2d_transform.inverse(); i2d_change *= _i2d_transform; for (SubpathList::iterator i = _subpaths.begin(); i != _subpaths.end(); ++i) { diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 770a9bf87..2c325a5ee 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1219,12 +1219,12 @@ EditWidget::shutdown() switch (response) { case Gtk::RESPONSE_YES: - sp_document_ref(doc); + doc->doRef(); sp_namedview_document_from_window(_desktop); if (sp_file_save_document(*this, doc)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } break; @@ -1270,11 +1270,11 @@ EditWidget::shutdown() switch (response) { case Gtk::RESPONSE_YES: - sp_document_ref(doc); + doc->doRef(); if (sp_file_save_document(*this, doc)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } break; @@ -1394,7 +1394,7 @@ EditWidget::updateScrollbars (double scale) Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) ); SPObject* root = doc->root; SPItem* item = SP_ITEM(root); - Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item)); + Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop()); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index 71ba4428c..79cc8ca42 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -76,7 +76,7 @@ ImageIcon::ImageIcon(const ImageIcon &other) ImageIcon::~ImageIcon() { if (document) - sp_document_unref(document); + document->doUnref(); } @@ -98,11 +98,11 @@ bool ImageIcon::showSvgDocument(const SPDocument *docArg) { if (document) - sp_document_unref(document); + document->doUnref(); SPDocument *doc = (SPDocument *)docArg; - sp_document_ref(doc); + doc->doRef(); document = doc; //This should remove it from the box, and free resources @@ -127,7 +127,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) fileName = Glib::filename_to_utf8(fileName); - SPDocument *doc = sp_document_new (fileName.c_str(), 0); + SPDocument *doc = SPDocument::createDoc (fileName.c_str(), 0); if (!doc) { g_warning("SVGView: error loading document '%s'\n", fileName.c_str()); return false; @@ -135,7 +135,7 @@ bool ImageIcon::showSvgFile(const Glib::ustring &theFileName) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } @@ -148,7 +148,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) return false; gint len = (gint)strlen(xmlBuffer); - SPDocument *doc = sp_document_new_from_mem(xmlBuffer, len, 0); + SPDocument *doc = SPDocument::createDocFromMem(xmlBuffer, len, 0); if (!doc) { g_warning("SVGView: error loading buffer '%s'\n",xmlBuffer); return false; @@ -156,7 +156,7 @@ bool ImageIcon::showSvgFromMemory(const char *xmlBuffer) showSvgDocument(doc); - sp_document_unref(doc); + doc->doUnref(); return true; } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index a7359242d..ab21ecf32 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -146,7 +146,7 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() { Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { SPObject *layer = _getLayer(); if (layer && SP_IS_ITEM(layer)) { - return sp_item_bbox_desktop(SP_ITEM(layer), type); + return SP_ITEM(layer)->getBboxDesktop(type); } else { return Geom::OptRect(); } diff --git a/src/unclump.cpp b/src/unclump.cpp index 85306698c..1d051bc62 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -31,7 +31,7 @@ unclump_center (SPItem *item) return i->second; } - Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect r = item->getBounds(item->i2d_affine()); if (r) { Geom::Point const c = r->midpoint(); c_cache[item->getId()] = c; @@ -50,7 +50,7 @@ unclump_wh (SPItem *item) if ( i != wh_cache.end() ) { wh = i->second; } else { - Geom::OptRect r = item->getBounds(sp_item_i2d_affine(item)); + Geom::OptRect r = item->getBounds(item->i2d_affine()); if (r) { wh = r->dimensions(); wh_cache[item->getId()] = wh; @@ -294,8 +294,8 @@ unclump_push (SPItem *from, SPItem *what, double dist) //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); - sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); + what->set_i2d_affine(what->i2d_affine() * move); + what->doWriteTransform(SP_OBJECT_REPR(what), what->transform, NULL); } /** @@ -317,8 +317,8 @@ unclump_pull (SPItem *to, SPItem *what, double dist) //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); - sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); + what->set_i2d_affine(what->i2d_affine() * move); + what->doWriteTransform(SP_OBJECT_REPR(what), what->transform, NULL); } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 36047e81b..dfb22b6d0 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -879,12 +879,12 @@ SPDesktopWidget::shutdown() { Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); - sp_document_ref(doc); + doc->doRef(); sp_namedview_document_from_window(desktop); if (sp_file_save_document(*window, doc)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } @@ -937,14 +937,14 @@ SPDesktopWidget::shutdown() switch (response) { case GTK_RESPONSE_YES: { - sp_document_ref(doc); + doc->doRef(); Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); if (sp_file_save_dialog(*window, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG)) { - sp_document_unref(doc); + doc->doUnref(); } else { // save dialog cancelled or save failed - sp_document_unref(doc); + doc->doUnref(); return TRUE; } @@ -1806,7 +1806,7 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) ); SPObject* root = doc->root; SPItem* item = SP_ITEM(root); - Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item)); + Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop()); /* Canvas region we always show unconditionally */ Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64), diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 5d91d3532..e90cc1c46 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -918,7 +918,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, SPObject *object = doc->getObjectById(name); if (object && SP_IS_ITEM(object)) { /* Find bbox in document */ - Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); + Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine()); Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc); if ( SP_OBJECT_PARENT(object) == NULL ) @@ -1105,7 +1105,7 @@ static guchar *load_svg_pixels(gchar const *name, /* Try to load from document. */ if (!info && Inkscape::IO::file_test( doc_filename, G_FILE_TEST_IS_REGULAR ) && - (doc = sp_document_new( doc_filename, FALSE )) ) { + (doc = SPDocument::createDoc( doc_filename, FALSE )) ) { //g_message("Loaded icon file %s", doc_filename); // prep the document @@ -1113,7 +1113,7 @@ static guchar *load_svg_pixels(gchar const *name, /* Create new arena */ NRArena *arena = NRArena::create(); /* Create ArenaItem and set transform */ - unsigned visionkey = sp_item_display_key_new(1); + unsigned visionkey = SPItem::display_key_new(1); /* fixme: Memory manage root if needed (Lauris) */ // This needs to be fixed indeed; this leads to a memory leak of a few megabytes these days // because shapes are being rendered which are not being freed @@ -1135,8 +1135,7 @@ static guchar *load_svg_pixels(gchar const *name, ==7014== by 0x5E9DDE: nr_arena_group_render(_cairo*, NRArenaItem*, NRRectL*, NRPixBlock*, unsigned int) (nr-arena-group.cpp:228) ==7014== by 0x5E72FB: nr_arena_item_invoke_render(_cairo*, NRArenaItem*, NRRectL const*, NRPixBlock*, unsigned int) (nr-arena-item.cpp:578) */ - root = sp_item_invoke_show( SP_ITEM(SP_DOCUMENT_ROOT(doc)), - arena, visionkey, SP_ITEM_SHOW_DISPLAY ); + root = SP_ITEM(SP_DOCUMENT_ROOT(doc))->invoke_show(arena, visionkey, SP_ITEM_SHOW_DISPLAY ); // store into the cache info = new svg_doc_cache_t; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 8759854a0..55dc80f6f 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -875,7 +875,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc) if (patterns_doc == NULL) { char *patterns_source = g_build_filename(INKSCAPE_PATTERNSDIR, "patterns.svg", NULL); if (Inkscape::IO::file_test(patterns_source, G_FILE_TEST_IS_REGULAR)) { - patterns_doc = sp_document_new(patterns_source, FALSE); + patterns_doc = SPDocument::createDoc(patterns_source, FALSE); } g_free(patterns_source); } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index f020b0c3a..a8c0788e6 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -182,7 +182,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, return NULL; // sandbox broken? // Find object's bbox in document - Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); + Geom::Matrix const i2doc(SP_ITEM(object)->i2doc_affine()); Geom::OptRect dbox = SP_ITEM(object)->getBounds(i2doc); if (!dbox) { @@ -242,8 +242,8 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD { // Do this here, outside of loop, to speed up preview generation: NRArena const *arena = NRArena::create(); - unsigned const visionkey = sp_item_display_key_new(1); - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(SP_DOCUMENT_ROOT (sandbox)), (NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); + unsigned const visionkey = SPItem::display_key_new(1); + NRArenaItem *root = SP_ITEM(SP_DOCUMENT_ROOT (sandbox))->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY); for (; marker_list != NULL; marker_list = marker_list->next) { Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data); @@ -280,7 +280,7 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD m->append(*i); } - sp_item_invoke_hide(SP_ITEM(sp_document_root(sandbox)), visionkey); + SP_ITEM(sp_document_root(sandbox))->invoke_hide(visionkey); nr_object_unref((NRObject *) arena); } @@ -342,7 +342,7 @@ gchar const *buffer = "