Mercurial > hg > orthanc-stone
annotate Framework/Radiography/RadiographyWindowingTracker.cpp @ 739:be9c1530d40a
deprecating enum SliceImageQuality
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 22 May 2019 09:13:04 +0200 |
parents | 4f2416d519b4 |
children | 08cdcadfab14 |
rev | line source |
---|---|
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "RadiographyWindowingTracker.h" |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include <Core/OrthancException.h> |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 namespace OrthancStone |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 class RadiographyWindowingTracker::UndoRedoCommand : public UndoRedoStack::ICommand |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 private: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 RadiographyScene& scene_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 float sourceCenter_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 float sourceWidth_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 float targetCenter_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 float targetWidth_; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 public: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 UndoRedoCommand(const RadiographyWindowingTracker& tracker) : |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 scene_(tracker.scene_), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 sourceCenter_(tracker.sourceCenter_), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 sourceWidth_(tracker.sourceWidth_) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 scene_.GetWindowingWithDefault(targetCenter_, targetWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 virtual void Undo() const |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 scene_.SetWindowing(sourceCenter_, sourceWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 virtual void Redo() const |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 scene_.SetWindowing(targetCenter_, targetWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 }; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 void RadiographyWindowingTracker::ComputeAxisEffect(int& deltaCenter, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 int& deltaWidth, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 int delta, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 Action actionNegative, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 Action actionPositive) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 if (delta < 0) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 switch (actionNegative) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 case Action_IncreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 deltaWidth = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 case Action_DecreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 deltaWidth = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 case Action_IncreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 deltaCenter = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 case Action_DecreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 deltaCenter = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 default: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 else if (delta > 0) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 switch (actionPositive) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 case Action_IncreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 deltaWidth = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 case Action_DecreaseWidth: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 deltaWidth = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 case Action_IncreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 deltaCenter = delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 case Action_DecreaseCenter: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 deltaCenter = -delta; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 break; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 default: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 RadiographyWindowingTracker::RadiographyWindowingTracker(UndoRedoStack& undoRedoStack, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 RadiographyScene& scene, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 int x, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 int y, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 Action leftAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 Action rightAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 Action upAction, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 Action downAction) : |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 undoRedoStack_(undoRedoStack), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 scene_(scene), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 clickX_(x), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 clickY_(y), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 leftAction_(leftAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 rightAction_(rightAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 upAction_(upAction), |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 downAction_(downAction) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 scene_.GetWindowingWithDefault(sourceCenter_, sourceWidth_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 float minValue, maxValue; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 scene.GetRange(minValue, maxValue); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 assert(minValue <= maxValue); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 float delta = (maxValue - minValue); |
455
e3a6e3bf5c7c
changed the windowing tracker sensitivity. It was not usable with 16bits full range
Alain Mazy <alain@mazy.be>
parents:
439
diff
changeset
|
141 strength_ = delta / 1000.0f; // 1px move will change the ww/wc by 0.1% |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 if (strength_ < 1) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 strength_ = 1; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 void RadiographyWindowingTracker::Render(CairoContext& context, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 double zoom) |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 void RadiographyWindowingTracker::MouseUp() |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 void RadiographyWindowingTracker::MouseMove(int displayX, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 int displayY, |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 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:
455
diff
changeset
|
166 double sceneY, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
457
diff
changeset
|
167 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
|
168 const std::vector<Deprecated::Touch>& sceneTouches) |
415
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 { |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 // This follows the behavior of the Osimis Web viewer: |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 // https://bitbucket.org/osimis/osimis-webviewer-plugin/src/master/frontend/src/app/viewport/image-plugins/windowing-viewport-tool.class.js |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 static const float SCALE = 1.0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 int deltaCenter = 0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 int deltaWidth = 0; |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 ComputeAxisEffect(deltaCenter, deltaWidth, displayX - clickX_, leftAction_, rightAction_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 ComputeAxisEffect(deltaCenter, deltaWidth, displayY - clickY_, upAction_, downAction_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 float newCenter = sourceCenter_ + (deltaCenter / SCALE * strength_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 float newWidth = sourceWidth_ + (deltaWidth / SCALE * strength_); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 scene_.SetWindowing(newCenter, newWidth); |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
c0589c3173fd
finished reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |