diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-01-30 13:18:11 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-01-30 13:18:11 +0000 |
| commit | a4ce97ec6835fb6ea8dfd3dbee11abe103b064e4 (patch) | |
| tree | e191825938581efc762f57e6915068e9c17b57fb /src | |
| parent | Prevent crash if a symbols file does not have a title. (diff) | |
| download | inkscape-a4ce97ec6835fb6ea8dfd3dbee11abe103b064e4.tar.gz inkscape-a4ce97ec6835fb6ea8dfd3dbee11abe103b064e4.zip | |
Correct positioning of custom markers. Fixes #230491.
(bzr r12986)
Diffstat (limited to 'src')
| -rw-r--r-- | src/marker.cpp | 6 | ||||
| -rw-r--r-- | src/marker.h | 2 | ||||
| -rw-r--r-- | src/selection-chemistry.cpp | 29 |
3 files changed, 20 insertions, 17 deletions
diff --git a/src/marker.cpp b/src/marker.cpp index d145aadaf..b9464186d 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -654,7 +654,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro delete view; } -const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine /*transform*/, Geom::Affine move) +const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -668,6 +668,8 @@ const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *docum sp_repr_set_svg_double(repr, "markerWidth", bounds.dimensions()[Geom::X]); sp_repr_set_svg_double(repr, "markerHeight", bounds.dimensions()[Geom::Y]); + sp_repr_set_svg_double(repr, "refX", center[Geom::X]); + sp_repr_set_svg_double(repr, "refY", center[Geom::Y]); repr->setAttribute("orient", "auto"); @@ -676,7 +678,7 @@ const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *docum SPObject *mark_object = document->getObjectById(mark_id); for (GSList *i = reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); + Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/marker.h b/src/marker.h index 831b298ac..b780950de 100644 --- a/src/marker.h +++ b/src/marker.h @@ -97,7 +97,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3082a2fe4..3f54ef8b9 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2804,6 +2804,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) void sp_selection_to_marker(SPDesktop *desktop, bool apply) { + // sp_selection_tile has similar code if (desktop == NULL) { return; } @@ -2826,25 +2827,28 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) return; } + // FIXME: Inverted Y coodinate + Geom::Point doc_height( 0, doc->getHeight().value("px")); + // calculate the transform to be applied to objects to move them to 0,0 - Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - *c; + Geom::Point corner( r->min()[Geom::X], r->max()[Geom::Y] ); // FIXME: Inverted Y coodinate + Geom::Point move_p = doc_height - corner; move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); + Geom::Point center( *c - corner ); // As defined by rotation center + center[Geom::Y] = -center[Geom::Y]; + GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); + items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting SPObject *parent = SP_OBJECT(items->data)->parent; Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine()); - // remember the position of the first item - gint pos = SP_OBJECT(items->data)->getRepr()->position(); - (void)pos; // TODO check why this was remembered - - // create a list of duplicates + // Create a list of duplicates, to be pasted inside marker element. GSList *repr_copies = NULL; for (GSList *i = items; i != NULL; i = i->next) { Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); @@ -2854,7 +2858,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { - // delete objects so that their clones don't get alerted; this object will be restored shortly + // Delete objects so that their clones don't get alerted; + // the objects will be restored inside the marker element. for (GSList *i = items; i != NULL; i = i->next) { SPObject *item = reinterpret_cast<SPObject*>(i->data); item->deleteObject(false); @@ -2868,12 +2873,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - gchar const *mark_id = generate_marker(repr_copies, bbox, doc, - ( Geom::Affine(Geom::Translate(desktop->dt2doc( - Geom::Point(r->min()[Geom::X], - r->max()[Geom::Y])))) - * parent_transform.inverse() ), - parent_transform * move); + gchar const *mark_id = generate_marker(repr_copies, bbox, doc, center, parent_transform * move); (void)mark_id; // restore compensation setting @@ -3099,6 +3099,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) void sp_selection_tile(SPDesktop *desktop, bool apply) { + // sp_selection_to_marker has similar code if (desktop == NULL) { return; } |
