summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Holder <speleo3@users.sourceforge.net>2008-12-16 15:52:36 +0000
committerspeleo3 <speleo3@users.sourceforge.net>2008-12-16 15:52:36 +0000
commit4fc3975983c401a7fb95084ab2db10d609e36f05 (patch)
treeaab43b87dcf998923b3d7b1c21b2c5dfa4e15f17 /src
parentAdded "Add" button to the SVG Fonts dialog. (diff)
downloadinkscape-4fc3975983c401a7fb95084ab2db10d609e36f05.tar.gz
inkscape-4fc3975983c401a7fb95084ab2db10d609e36f05.zip
* remove sp_item_i2root_affine and sp_item_i2r_affine and replace all calls by
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) (bzr r7010)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/export.cpp2
-rw-r--r--src/extension/internal/cairo-renderer.cpp2
-rw-r--r--src/main.cpp2
-rw-r--r--src/selection-chemistry.cpp6
-rw-r--r--src/sp-flowregion.cpp19
-rw-r--r--src/sp-item.cpp42
-rw-r--r--src/sp-item.h2
-rw-r--r--src/sp-root.cpp18
-rw-r--r--src/splivarot.cpp10
9 files changed, 25 insertions, 78 deletions
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index f1a68c999..cce57486d 100644
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
@@ -1099,7 +1099,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
}
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);
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 4bc983cb7..a536a67ac 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -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 eb060570f..515ed9c18 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1191,7 +1191,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_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 {
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 4e93c4832..b6a194d9a 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -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;
@@ -2229,7 +2229,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_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();
@@ -2899,7 +2899,7 @@ fit_canvas_to_drawing(SPDocument *doc)
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 3b45951b8..79007cac7 100644
--- a/src/sp-flowregion.cpp
+++ b/src/sp-flowregion.cpp
@@ -55,7 +55,7 @@ static gchar * sp_flowregionexclude_description (SPItem * item);
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)
@@ -190,16 +190,13 @@ void SPFlowregion::UpdateComputed(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);
}
}
@@ -414,11 +411,9 @@ void SPFlowregionExclude::UpdateComputed(void)
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);
}
}
@@ -510,15 +505,19 @@ static void UnionShape(Shape **base_shape, Shape const *add_shape)
}
}
-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));
@@ -528,8 +527,6 @@ static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat)
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 78561de1b..519ed2a45 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -1515,8 +1515,9 @@ i2anc_affine(SPObject const *object, SPObject const *const ancestor) {
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;
@@ -1543,30 +1544,8 @@ Geom::Matrix sp_item_i2doc_affine(SPItem const *item)
}
/**
- * 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);
@@ -1578,18 +1557,6 @@ Geom::Matrix sp_item_i2d_affine(SPItem const *item)
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.
@@ -1632,6 +1599,9 @@ 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)
{
diff --git a/src/sp-item.h b/src/sp-item.h
index a2a9c1ba3..03fec93e6 100644
--- a/src/sp-item.h
+++ b/src/sp-item.h
@@ -257,7 +257,6 @@ 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_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);
@@ -271,7 +270,6 @@ 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 5a9cce8fb..0cb3d3389 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -51,7 +51,6 @@ static void sp_root_modified(SPObject *object, guint flags);
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;
@@ -106,7 +105,6 @@ sp_root_class_init(SPRootClass *klass)
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;
}
@@ -641,22 +639,6 @@ sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags)
}
/**
- * 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.
*/
static void
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index eb01e625a..55d1146b1 100644
--- 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);