From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/viewbox.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index e1da23efa..1b50fe71c 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -15,7 +15,6 @@ #include <2geom/transforms.h> #include "viewbox.h" -#include "attributes.h" #include "enums.h" #include "sp-item.h" -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/viewbox.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 1b50fe71c..e1da23efa 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -15,6 +15,7 @@ #include <2geom/transforms.h> #include "viewbox.h" +#include "attributes.h" #include "enums.h" #include "sp-item.h" -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/viewbox.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index e1da23efa..1b50fe71c 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -15,7 +15,6 @@ #include <2geom/transforms.h> #include "viewbox.h" -#include "attributes.h" #include "enums.h" #include "sp-item.h" -- cgit v1.2.3 From b1fd9e5520ba0578f3b1dbfa53a806bfdb74f3a3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 3 Oct 2016 00:48:49 +0200 Subject: Doc rotate start (bzr r15142.1.1) --- src/viewbox.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 12 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 1b50fe71c..e40e477ef 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -17,6 +17,12 @@ #include "viewbox.h" #include "enums.h" #include "sp-item.h" +#include "display/sp-canvas-group.h" +#include "display/canvas-bpath.h" +#include "display/curve.h" +#include "inkscape.h" +#include "desktop.h" + SPViewBox::SPViewBox() : viewBox_set(false) @@ -25,6 +31,8 @@ SPViewBox::SPViewBox() , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec , aspect_clip(SP_ASPECT_MEET) , c2p(Geom::identity()) + , rotation(Geom::identity()) + , angle(0) { } @@ -159,6 +167,14 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { } } +double SPViewBox::get_rotation() { + return this->angle; +} + +void SPViewBox::set_rotation(double angle_val) { + this->angle = angle_val; +} + // Apply scaling from viewbox void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { @@ -224,18 +240,60 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { } /* Viewbox transform from scale and position */ - Geom::Affine q; - q[0] = scale_x; - q[1] = 0.0; - q[2] = 0.0; - q[3] = scale_y; - q[4] = x - scale_x * this->viewBox.left(); - q[5] = y - scale_y * this->viewBox.top(); - - // std::cout << " q\n" << q << std::endl; - - /* Append viewbox transformation */ - this->c2p = q * this->c2p; + Geom::Affine vbt = Geom::identity(); + vbt[0] = scale_x; + vbt[1] = 0.0; + vbt[2] = 0.0; + vbt[3] = scale_y; + vbt[4] = x - scale_x * this->viewBox.left(); + vbt[5] = y - scale_y * this->viewBox.top(); + // std::cout << " q\n" << q << std::endl + /* Append viewbox and turn transformation */ + if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 + Geom::Point r0 = this->viewBox.min(); + Geom::Point r1 = this->viewBox.max(); + Geom::Point p = (r0 + r1) / 2; + SPDesktop * desktop = SP_ACTIVE_DESKTOP; + SPCanvasItem *vw_rot = NULL; + if (desktop) { + if (this->page_border_rotated) { + desktop->remove_temporary_canvasitem(this->page_border_rotated); + this->page_border_rotated = NULL; + } + SPCurve *c = new SPCurve(); + c->moveto(this->viewBox.min()); + c->lineto(Geom::Point(this->viewBox.max()[Geom::X],this->viewBox.min()[Geom::Y])); + c->lineto(Geom::Point(this->viewBox.max()[Geom::X],this->viewBox.max()[Geom::Y])); + c->lineto(Geom::Point(this->viewBox.min()[Geom::X],this->viewBox.max()[Geom::Y])); + c->closepath(); + vw_rot = sp_canvas_bpath_new(desktop->getTempGroup(), c, true); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(vw_rot), 0xFF00009A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(vw_rot), 0, SP_WIND_RULE_NONZERO); + this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); + Geom::PathVector const box = c->get_pathvector(); + Geom::OptRect bbox = box.boundsFast(); + if (bbox){ + r0 = (*bbox).min(); + r1 = (*bbox).max(); + p = (r0 + r1) / 2; + } + Geom::Affine rot = Geom::identity(); + rot *= Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(-angle)) * Geom::Translate(p); + sp_canvas_item_affine_absolute(vw_rot, rot * vbt); + this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); + } + rotation = Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(p); + this->c2p = rotation * vbt * this->c2p; + } else { + SPDesktop * desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (this->page_border_rotated) { + desktop->remove_temporary_canvasitem(this->page_border_rotated); + this->page_border_rotated = NULL; + } + } + this->c2p = vbt * this->c2p; + } } SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { -- cgit v1.2.3 From f5e77f7f48954ec3bed892fa6763b0ed099a044e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Oct 2016 16:48:24 +0200 Subject: add rotate from current desktop center (bzr r15142.1.3) --- src/viewbox.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index e40e477ef..ba316e2c2 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -23,6 +23,8 @@ #include "inkscape.h" #include "desktop.h" +#include "display/sodipodi-ctrl.h" +#include "ui/dialog/knot-properties.h" SPViewBox::SPViewBox() : viewBox_set(false) @@ -33,6 +35,8 @@ SPViewBox::SPViewBox() , c2p(Geom::identity()) , rotation(Geom::identity()) , angle(0) + , previous_angle(0) + , rotated(false) { } @@ -172,6 +176,8 @@ double SPViewBox::get_rotation() { } void SPViewBox::set_rotation(double angle_val) { + this->previous_angle = this->angle; + this->rotated = true; this->angle = angle_val; } @@ -255,6 +261,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { Geom::Point p = (r0 + r1) / 2; SPDesktop * desktop = SP_ACTIVE_DESKTOP; SPCanvasItem *vw_rot = NULL; + Geom::Point rot_center = Geom::Point(); if (desktop) { if (this->page_border_rotated) { desktop->remove_temporary_canvasitem(this->page_border_rotated); @@ -273,17 +280,25 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { Geom::PathVector const box = c->get_pathvector(); Geom::OptRect bbox = box.boundsFast(); if (bbox){ - r0 = (*bbox).min(); - r1 = (*bbox).max(); - p = (r0 + r1) / 2; + p = (*bbox).midpoint(); } + Geom::Rect view = desktop->get_display_area(); + rot_center = desktop->doc2dt(view.midpoint()); Geom::Affine rot = Geom::identity(); - rot *= Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(-angle)) * Geom::Translate(p); + rot *= Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(-angle)) * Geom::Translate(p); sp_canvas_item_affine_absolute(vw_rot, rot * vbt); this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); + Geom::Affine rotcenter = Geom::identity(); + rotcenter *= Geom::Translate(p * vbt).inverse() * Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)) * Geom::Translate(p * vbt); + rot_center = rot_center * rotcenter; } rotation = Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(p); this->c2p = rotation * vbt * this->c2p; + rot_center = desktop->dt2doc(rot_center); + if (desktop && this->rotated) { + desktop->zoom_relative(rot_center[Geom::X], rot_center[Geom::Y], 1.0); + this->rotated = false; + } } else { SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (desktop) { @@ -296,6 +311,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { } } + SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { /* Create copy of item context */ -- cgit v1.2.3 From 45b6180786db318dd135ea918732ce8051470e75 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Oct 2016 20:29:16 +0200 Subject: Keep selection (bzr r15142.1.5) --- src/viewbox.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index ba316e2c2..dbbd462c8 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -17,15 +17,13 @@ #include "viewbox.h" #include "enums.h" #include "sp-item.h" +#include "sp-root.h" #include "display/sp-canvas-group.h" #include "display/canvas-bpath.h" #include "display/curve.h" #include "inkscape.h" #include "desktop.h" -#include "display/sodipodi-ctrl.h" -#include "ui/dialog/knot-properties.h" - SPViewBox::SPViewBox() : viewBox_set(false) , viewBox() @@ -177,8 +175,8 @@ double SPViewBox::get_rotation() { void SPViewBox::set_rotation(double angle_val) { this->previous_angle = this->angle; - this->rotated = true; this->angle = angle_val; + this->rotated = true; } // Apply scaling from viewbox @@ -244,7 +242,6 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { break; } } - /* Viewbox transform from scale and position */ Geom::Affine vbt = Geom::identity(); vbt[0] = scale_x; @@ -253,7 +250,6 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { vbt[3] = scale_y; vbt[4] = x - scale_x * this->viewBox.left(); vbt[5] = y - scale_y * this->viewBox.top(); - // std::cout << " q\n" << q << std::endl /* Append viewbox and turn transformation */ if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 Geom::Point r0 = this->viewBox.min(); -- cgit v1.2.3 From 7f008cb2f657420416aef950a1576e1162c89fa4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 9 Oct 2016 03:19:42 +0200 Subject: Added widget to to rotate (bzr r15142.1.7) --- src/viewbox.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index dbbd462c8..d4e64a4da 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -251,13 +251,12 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { vbt[4] = x - scale_x * this->viewBox.left(); vbt[5] = y - scale_y * this->viewBox.top(); /* Append viewbox and turn transformation */ + Geom::Point rot_center = Geom::Point(); + Geom::Point p = this->viewBox.midpoint(); + Geom::Affine rotcenter = Geom::identity(); + SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 - Geom::Point r0 = this->viewBox.min(); - Geom::Point r1 = this->viewBox.max(); - Geom::Point p = (r0 + r1) / 2; - SPDesktop * desktop = SP_ACTIVE_DESKTOP; SPCanvasItem *vw_rot = NULL; - Geom::Point rot_center = Geom::Point(); if (desktop) { if (this->page_border_rotated) { desktop->remove_temporary_canvasitem(this->page_border_rotated); @@ -284,20 +283,15 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { rot *= Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(-angle)) * Geom::Translate(p); sp_canvas_item_affine_absolute(vw_rot, rot * vbt); this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); - Geom::Affine rotcenter = Geom::identity(); rotcenter *= Geom::Translate(p * vbt).inverse() * Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)) * Geom::Translate(p * vbt); - rot_center = rot_center * rotcenter; } rotation = Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(p); this->c2p = rotation * vbt * this->c2p; - rot_center = desktop->dt2doc(rot_center); - if (desktop && this->rotated) { - desktop->zoom_relative(rot_center[Geom::X], rot_center[Geom::Y], 1.0); - this->rotated = false; - } } else { - SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (desktop) { + Geom::Rect view = desktop->get_display_area(); + rot_center = desktop->doc2dt(view.midpoint()); + rotcenter *= Geom::Translate(p * vbt).inverse() * Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)) * Geom::Translate(p * vbt); if (this->page_border_rotated) { desktop->remove_temporary_canvasitem(this->page_border_rotated); this->page_border_rotated = NULL; @@ -305,6 +299,11 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { } this->c2p = vbt * this->c2p; } + if (desktop && this->rotated) { + rot_center = desktop->dt2doc(rot_center * rotcenter); + desktop->zoom_relative(rot_center[Geom::X], rot_center[Geom::Y], 1.0); + this->rotated = false; + } } -- cgit v1.2.3 From c7f5c676fa15f59f5f78c934263539981a26bbd2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 10 Oct 2016 14:08:35 +0200 Subject: Fix some canvas problems and refactorization (bzr r15142.1.8) --- src/viewbox.cpp | 63 ++++++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index d4e64a4da..15b5b19c4 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -17,10 +17,6 @@ #include "viewbox.h" #include "enums.h" #include "sp-item.h" -#include "sp-root.h" -#include "display/sp-canvas-group.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" #include "inkscape.h" #include "desktop.h" @@ -31,6 +27,7 @@ SPViewBox::SPViewBox() , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec , aspect_clip(SP_ASPECT_MEET) , c2p(Geom::identity()) + , vbt(Geom::identity()) , rotation(Geom::identity()) , angle(0) , previous_angle(0) @@ -243,7 +240,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { } } /* Viewbox transform from scale and position */ - Geom::Affine vbt = Geom::identity(); + vbt = Geom::identity(); vbt[0] = scale_x; vbt[1] = 0.0; vbt[2] = 0.0; @@ -251,57 +248,27 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { vbt[4] = x - scale_x * this->viewBox.left(); vbt[5] = y - scale_y * this->viewBox.top(); /* Append viewbox and turn transformation */ - Geom::Point rot_center = Geom::Point(); - Geom::Point p = this->viewBox.midpoint(); - Geom::Affine rotcenter = Geom::identity(); + Geom::Point page_center = this->viewBox.midpoint(); + Geom::Affine center_rotation = Geom::identity(); SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 - SPCanvasItem *vw_rot = NULL; if (desktop) { - if (this->page_border_rotated) { - desktop->remove_temporary_canvasitem(this->page_border_rotated); - this->page_border_rotated = NULL; - } - SPCurve *c = new SPCurve(); - c->moveto(this->viewBox.min()); - c->lineto(Geom::Point(this->viewBox.max()[Geom::X],this->viewBox.min()[Geom::Y])); - c->lineto(Geom::Point(this->viewBox.max()[Geom::X],this->viewBox.max()[Geom::Y])); - c->lineto(Geom::Point(this->viewBox.min()[Geom::X],this->viewBox.max()[Geom::Y])); - c->closepath(); - vw_rot = sp_canvas_bpath_new(desktop->getTempGroup(), c, true); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(vw_rot), 0xFF00009A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(vw_rot), 0, SP_WIND_RULE_NONZERO); - this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); - Geom::PathVector const box = c->get_pathvector(); - Geom::OptRect bbox = box.boundsFast(); - if (bbox){ - p = (*bbox).midpoint(); - } - Geom::Rect view = desktop->get_display_area(); - rot_center = desktop->doc2dt(view.midpoint()); - Geom::Affine rot = Geom::identity(); - rot *= Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(-angle)) * Geom::Translate(p); - sp_canvas_item_affine_absolute(vw_rot, rot * vbt); - this->page_border_rotated = desktop->add_temporary_canvasitem(vw_rot, 0); - rotcenter *= Geom::Translate(p * vbt).inverse() * Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)) * Geom::Translate(p * vbt); + rotation = Geom::Translate(page_center).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(page_center); + this->c2p = rotation * vbt * this->c2p; + } else { + this->c2p = vbt * this->c2p; } - rotation = Geom::Translate(p).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(p); - this->c2p = rotation * vbt * this->c2p; } else { - if (desktop) { - Geom::Rect view = desktop->get_display_area(); - rot_center = desktop->doc2dt(view.midpoint()); - rotcenter *= Geom::Translate(p * vbt).inverse() * Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)) * Geom::Translate(p * vbt); - if (this->page_border_rotated) { - desktop->remove_temporary_canvasitem(this->page_border_rotated); - this->page_border_rotated = NULL; - } - } this->c2p = vbt * this->c2p; } if (desktop && this->rotated) { - rot_center = desktop->dt2doc(rot_center * rotcenter); - desktop->zoom_relative(rot_center[Geom::X], rot_center[Geom::Y], 1.0); + Geom::Rect view = desktop->get_display_area(); + Geom::Point view_center = desktop->doc2dt(view.midpoint()); + center_rotation *= Geom::Translate(page_center * vbt).inverse(); + center_rotation *= Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)); + center_rotation *= Geom::Translate(page_center * vbt); + view_center = desktop->dt2doc(view_center * center_rotation); + desktop->zoom_relative(view_center[Geom::X], view_center[Geom::Y], 1.0); this->rotated = false; } } -- cgit v1.2.3 From c57802d04d26ecf8618ffe8f1f9a90c79d36ed92 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 15 Oct 2016 01:48:35 +0200 Subject: Change from slider to spin (bzr r15142.1.13) --- src/viewbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 15b5b19c4..ebfc04d8a 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -249,7 +249,6 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { vbt[5] = y - scale_y * this->viewBox.top(); /* Append viewbox and turn transformation */ Geom::Point page_center = this->viewBox.midpoint(); - Geom::Affine center_rotation = Geom::identity(); SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 if (desktop) { @@ -264,6 +263,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { if (desktop && this->rotated) { Geom::Rect view = desktop->get_display_area(); Geom::Point view_center = desktop->doc2dt(view.midpoint()); + Geom::Affine center_rotation = Geom::identity(); center_rotation *= Geom::Translate(page_center * vbt).inverse(); center_rotation *= Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)); center_rotation *= Geom::Translate(page_center * vbt); -- cgit v1.2.3 From 014489163050d8abe9e5c4949fb80f3c21b1c17b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Mar 2017 15:22:22 +0100 Subject: Replace rectangle based zooming by affine based zooming. This allows a rotation to be included in the drawing to window mapping. General code cleanup. Added documentation. Any change to zooming behavior is probably a bug. (bzr r15592) --- src/viewbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index ebfc04d8a..1fa33117a 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -268,7 +268,7 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { center_rotation *= Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)); center_rotation *= Geom::Translate(page_center * vbt); view_center = desktop->dt2doc(view_center * center_rotation); - desktop->zoom_relative(view_center[Geom::X], view_center[Geom::Y], 1.0); + desktop->zoom_relative_center_point(view_center, 1.0); this->rotated = false; } } -- cgit v1.2.3 From f47466c701b2256b2ce232f6d311d2be47136eab Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 20 Mar 2017 21:12:31 +0100 Subject: Implement rotation via desktop to window affine. Remove rotation via viewbox. Still some work to do... (bzr r15603) --- src/viewbox.cpp | 62 ++++++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 49 deletions(-) (limited to 'src/viewbox.cpp') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 1fa33117a..1b50fe71c 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -17,8 +17,6 @@ #include "viewbox.h" #include "enums.h" #include "sp-item.h" -#include "inkscape.h" -#include "desktop.h" SPViewBox::SPViewBox() : viewBox_set(false) @@ -27,11 +25,6 @@ SPViewBox::SPViewBox() , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec , aspect_clip(SP_ASPECT_MEET) , c2p(Geom::identity()) - , vbt(Geom::identity()) - , rotation(Geom::identity()) - , angle(0) - , previous_angle(0) - , rotated(false) { } @@ -166,16 +159,6 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { } } -double SPViewBox::get_rotation() { - return this->angle; -} - -void SPViewBox::set_rotation(double angle_val) { - this->previous_angle = this->angle; - this->angle = angle_val; - this->rotated = true; -} - // Apply scaling from viewbox void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { @@ -239,41 +222,22 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in, double scale_none) { break; } } + /* Viewbox transform from scale and position */ - vbt = Geom::identity(); - vbt[0] = scale_x; - vbt[1] = 0.0; - vbt[2] = 0.0; - vbt[3] = scale_y; - vbt[4] = x - scale_x * this->viewBox.left(); - vbt[5] = y - scale_y * this->viewBox.top(); - /* Append viewbox and turn transformation */ - Geom::Point page_center = this->viewBox.midpoint(); - SPDesktop * desktop = SP_ACTIVE_DESKTOP; - if (this->angle > 0.0 || this->angle < 0.0 ) { //!0 - if (desktop) { - rotation = Geom::Translate(page_center).inverse() * Geom::Rotate(Geom::rad_from_deg(angle)) * Geom::Translate(page_center); - this->c2p = rotation * vbt * this->c2p; - } else { - this->c2p = vbt * this->c2p; - } - } else { - this->c2p = vbt * this->c2p; - } - if (desktop && this->rotated) { - Geom::Rect view = desktop->get_display_area(); - Geom::Point view_center = desktop->doc2dt(view.midpoint()); - Geom::Affine center_rotation = Geom::identity(); - center_rotation *= Geom::Translate(page_center * vbt).inverse(); - center_rotation *= Geom::Rotate(Geom::rad_from_deg(this->angle - this->previous_angle)); - center_rotation *= Geom::Translate(page_center * vbt); - view_center = desktop->dt2doc(view_center * center_rotation); - desktop->zoom_relative_center_point(view_center, 1.0); - this->rotated = false; - } + Geom::Affine q; + q[0] = scale_x; + q[1] = 0.0; + q[2] = 0.0; + q[3] = scale_y; + q[4] = x - scale_x * this->viewBox.left(); + q[5] = y - scale_y * this->viewBox.top(); + + // std::cout << " q\n" << q << std::endl; + + /* Append viewbox transformation */ + this->c2p = q * this->c2p; } - SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx, double scale_none) { /* Create copy of item context */ -- cgit v1.2.3