annotate Framework/Deprecated/Radiography/RadiographyLayerMoveTracker.cpp @ 1430:5128b448a6ee

yet another try to fix OS X
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 May 2020 18:03:20 +0200
parents c5403d52078c
children 30deba7bc8e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "RadiographyLayerMoveTracker.h"
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "RadiographySceneCommand.h"
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include <Core/OrthancException.h>
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancStone
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 class RadiographyLayerMoveTracker::UndoRedoCommand : public RadiographySceneCommand
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 private:
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 double sourceX_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 double sourceY_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 double targetX_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 double targetY_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 protected:
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 virtual void UndoInternal(RadiographyLayer& layer) const
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 layer.SetPan(sourceX_, sourceY_);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 virtual void RedoInternal(RadiographyLayer& layer) const
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 layer.SetPan(targetX_, targetY_);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 UndoRedoCommand(const RadiographyLayerMoveTracker& tracker) :
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 RadiographySceneCommand(tracker.accessor_),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 sourceX_(tracker.panX_),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 sourceY_(tracker.panY_),
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 414
diff changeset
54 targetX_(tracker.accessor_.GetLayer().GetGeometry().GetPanX()),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 414
diff changeset
55 targetY_(tracker.accessor_.GetLayer().GetGeometry().GetPanY())
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 };
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 RadiographyLayerMoveTracker::RadiographyLayerMoveTracker(UndoRedoStack& undoRedoStack,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 RadiographyScene& scene,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 size_t layer,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 double x,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 double y,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 bool oneAxis) :
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 undoRedoStack_(undoRedoStack),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 accessor_(scene, layer),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 clickX_(x),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 clickY_(y),
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 oneAxis_(oneAxis)
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 if (accessor_.IsValid())
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 414
diff changeset
75 panX_ = accessor_.GetLayer().GetGeometry().GetPanX();
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 414
diff changeset
76 panY_ = accessor_.GetLayer().GetGeometry().GetPanY();
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 void RadiographyLayerMoveTracker::Render(CairoContext& context,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 double zoom)
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 void RadiographyLayerMoveTracker::MouseUp()
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 if (accessor_.IsValid())
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 undoRedoStack_.Add(new UndoRedoCommand(*this));
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 void RadiographyLayerMoveTracker::MouseMove(int displayX,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 int displayY,
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 double sceneX,
457
3b4df9925db6 added support for 'touch' in mouse trackers. This is still a bit hacky and we need to refactor it to make it clean. Thanks to that, Pan and zoom are available together with 2 touches
Alain Mazy <alain@mazy.be>
parents: 440
diff changeset
100 double sceneY,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
101 const std::vector<Deprecated::Touch>& displayTouches,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 457
diff changeset
102 const std::vector<Deprecated::Touch>& sceneTouches)
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 if (accessor_.IsValid())
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 double dx = sceneX - clickX_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 double dy = sceneY - clickY_;
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 if (oneAxis_)
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 if (fabs(dx) > fabs(dy))
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 accessor_.GetLayer().SetPan(dx + panX_, panY_);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 else
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 accessor_.GetLayer().SetPan(panX_, dy + panY_);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 else
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 accessor_.GetLayer().SetPan(dx + panX_, dy + panY_);
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }