diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-01-11 19:01:50 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-01-11 19:01:50 +0000 |
| commit | 0e82b86bbfd6d5656431edbf20fa8b6f79515a04 (patch) | |
| tree | e9c728ab9079678cf526dc228800767a2f16c5f6 /src/sp-rect.cpp | |
| parent | Check for perspective in document defs (to avoid hanging/crashes after vacuum... (diff) | |
| download | inkscape-0e82b86bbfd6d5656431edbf20fa8b6f79515a04.tar.gz inkscape-0e82b86bbfd6d5656431edbf20fa8b6f79515a04.zip | |
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)
Diffstat (limited to 'src/sp-rect.cpp')
| -rw-r--r-- | src/sp-rect.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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 <glibmm/i18n.h> #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<std::pair<Geom::Point, Geom::Point> > 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++ |
