From 0e82b86bbfd6d5656431edbf20fa8b6f79515a04 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Fri, 11 Jan 2008 19:01:50 +0000 Subject: Add possibility to convert objects (only rectangles and 3D boxes currently) to guidelines. Also see corresponding post on the mailing list; in particular, feel free to revert it if this is inappropriate during Frost phase. (bzr r4462) --- src/sp-rect.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/sp-rect.cpp') diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index d9caebd5a..e8e04cc51 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -28,6 +28,7 @@ #include "sp-rect.h" #include #include "xml/repr.h" +#include "sp-guide.h" #define noRECT_VERBOSE @@ -578,6 +579,32 @@ static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p) *p = NR::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d; } +void +sp_rect_convert_to_guides(SPRect *rect, bool write_undo) { + SPDocument *doc = SP_OBJECT_DOCUMENT(rect); + std::list > pts; + + NR::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(rect))); + + NR::Point A1(NR::Point(rect->x.computed, rect->y.computed) * i2d); + NR::Point A2(NR::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); + NR::Point A3(NR::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed) * i2d); + NR::Point A4(NR::Point(rect->x.computed + rect->width.computed, rect->y.computed) * i2d); + + pts.push_back(std::make_pair(A1.to_2geom(), A2.to_2geom())); + pts.push_back(std::make_pair(A2.to_2geom(), A3.to_2geom())); + pts.push_back(std::make_pair(A3.to_2geom(), A4.to_2geom())); + pts.push_back(std::make_pair(A4.to_2geom(), A1.to_2geom())); + + sp_guide_pt_pairs_to_guides(doc, pts); + + SP_OBJECT(rect)->deleteObject(true); + + if (write_undo) { + sp_document_done(doc, SP_VERB_CONTEXT_RECT, _("Convert to guides")); + } +} + /* Local Variables: mode:c++ -- cgit v1.2.3