summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c702dce)
raw | patch | inline | side by side (parent: c702dce)
author | speleo3 <speleo3@users.sourceforge.net> | |
Tue, 16 Dec 2008 15:52:36 +0000 (15:52 +0000) | ||
committer | speleo3 <speleo3@users.sourceforge.net> | |
Tue, 16 Dec 2008 15:52:36 +0000 (15:52 +0000) |
sp_item_i2doc_affine or sp_item_i2d_affine respectively
* remove sp_root_bbox, root->c2p was considered in the wrong place there
* in sp_item_i2doc_affine do not consider SP_ITEM(object)->transform for root
node, because <svg> node does not have a transform attribute
* fix style scaling for boolean operations (with viewBox)
* fix zoom to fit drawing (with viewBox)
* fix export area size for "export drawing" (with viewBox)
* fix simultaneous movement of clone + original (with viewBox)
* remove sp_root_bbox, root->c2p was considered in the wrong place there
* in sp_item_i2doc_affine do not consider SP_ITEM(object)->transform for root
node, because <svg> node does not have a transform attribute
* fix style scaling for boolean operations (with viewBox)
* fix zoom to fit drawing (with viewBox)
* fix export area size for "export drawing" (with viewBox)
* fix simultaneous movement of clone + original (with viewBox)
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index f1a68c9994dbadc52b33b0a76b392d89adc0e02a..cce57486d7813cc3e1a69c1561a190cfd2e10dc4 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
}
Geom::OptRect area;
- sp_item_invoke_bbox(item, area, sp_item_i2r_affine((SPItem *) item), TRUE);
+ sp_item_invoke_bbox(item, area, sp_item_i2d_affine((SPItem *) item), 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);
index 4bc983cb75247e77903b48abdff190e5072eb999..a536a67acf5565615c024f45859f565943fa7514 100644 (file)
@@ -602,7 +602,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
d.x1 = ceil(sp_document_width(doc));
d.y1 = ceil(sp_document_height(doc));
} else {
- sp_item_invoke_bbox(base, &d, sp_item_i2r_affine(base), TRUE, SPItem::RENDERING_BBOX);
+ sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
}
if (ctx->_vector_based_target) {
diff --git a/src/main.cpp b/src/main.cpp
index eb060570f1ebd0e3d422622ec0a042e3c6ffa8bc..515ed9c1838a0d131f8e7577b1970f32b711e402 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
// 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_i2r_affine((SPItem *) o_area), TRUE);
+ sp_item_invoke_bbox((SPItem *) o_area, areaMaybe, sp_item_i2d_affine((SPItem *) o_area), TRUE);
if (areaMaybe) {
area = *areaMaybe;
} else {
index 4e93c48326b11598d875275c0ebf6297972bf084..b6a194d9a9fcb86915ff826f617f47fdab62fee8 100644 (file)
@@ -1216,7 +1216,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 parent_transform = sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
+ Geom::Matrix parent_transform = sp_item_i2doc_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
Geom::Matrix t = parent_transform * matrix_to_desktop (matrix_from_desktop (affine, item), item) * parent_transform.inverse();
Geom::Matrix t_inv =parent_transform * matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item) * parent_transform.inverse();
Geom::Matrix result = t_inv * item->transform * t;
// bottommost object, after sorting
SPObject *parent = SP_OBJECT_PARENT (items->data);
- Geom::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent)));
+ Geom::Matrix parent_transform (sp_item_i2doc_affine(SP_ITEM(parent)));
// remember the position of the first item
gint pos = SP_OBJECT_REPR (items->data)->position();
sp_document_ensure_up_to_date(doc);
SPItem const *const root = SP_ITEM(doc->root);
- Geom::OptRect const bbox(root->getBounds(sp_item_i2r_affine(root)));
+ Geom::OptRect const bbox(root->getBounds(sp_item_i2d_affine(root)));
if (bbox) {
doc->fitToRect(*bbox);
return true;
diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp
index 3b45951b8232655c0af3b02bf9a58c837877bba3..79007cac7735a7494fb43db723ef5395de4f491c 100644 (file)
--- a/src/sp-flowregion.cpp
+++ b/src/sp-flowregion.cpp
static SPItemClass * flowregionexclude_parent_class;
-static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat);
+static void GetDest(SPObject* child,Shape **computed);
GType
sp_flowregion_get_type (void)
{
SPObject* object=SP_OBJECT(this);
- NR::Matrix itr_mat (sp_item_i2root_affine (SP_ITEM(object)));
- itr_mat = itr_mat.inverse();
-
for (std::vector<Shape*>::iterator it = computed.begin() ; it != computed.end() ; it++)
delete *it;
computed.clear();
for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
Shape *shape = NULL;
- GetDest(child,&shape,itr_mat);
+ GetDest(child,&shape);
computed.push_back(shape);
}
}
delete computed;
computed = NULL;
}
- NR::Matrix itr_mat (sp_item_i2root_affine (SP_ITEM(object)));
- itr_mat = itr_mat.inverse();
for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
- GetDest(child,&computed,itr_mat);
+ GetDest(child,&computed);
}
}
}
}
-static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat)
+static void GetDest(SPObject* child,Shape **computed)
{
if ( child == NULL ) return;
SPCurve *curve=NULL;
+ Geom::Matrix tr_mat;
SPObject* u_child=child;
if ( SP_IS_USE(u_child) ) {
u_child=SP_USE(u_child)->child;
+ tr_mat = SP_ITEM(u_child)->getRelativeTransform(SP_OBJECT_PARENT(child));
+ } else {
+ tr_mat = SP_ITEM(u_child)->transform;
}
if ( SP_IS_SHAPE (u_child) ) {
curve = sp_shape_get_curve (SP_SHAPE (u_child));
if ( curve ) {
Path* temp=new Path;
- Geom::Matrix tr_mat = sp_item_i2root_affine (SP_ITEM(u_child));
- tr_mat = (Geom::Matrix)itr_mat * tr_mat;
temp->LoadPathVector(curve->get_pathvector(), tr_mat, true);
Shape* n_shp=new Shape;
temp->Convert(0.25);
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 78561de1b50fbcb2ba640cc93f340784350e3bba..519ed2a45f79bcbfae4169c7515e362cb7e2f3d2 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
while ( object != ancestor && SP_IS_ITEM(object) ) {
if (SP_IS_ROOT(object)) {
ret *= SP_ROOT(object)->c2p;
+ } else {
+ ret *= SP_ITEM(object)->transform;
}
- ret *= SP_ITEM(object)->transform;
object = SP_OBJECT_PARENT(object);
}
return ret;
}
/**
- * Returns the accumulated transformation of the item and all its ancestors, but excluding root's viewport.
- * Used in path operations mostly.
- * \pre (item != NULL) and SP_IS_ITEM(item).
+ * Returns the transformation from item to desktop coords
*/
-Geom::Matrix sp_item_i2root_affine(SPItem const *item)
-{
- g_assert(item != NULL);
- g_assert(SP_IS_ITEM(item));
-
- Geom::Matrix ret(Geom::identity());
- g_assert(ret.isIdentity());
- while ( NULL != SP_OBJECT_PARENT(item) ) {
- ret *= item->transform;
- item = SP_ITEM(SP_OBJECT_PARENT(item));
- }
- g_assert(SP_IS_ROOT(item));
-
- ret *= item->transform;
-
- return ret;
-}
-
-/* fixme: This is EVIL!!! */
-// fix this note: why/what evil? :)
Geom::Matrix sp_item_i2d_affine(SPItem const *item)
{
g_assert(item != NULL);
return ret;
}
-// same as i2d but with i2root instead of i2doc
-Geom::Matrix sp_item_i2r_affine(SPItem const *item)
-{
- g_assert(item != NULL);
- g_assert(SP_IS_ITEM(item));
-
- Geom::Matrix const ret( sp_item_i2root_affine(item)
- * Geom::Scale(1, -1)
- * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
- return ret;
-}
-
/**
* Converts a matrix \a m into the desktop coords of the \a item.
* Will become a noop when we eliminate the coordinate flipping.
}
+/**
+ * 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)
{
diff --git a/src/sp-item.h b/src/sp-item.h
index a2a9c1ba385b31d7ab4aef0090522f632ad0d8e5..03fec93e62892be3fd4d3c7df14b5ca109967103 100644 (file)
--- a/src/sp-item.h
+++ b/src/sp-item.h
Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest);
Geom::Matrix sp_item_i2doc_affine(SPItem const *item);
-Geom::Matrix sp_item_i2root_affine(SPItem const *item);
Geom::Matrix matrix_to_desktop (Geom::Matrix m, SPItem const *item);
Geom::Matrix matrix_from_desktop (Geom::Matrix m, SPItem const *item);
* \return TRANSFORM.
*/
Geom::Matrix sp_item_i2d_affine(SPItem const *item);
-Geom::Matrix sp_item_i2r_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);
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 5a9cce8fbda6b157fc2f117d8ce35a4e3b8dbc27..0cb3d3389a4b33f39b6efeefebafc0141ae5cbc8 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
-static void sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_root_print(SPItem *item, SPPrintContext *ctx);
static SPGroupClass *parent_class;
sp_object_class->write = sp_root_write;
sp_item_class->show = sp_root_show;
- sp_item_class->bbox = sp_root_bbox;
sp_item_class->print = sp_root_print;
}
@@ -640,22 +638,6 @@ sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags)
return ai;
}
-/**
- * Virtual bbox callback.
- */
-static void
-sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
-{
- SPRoot const *root = SP_ROOT(item);
-
- if (((SPItemClass *) (parent_class))->bbox) {
- Geom::Matrix const product( to_2geom(root->c2p) * transform );
- ((SPItemClass *) (parent_class))->bbox(item, bbox,
- product,
- flags);
- }
-}
-
/**
* Virtual print callback.
*/
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index eb01e625ab8d0b30ff3b8ee60bf5a3a9581b06f4..55d1146b1aef50ca3b98d7383bf553af4c5a7048 100644 (file)
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -452,11 +452,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);
- NR::Matrix i2root(sp_item_i2root_affine(item_source));
- sp_item_adjust_stroke(item_source, i2root.descrim());
- sp_item_adjust_pattern(item_source, i2root);
- sp_item_adjust_gradient(item_source, i2root);
- sp_item_adjust_livepatheffect(item_source, i2root);
+ NR::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);
Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source);