Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/RotateSceneTracker.cpp @ 700:059e1fd05fd6 refactor-viewport-controller
Introduced the ViewportController that sits between the application and the
Scene2D to handle the trackers and measuring tools. This is a work in progress.
The Scene2D is no longer an observable. Message sending is managed by the
ViewportController.
Move some refs to shared and weak to prevent lifetime issues.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Sun, 19 May 2019 16:26:17 +0200 |
parents | 7efa2543699d |
children | c0fcb2757b0a |
comparison
equal
deleted
inserted
replaced
699:5c551f078c18 | 700:059e1fd05fd6 |
---|---|
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 | |
22 #include "RotateSceneTracker.h" | 21 #include "RotateSceneTracker.h" |
22 #include <Framework/Scene2DViewport/ViewportController.h> | |
23 | 23 |
24 namespace OrthancStone | 24 namespace OrthancStone |
25 { | 25 { |
26 RotateSceneTracker::RotateSceneTracker(Scene2D& scene, | 26 RotateSceneTracker::RotateSceneTracker(ViewportControllerWPtr controllerW, |
27 const PointerEvent& event) : | 27 const PointerEvent& event) |
28 scene_(scene), | 28 : OneGesturePointerTracker(controllerW) |
29 click_(event.GetMainPosition()), | 29 , click_(event.GetMainPosition()) |
30 aligner_(scene, click_), | 30 , aligner_(controllerW, click_) |
31 isFirst_(true), | 31 , isFirst_(true) |
32 originalSceneToCanvas_(scene.GetSceneToCanvasTransform()) | 32 , originalSceneToCanvas_(GetController()->GetSceneToCanvasTransform()) |
33 { | 33 { |
34 } | 34 } |
35 | 35 |
36 | 36 void RotateSceneTracker::PointerMove(const PointerEvent& event) |
37 void RotateSceneTracker::Update(const PointerEvent& event) | |
38 { | 37 { |
39 ScenePoint2D p = event.GetMainPosition(); | 38 ScenePoint2D p = event.GetMainPosition(); |
40 double dx = p.GetX() - click_.GetX(); | 39 double dx = p.GetX() - click_.GetX(); |
41 double dy = p.GetY() - click_.GetY(); | 40 double dy = p.GetY() - click_.GetY(); |
42 | 41 |
49 { | 48 { |
50 referenceAngle_ = a; | 49 referenceAngle_ = a; |
51 isFirst_ = false; | 50 isFirst_ = false; |
52 } | 51 } |
53 | 52 |
54 scene_.SetSceneToCanvasTransform( | 53 GetController()->SetSceneToCanvasTransform( |
55 AffineTransform2D::Combine( | 54 AffineTransform2D::Combine( |
56 AffineTransform2D::CreateRotation(a - referenceAngle_), | 55 AffineTransform2D::CreateRotation(a - referenceAngle_), |
57 originalSceneToCanvas_)); | 56 originalSceneToCanvas_)); |
58 | 57 |
59 aligner_.Apply(); | 58 aligner_.Apply(); |
60 } | 59 } |
61 } | 60 } |
61 | |
62 void RotateSceneTracker::Cancel() | |
63 { | |
64 GetController()->SetSceneToCanvasTransform(originalSceneToCanvas_); | |
65 } | |
66 | |
62 } | 67 } |