summaryrefslogtreecommitdiffstats
path: root/src/sp-guide.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2011-07-18 20:44:25 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2011-07-18 20:44:25 +0000
commit61ec015d8734244ecd6223e941ecc09eccdfcdaa (patch)
treef1327ce92272cf6dfa86c59f9bd8794002b1edf9 /src/sp-guide.cpp
parentfix hardcoded desktop2doc transform (diff)
downloadinkscape-61ec015d8734244ecd6223e941ecc09eccdfcdaa.tar.gz
inkscape-61ec015d8734244ecd6223e941ecc09eccdfcdaa.zip
refactor the guideline drawing. now it obeys desktop transforms a lot better.
(bzr r10471)
Diffstat (limited to 'src/sp-guide.cpp')
-rw-r--r--src/sp-guide.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index f71bc1762..71312b698 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -40,6 +40,7 @@
#include "desktop.h"
#include "sp-namedview.h"
#include <2geom/angle.h>
+#include <2geom/transforms.h>
#include "document.h"
using Inkscape::DocumentUndo;
@@ -321,7 +322,14 @@ sp_guide_delete_all_guides(SPDesktop *dt) {
void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler)
{
- SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line);
+ // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation)
+ // therefore, we have to correct for this first...
+ SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way...
+ Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1);
+ Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation();
+ Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt();
+
+ SPCanvasItem *item = sp_guideline_new(group, label, point_on_line_dt, normal_dt);
sp_guideline_set_color(SP_GUIDELINE(item), color);
g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this);
@@ -379,8 +387,14 @@ void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const
{
g_assert(SP_IS_GUIDE(&guide));
+ // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation)
+ // therefore, we have to correct for this first...
+ SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way...
+ Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1);
+ Geom::Point point_on_line_dt = point_on_line * correction * desktop->doc2dt();
+
for (GSList *l = guide.views; l != NULL; l = l->next) {
- sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line);
+ sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line_dt);
}
/* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit
@@ -410,8 +424,14 @@ void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool
{
g_assert(SP_IS_GUIDE(&guide));
+ // historically, normal_to_line and point_on_line are stored in desktop coordinates (without desktop rotation)
+ // therefore, we have to correct for this first...
+ SPDesktop const *desktop = inkscape_active_desktop(); /// @fixme Obtain SPDesktop in better way...
+ Geom::Affine correction = Geom::Translate(0, -desktop->namedview->document->getHeight()) * Geom::Scale(1, -1);
+ Geom::Point normal_dt = normal_to_line * correction.withoutTranslation() * desktop->doc2dt().withoutTranslation();
+
for (GSList *l = guide.views; l != NULL; l = l->next) {
- sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line);
+ sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_dt);
}
/* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit