Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/MagnifyingGlassTracker.cpp @ 1993:317a53d4fdc6
added magnifying glass
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 31 Oct 2022 22:19:57 +0100 |
parents | |
children | 2f242d231a22 |
comparison
equal
deleted
inserted
replaced
1992:237e0eb40f38 | 1993:317a53d4fdc6 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "MagnifyingGlassTracker.h" | |
25 | |
26 #include "../Scene2DViewport/ViewportController.h" | |
27 #include "../Viewport/ViewportLocker.h" | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 void MagnifyingGlassTracker::Update(ViewportLocker& locker, | |
32 const PointerEvent& event) | |
33 { | |
34 ScenePoint2D p = event.GetMainPosition().Apply(originalCanvasToScene_); | |
35 | |
36 locker.GetController().SetSceneToCanvasTransform( | |
37 AffineTransform2D::Combine( | |
38 originalSceneToCanvas_, | |
39 AffineTransform2D::CreateOffset(p.GetX(), p.GetY()), | |
40 AffineTransform2D::CreateScaling(5, 5), | |
41 AffineTransform2D::CreateOffset(-pivot_.GetX(), -pivot_.GetY()))); | |
42 | |
43 locker.Invalidate(); | |
44 } | |
45 | |
46 | |
47 MagnifyingGlassTracker::MagnifyingGlassTracker(boost::weak_ptr<IViewport> viewport, | |
48 const PointerEvent& event) : | |
49 viewport_(viewport) | |
50 { | |
51 ViewportLocker locker(viewport_); | |
52 | |
53 if (locker.IsValid()) | |
54 { | |
55 originalSceneToCanvas_ = locker.GetController().GetSceneToCanvasTransform(); | |
56 originalCanvasToScene_ = locker.GetController().GetCanvasToSceneTransform(); | |
57 pivot_ = event.GetMainPosition().Apply(locker.GetController().GetCanvasToSceneTransform()); | |
58 | |
59 Update(locker, event); | |
60 } | |
61 } | |
62 | |
63 | |
64 void MagnifyingGlassTracker::PointerUp(const PointerEvent& event, | |
65 const Scene2D& scene) | |
66 { | |
67 Cancel(scene); | |
68 OneGesturePointerTracker::PointerUp(event, scene); | |
69 } | |
70 | |
71 | |
72 void MagnifyingGlassTracker::PointerMove(const PointerEvent& event, | |
73 const Scene2D& scene) | |
74 { | |
75 ViewportLocker locker(viewport_); | |
76 | |
77 if (locker.IsValid()) | |
78 { | |
79 Update(locker, event); | |
80 } | |
81 } | |
82 | |
83 | |
84 void MagnifyingGlassTracker::Cancel(const Scene2D& scene) | |
85 { | |
86 ViewportLocker locker(viewport_); | |
87 | |
88 if (locker.IsValid()) | |
89 { | |
90 locker.GetController().SetSceneToCanvasTransform(originalSceneToCanvas_); | |
91 locker.Invalidate(); | |
92 } | |
93 } | |
94 } |