diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
| commit | 945ce419c806c73d70203dec33ececafbe108a92 (patch) | |
| tree | cfcdb59bf47e9db7f9e01f7eebb59924bdeaea94 /src/selection-chemistry.cpp | |
| parent | Merge from trunk (again) (diff) | |
| parent | Extensions. SVG+media fix (see Bug #400356). (diff) | |
| download | inkscape-945ce419c806c73d70203dec33ececafbe108a92.tar.gz inkscape-945ce419c806c73d70203dec33ececafbe108a92.zip | |
Merge from trunk
(bzr r9508.1.73)
Diffstat (limited to 'src/selection-chemistry.cpp')
| -rw-r--r-- | src/selection-chemistry.cpp | 189 |
1 files changed, 101 insertions, 88 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 91c902a46..7dbffba1a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -212,7 +212,7 @@ void SelectionHelper::selectPrev(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Matrix full_t, GSList **clip, Inkscape::XML::Document* xml_doc) +void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -239,7 +239,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(i->data)->i2doc_affine(), clip, xml_doc); + sp_selection_copy_one(SP_OBJECT(i->data)->getRepr(), SP_ITEM(i->data)->i2doc_affine(), clip, xml_doc); } *clip = g_slist_reverse(*clip); @@ -257,10 +257,10 @@ 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(parent)->i2doc_affine()); + Geom::Affine local(SP_ITEM(parent)->i2doc_affine()); if (!local.isIdentity()) { gchar const *t_str = copy->attribute("transform"); - Geom::Matrix item_t(Geom::identity()); + Geom::Affine item_t(Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= local.inverse(); @@ -408,7 +408,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) // std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n"; gchar *newref = g_strdup_printf("#%s", new_ids[j]); SPObject *new_clone = doc->getObjectById(new_ids[i]); - SP_OBJECT_REPR(new_clone)->setAttribute("xlink:href", newref); + new_clone->getRepr()->setAttribute("xlink:href", newref); new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); g_free(newref); } @@ -587,7 +587,7 @@ void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XM // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform gchar const *t_str = current->attribute("transform"); - Geom::Matrix item_t(Geom::identity()); + Geom::Affine item_t(Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= SP_ITEM(doc->getObjectByRepr(current->parent()))->i2doc_affine(); @@ -691,7 +691,7 @@ void sp_selection_ungroup(SPDesktop *desktop) } /* We do not allow ungrouping <svg> etc. (lauris) */ - if (strcmp(SP_OBJECT_REPR(group)->name(), "svg:g") && strcmp(SP_OBJECT_REPR(group)->name(), "svg:switch")) { + if (strcmp(group->getRepr()->name(), "svg:g") && strcmp(group->getRepr()->name(), "svg:switch")) { // keep the non-group item in the new selection new_select = g_slist_append(new_select, group); continue; @@ -755,13 +755,13 @@ sp_item_list_common_parent_group(GSList const *items) if (!items) { return NULL; } - SPObject *parent = SP_OBJECT_PARENT(items->data); - /* Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor */ + SPObject *parent = SP_OBJECT(items->data)->parent; + // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor if (!SP_IS_GROUP(parent)) { return NULL; } for (items = items->next; items; items = items->next) { - if (SP_OBJECT_PARENT(items->data) != parent) { + if (SP_OBJECT(items->data)->parent != parent) { return NULL; } } @@ -812,7 +812,7 @@ sp_selection_raise(SPDesktop *desktop) return; } - Inkscape::XML::Node *grepr = SP_OBJECT_REPR(group); + Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); /* Construct reverse-ordered list of selected children. */ GSList *rev = g_slist_copy((GSList *) items); @@ -834,7 +834,7 @@ sp_selection_raise(SPDesktop *desktop) // AND if it's not one of our selected objects, if (!g_slist_find((GSList *) items, newref)) { // move the selected object after that sibling - grepr->changeOrder(SP_OBJECT_REPR(child), SP_OBJECT_REPR(newref)); + grepr->changeOrder(child->getRepr(), newref->getRepr()); } break; } @@ -906,7 +906,7 @@ sp_selection_lower(SPDesktop *desktop) return; } - Inkscape::XML::Node *grepr = SP_OBJECT_REPR(group); + Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); @@ -931,9 +931,9 @@ sp_selection_lower(SPDesktop *desktop) // move the selected object before that sibling SPObject *put_after = prev_sibling(newref); if (put_after) - grepr->changeOrder(SP_OBJECT_REPR(child), SP_OBJECT_REPR(put_after)); + grepr->changeOrder(child->getRepr(), put_after->getRepr()); else - SP_OBJECT_REPR(child)->setPosition(0); + child->getRepr()->setPosition(0); } break; } @@ -1299,7 +1299,7 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix const &affine, bool set_i2d, bool compensate) +void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate) { if (selection->isEmpty()) return; @@ -1316,7 +1316,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons std::list<SPBox3D *> selboxes = selection->box3DList(persp); // create a new perspective as a copy of the current one and link the selected boxes to it - transf_persp = persp3d_create_xml_element (SP_OBJECT_DOCUMENT(persp), persp->perspective_impl); + transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl); for (std::list<SPBox3D *>::iterator b = selboxes.begin(); b != selboxes.end(); ++b) box3d_switch_perspectives(*b, persp, transf_persp); @@ -1375,9 +1375,9 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons * Same for textpath if we are also doing ANY transform to its path: do not touch textpath, * letters cannot be squeezed or rotated anyway, they only refill the changed path. * Same for linked offset if we are also moving its source: do not move it. */ - if (transform_textpath_with_path || transform_offset_with_source) { + if (transform_textpath_with_path) { // Restore item->transform field from the repr, in case it was changed by seltrans. - SP_OBJECT(item)->readAttr( "transform" ); + item->readAttr( "transform" ); } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the <use> so that the flow remains // the same (even though the output itself gets transformed) @@ -1390,48 +1390,61 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons } } } - } else if (transform_clone_with_original) { + } else if (transform_clone_with_original || transform_offset_with_source) { // We are transforming a clone along with its original. The below matrix juggling is // necessary to ensure that they transform as a whole, i.e. the clone's induced // transform and its move compensation are both cancelled out. // restore item->transform field from the repr, in case it was changed by seltrans - SP_OBJECT(item)->readAttr( "transform" ); + item->readAttr( "transform" ); // calculate the matrix we need to apply to the clone to cancel its induced transform from its original - 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; + Geom::Affine parent2dt = SP_ITEM(item->parent)->i2d_affine(); + Geom::Affine t = parent2dt * affine * parent2dt.inverse(); + Geom::Affine t_inv = t.inverse(); + Geom::Affine result = t_inv * item->transform * t; - if ((prefs_parallel || prefs_unmoved) && affine.isTranslation()) { + if (transform_clone_with_original && (prefs_parallel || prefs_unmoved) && affine.isTranslation()) { // we need to cancel out the move compensation, too // find out the clone move, same as in sp_use_move_compensate - Geom::Matrix parent = sp_use_get_parent_transform(SP_USE(item)); - Geom::Matrix clone_move = parent.inverse() * t * parent; + Geom::Affine parent = sp_use_get_parent_transform(SP_USE(item)); + Geom::Affine clone_move = parent.inverse() * t * parent; if (prefs_parallel) { - Geom::Matrix move = result * clone_move * t_inv; - item->doWriteTransform(SP_OBJECT_REPR(item), move, &move, compensate); + Geom::Affine move = result * clone_move * t_inv; + item->doWriteTransform(item->getRepr(), 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; - item->doWriteTransform(SP_OBJECT_REPR(item), move, &t, compensate); + Geom::Affine move = result * clone_move; + item->doWriteTransform(item->getRepr(), move, &t, compensate); + } + + } else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()){ + Geom::Affine parent = item->transform; + Geom::Affine offset_move = parent.inverse() * t * parent; + + if (prefs_parallel) { + Geom::Affine move = result * offset_move * t_inv; + item->doWriteTransform(item->getRepr(), move, &move, compensate); + + } else if (prefs_unmoved) { + Geom::Affine move = result * offset_move; + item->doWriteTransform(item->getRepr(), move, &t, compensate); } } else { // just apply the result - item->doWriteTransform(SP_OBJECT_REPR(item), result, &t, compensate); + item->doWriteTransform(item->getRepr(), result, &t, compensate); } } else { if (set_i2d) { - item->set_i2d_affine(item->i2d_affine() * (Geom::Matrix)affine); + item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine); } - item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, NULL, compensate); + item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate); } // if we're moving the actual object, not just updating the repr, we can transform the @@ -1479,7 +1492,7 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, y1 - y0); Geom::Scale const scale( newSize * Geom::Scale(bbox->dimensions()).inverse() ); Geom::Translate const o2n(x0, y0); - Geom::Matrix const final( p2o * scale * o2n ); + Geom::Affine const final( p2o * scale * o2n ); sp_selection_apply_affine(selection, final); } @@ -1505,7 +1518,7 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con Geom::Translate const n2d(-align); Geom::Translate const d2n(align); - Geom::Matrix const final( n2d * scale * d2n ); + Geom::Affine const final( n2d * scale * d2n ); sp_selection_apply_affine(selection, final); } @@ -1515,7 +1528,7 @@ sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const & Geom::Translate const d2n(center); Geom::Translate const n2d(-center); Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees)); - Geom::Matrix const final( Geom::Matrix(n2d) * rotate * d2n ); + Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n ); sp_selection_apply_affine(selection, final); } @@ -1524,21 +1537,21 @@ sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &al { Geom::Translate const d2n(align); Geom::Translate const n2d(-align); - Geom::Matrix const skew(1, dy, + Geom::Affine const skew(1, dy, dx, 1, 0, 0); - Geom::Matrix const final( n2d * skew * d2n ); + Geom::Affine const final( n2d * skew * d2n ); sp_selection_apply_affine(selection, final); } void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move, bool compensate) { - sp_selection_apply_affine(selection, Geom::Matrix(Geom::Translate(move)), true, compensate); + sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(move)), true, compensate); } void sp_selection_move_relative(Inkscape::Selection *selection, double dx, double dy) { - sp_selection_apply_affine(selection, Geom::Matrix(Geom::Translate(dx, dy))); + sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(dx, dy))); } /** @@ -1762,7 +1775,7 @@ struct ListReverse { return make_list(o->firstChild(), NULL); } static Iterator siblings_after(SPObject *o) { - return make_list(SP_OBJECT_PARENT(o)->firstChild(), o); + return make_list(o->parent->firstChild(), o); } static void dispose(Iterator i) { g_slist_free(i); @@ -1893,8 +1906,8 @@ void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/) for (GSList *i = const_cast<GSList*>(items); i; i= i->next) { SPItem *item = SP_ITEM(i->data); SPObject *search = clip - ? SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL) - : SP_OBJECT(item->mask_ref ? item->mask_ref->getObject() : NULL); + ? (item->clip_ref ? item->clip_ref->getObject() : NULL) + : item->mask_ref ? item->mask_ref->getObject() : NULL; has_path |= has_path_recursive(search); if (has_path) break; } @@ -1935,7 +1948,7 @@ SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, GSList *path=NULL; while ( current != root ) { path = g_slist_prepend(path, current); - current = SP_OBJECT_PARENT(current); + current = current->parent; } SPItem *next; @@ -1961,7 +1974,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, if (path) { SPObject *object=reinterpret_cast<SPObject *>(path->data); - g_assert(SP_OBJECT_PARENT(object) == root); + g_assert(object->parent == root); if (desktop->isLayer(object)) { found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); } @@ -2101,7 +2114,7 @@ sp_selection_relink(SPDesktop *desktop) if (!SP_IS_USE(item)) continue; - SP_OBJECT_REPR(item)->setAttribute("xlink:href", newref); + item->getRepr()->setAttribute("xlink:href", newref); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); relinked = true; } @@ -2211,7 +2224,7 @@ sp_select_clone_original(SPDesktop *desktop) } else if (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) { original = sp_offset_get_source(SP_OFFSET(item)); } else if (SP_IS_TEXT_TEXTPATH(item)) { - original = sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->firstChild())); + original = sp_textpath_get_path_item(SP_TEXTPATH(item->firstChild())); } else if (SP_IS_FLOWTEXT(item)) { original = SP_FLOWTEXT(item)->get_frame(NULL); // first frame only } else { // it's an object that we don't know what to do with @@ -2224,7 +2237,7 @@ sp_select_clone_original(SPDesktop *desktop) return; } - for (SPObject *o = original; o && !SP_IS_ROOT(o); o = SP_OBJECT_PARENT(o)) { + for (SPObject *o = original; o && !SP_IS_ROOT(o); o = o->parent) { if (SP_IS_DEFS(o)) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in <defs>)")); return; @@ -2287,25 +2300,25 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // calculate the transform to be applied to objects to move them to 0,0 Geom::Point move_p = Geom::Point(0, doc->getHeight()) - *c; move_p[Geom::Y] = -move_p[Geom::Y]; - Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p)); + Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); GSList *items = g_slist_copy((GSList *) selection->itemList()); items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT_PARENT(items->data); + SPObject *parent = SP_OBJECT(items->data)->parent; - Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine()); + Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine()); // remember the position of the first item - gint pos = SP_OBJECT_REPR(items->data)->position(); + gint pos = SP_OBJECT(items->data)->getRepr()->position(); (void)pos; // TODO check why this was remembered // create a list of duplicates GSList *repr_copies = NULL; for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); repr_copies = g_slist_prepend(repr_copies, dup); } @@ -2327,7 +2340,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); gchar const *mark_id = generate_marker(repr_copies, bounds, doc, - ( Geom::Matrix(Geom::Translate(desktop->dt2doc( + ( Geom::Affine(Geom::Translate(desktop->dt2doc( Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) * parent_transform.inverse() ), @@ -2411,24 +2424,24 @@ sp_selection_tile(SPDesktop *desktop, bool apply) // calculate the transform to be applied to objects to move them to 0,0 Geom::Point move_p = Geom::Point(0, doc->getHeight()) - (r->min() + Geom::Point(0, r->dimensions()[Geom::Y])); move_p[Geom::Y] = -move_p[Geom::Y]; - Geom::Matrix move = Geom::Matrix(Geom::Translate(move_p)); + Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); GSList *items = g_slist_copy((GSList *) selection->itemList()); items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT_PARENT(items->data); + SPObject *parent = SP_OBJECT(items->data)->parent; - Geom::Matrix parent_transform(SP_ITEM(parent)->i2doc_affine()); + Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine()); // remember the position of the first item - gint pos = SP_OBJECT_REPR(items->data)->position(); + gint pos = SP_OBJECT(items->data)->getRepr()->position(); // create a list of duplicates GSList *repr_copies = NULL; for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); repr_copies = g_slist_prepend(repr_copies, dup); } // restore the z-order after prepends @@ -2452,7 +2465,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); gchar const *pat_id = pattern_tile(repr_copies, bounds, doc, - ( Geom::Matrix(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], + ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X], r->max()[Geom::Y])))) * parent_transform.inverse() ), parent_transform * move); @@ -2473,7 +2486,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) sp_repr_set_svg_double(rect, "y", min[Geom::Y]); // restore parent and position - SP_OBJECT_REPR(parent)->appendChild(rect); + parent->getRepr()->appendChild(rect); rect->setPosition(pos > 0 ? pos : 0); SPItem *rectangle = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(rect); @@ -2530,11 +2543,11 @@ void sp_selection_untile(SPDesktop *desktop) SPPattern *pattern = pattern_getroot(SP_PATTERN(server)); - Geom::Matrix pat_transform = pattern_patternTransform(SP_PATTERN(server)); + Geom::Affine pat_transform = pattern_patternTransform(SP_PATTERN(server)); pat_transform *= item->transform; for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { - Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc); + Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); SPItem *i = SP_ITEM(desktop->currentLayer()->appendChildRepr(copy)); // FIXME: relink clones to the new canvas objects @@ -2543,15 +2556,15 @@ void sp_selection_untile(SPDesktop *desktop) // this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work) doc->ensureUpToDate(); - Geom::Matrix transform( i->transform * pat_transform ); - i->doWriteTransform(SP_OBJECT_REPR(i), transform); + Geom::Affine transform( i->transform * pat_transform ); + i->doWriteTransform(i->getRepr(), transform); new_select = g_slist_prepend(new_select, i); } SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill", "none"); - sp_repr_css_change(SP_OBJECT_REPR(item), css, "style"); + sp_repr_css_change(item->getRepr(), css, "style"); } if (!did) { @@ -2671,7 +2684,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", document->getName(), - SP_OBJECT_REPR(items->data)->attribute("id"), + SP_OBJECT(items->data)->getRepr()->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, // digits, and a few other chars, with "_" @@ -2690,9 +2703,9 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) //g_print("%s\n", filepath); // Remember parent and z-order of the topmost one - gint pos = SP_OBJECT_REPR(g_slist_last(items)->data)->position(); - SPObject *parent_object = SP_OBJECT_PARENT(g_slist_last(items)->data); - Inkscape::XML::Node *parent = SP_OBJECT_REPR(parent_object); + gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position(); + SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent; + Inkscape::XML::Node *parent = parent_object->getRepr(); // Calculate resolution Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2753,8 +2766,8 @@ void 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(parent_object)->i2d_affine()); - Geom::Matrix t; + Geom::Affine eek(SP_ITEM(parent_object)->i2d_affine()); + Geom::Affine t; double shift_x = bbox->min()[Geom::X]; double shift_y = bbox->max()[Geom::Y]; @@ -2890,7 +2903,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); SPObject *item = reinterpret_cast<SPObject*>(i->data); @@ -2904,7 +2917,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } else if (!topmost) { // topmost item is used as a mask, which is applied to other items in a selection GSList *i = items; - Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { @@ -2923,7 +2936,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_select = g_slist_prepend(items_to_select, i->data); } - Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { @@ -2946,8 +2959,8 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ GSList *reprs_to_group = NULL; for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { - reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT_REPR(i->data)); - items_to_select = g_slist_remove(items_to_select, i->data); + reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr()); + items_to_select = g_slist_remove(items_to_select, i->data); } reprs_to_group = g_slist_reverse(reprs_to_group); @@ -2970,7 +2983,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ SPItem *item = reinterpret_cast<SPItem *>(i->data); // inverted object transform should be applied to a mask object, // as mask is calculated in user space (after applying transform) - Geom::Matrix maskTransform(item->transform.inverse()); + Geom::Affine maskTransform(item->transform.inverse()); GSList *mask_items_dup = NULL; for (GSList *mask_item = mask_items; NULL != mask_item; mask_item = mask_item->next) { @@ -2988,7 +3001,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ g_slist_free(mask_items_dup); mask_items_dup = NULL; - Inkscape::XML::Node *current = SP_OBJECT_REPR(i->data); + Inkscape::XML::Node *current = SP_OBJECT(i->data)->getRepr(); // Node to apply mask to Inkscape::XML::Node *apply_mask_to = current; @@ -3091,7 +3104,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } } - SP_OBJECT_REPR(i->data)->setAttribute(attributeName, "none"); + SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none"); if (ungroup_masked && SP_IS_GROUP(i->data)) { // if we had previously enclosed masked object in group, @@ -3113,7 +3126,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { GSList *items_to_move = NULL; for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { // Collect all clipped paths and masks within a single group - Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc); + Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc); items_to_move = g_slist_prepend(items_to_move, copy); } @@ -3123,8 +3136,8 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } // remember parent and position of the item to which the clippath/mask was applied - Inkscape::XML::Node *parent = SP_OBJECT_REPR((*it).second)->parent(); - gint pos = SP_OBJECT_REPR((*it).second)->position(); + Inkscape::XML::Node *parent = ((*it).second)->getRepr()->parent(); + gint pos = ((*it).second)->getRepr()->position(); // Iterate through all clipped paths / masks for (GSList *i = items_to_move; NULL != i; i = i->next) { @@ -3138,9 +3151,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { items_to_select = g_slist_prepend(items_to_select, mask_item); // transform mask, so it is moved the same spot where mask was applied - Geom::Matrix transform(mask_item->transform); + Geom::Affine transform(mask_item->transform); transform *= (*it).second->transform; - mask_item->doWriteTransform(SP_OBJECT_REPR(mask_item), transform); + mask_item->doWriteTransform(mask_item->getRepr(), transform); } g_slist_free(items_to_move); @@ -3218,7 +3231,7 @@ fit_canvas_to_drawing(SPDocument *doc, bool with_margins) doc->ensureUpToDate(); SPItem const *const root = SP_ITEM(doc->root); - Geom::OptRect const bbox(root->getBounds(root->i2d_affine())); + Geom::OptRect const bbox(root->getBounds(root->i2d_affine(), SPItem::RENDERING_BBOX)); if (bbox) { doc->fitToRect(*bbox, with_margins); return true; |
