Mercurial > hg > orthanc-stone
annotate Applications/Samples/SingleFrameEditorApplication.h @ 413:18b707fb8620
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 12 Nov 2018 17:17:25 +0100 |
parents | 6decc0ba9da5 |
children | f7616c010056 |
rev | line source |
---|---|
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1 /** |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
6 * |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
11 * |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
16 * |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
19 **/ |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
20 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
21 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
22 #pragma once |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
23 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
24 #include "SampleApplicationBase.h" |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
25 |
408 | 26 #include "../../Framework/Radiography/RadiographyScene.h" |
413 | 27 #include "../../Framework/Radiography/RadiographyWidget.h" |
408 | 28 |
29 #include "../../Framework/Toolbox/UndoRedoStack.h" | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
30 |
343 | 31 #include <Core/Images/FontRegistry.h> |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
32 #include <Core/Images/Image.h> |
339 | 33 #include <Core/Images/ImageProcessing.h> |
338 | 34 #include <Core/Images/PamReader.h> |
361
f559ac66ef55
first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
360
diff
changeset
|
35 #include <Core/Images/PamWriter.h> |
362
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
36 #include <Core/Images/PngWriter.h> |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
37 #include <Core/Logging.h> |
403 | 38 #include <Core/OrthancException.h> |
361
f559ac66ef55
first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
360
diff
changeset
|
39 #include <Core/Toolbox.h> |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
40 #include <Plugins/Samples/Common/DicomDatasetReader.h> |
338 | 41 #include <Plugins/Samples/Common/FullOrthancDataset.h> |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
42 |
407 | 43 |
44 // Export using PAM is faster than using PNG, but requires Orthanc | |
45 // core >= 1.4.3 | |
362
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
46 #define EXPORT_USING_PAM 1 |
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
47 |
340
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
48 |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
49 #include <boost/math/constants/constants.hpp> |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
50 #include <boost/math/special_functions/round.hpp> |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
51 |
340
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
52 |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
53 namespace OrthancStone |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
54 { |
413 | 55 class RadiographySceneCommand : public UndoRedoStack::ICommand |
336
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
56 { |
408 | 57 private: |
58 RadiographyScene& scene_; | |
59 size_t layer_; | |
350
c57e049ed079
drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
60 |
408 | 61 protected: |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
62 virtual void UndoInternal(RadiographyLayer& layer) const = 0; |
354 | 63 |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
64 virtual void RedoInternal(RadiographyLayer& layer) const = 0; |
338 | 65 |
66 public: | |
413 | 67 RadiographySceneCommand(RadiographyScene& scene, |
408 | 68 size_t layer) : |
407 | 69 scene_(scene), |
70 layer_(layer) | |
354 | 71 { |
72 } | |
73 | |
413 | 74 RadiographySceneCommand(const RadiographyScene::LayerAccessor& accessor) : |
407 | 75 scene_(accessor.GetScene()), |
76 layer_(accessor.GetIndex()) | |
354 | 77 { |
78 } | |
79 | |
80 virtual void Undo() const | |
81 { | |
408 | 82 RadiographyScene::LayerAccessor accessor(scene_, layer_); |
354 | 83 |
84 if (accessor.IsValid()) | |
85 { | |
407 | 86 UndoInternal(accessor.GetLayer()); |
354 | 87 } |
88 } | |
89 | |
90 virtual void Redo() const | |
91 { | |
408 | 92 RadiographyScene::LayerAccessor accessor(scene_, layer_); |
354 | 93 |
94 if (accessor.IsValid()) | |
95 { | |
407 | 96 RedoInternal(accessor.GetLayer()); |
354 | 97 } |
98 } | |
99 }; | |
100 | |
101 | |
408 | 102 class RadiographyLayerRotateTracker : public IWorldSceneMouseTracker |
354 | 103 { |
104 private: | |
407 | 105 UndoRedoStack& undoRedoStack_; |
408 | 106 RadiographyScene::LayerAccessor accessor_; |
407 | 107 double centerX_; |
108 double centerY_; | |
109 double originalAngle_; | |
110 double clickAngle_; | |
111 bool roundAngles_; | |
354 | 112 |
113 bool ComputeAngle(double& angle /* out */, | |
114 double sceneX, | |
115 double sceneY) const | |
116 { | |
117 Vector u; | |
118 LinearAlgebra::AssignVector(u, sceneX - centerX_, sceneY - centerY_); | |
119 | |
120 double nu = boost::numeric::ublas::norm_2(u); | |
121 | |
122 if (!LinearAlgebra::IsCloseToZero(nu)) | |
123 { | |
124 u /= nu; | |
125 angle = atan2(u[1], u[0]); | |
126 return true; | |
127 } | |
128 else | |
129 { | |
130 return false; | |
131 } | |
132 } | |
133 | |
134 | |
413 | 135 class UndoRedoCommand : public RadiographySceneCommand |
354 | 136 { |
137 private: | |
138 double sourceAngle_; | |
139 double targetAngle_; | |
140 | |
141 static int ToDegrees(double angle) | |
142 { | |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
143 return boost::math::iround(angle * 180.0 / boost::math::constants::pi<double>()); |
354 | 144 } |
145 | |
146 protected: | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
147 virtual void UndoInternal(RadiographyLayer& layer) const |
354 | 148 { |
149 LOG(INFO) << "Undo - Set angle to " << ToDegrees(sourceAngle_) << " degrees"; | |
407 | 150 layer.SetAngle(sourceAngle_); |
354 | 151 } |
152 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
153 virtual void RedoInternal(RadiographyLayer& layer) const |
354 | 154 { |
155 LOG(INFO) << "Redo - Set angle to " << ToDegrees(sourceAngle_) << " degrees"; | |
407 | 156 layer.SetAngle(targetAngle_); |
354 | 157 } |
158 | |
159 public: | |
408 | 160 UndoRedoCommand(const RadiographyLayerRotateTracker& tracker) : |
413 | 161 RadiographySceneCommand(tracker.accessor_), |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
162 sourceAngle_(tracker.originalAngle_), |
407 | 163 targetAngle_(tracker.accessor_.GetLayer().GetAngle()) |
354 | 164 { |
165 } | |
166 }; | |
167 | |
168 | |
169 public: | |
408 | 170 RadiographyLayerRotateTracker(UndoRedoStack& undoRedoStack, |
171 RadiographyScene& scene, | |
172 const ViewportGeometry& view, | |
173 size_t layer, | |
174 double x, | |
175 double y, | |
176 bool roundAngles) : | |
354 | 177 undoRedoStack_(undoRedoStack), |
407 | 178 accessor_(scene, layer), |
354 | 179 roundAngles_(roundAngles) |
180 { | |
181 if (accessor_.IsValid()) | |
182 { | |
407 | 183 accessor_.GetLayer().GetCenter(centerX_, centerY_); |
184 originalAngle_ = accessor_.GetLayer().GetAngle(); | |
354 | 185 |
186 double sceneX, sceneY; | |
187 view.MapDisplayToScene(sceneX, sceneY, x, y); | |
188 | |
189 if (!ComputeAngle(clickAngle_, x, y)) | |
190 { | |
191 accessor_.Invalidate(); | |
192 } | |
193 } | |
194 } | |
195 | |
196 virtual bool HasRender() const | |
197 { | |
198 return false; | |
199 } | |
200 | |
201 virtual void Render(CairoContext& context, | |
202 double zoom) | |
203 { | |
204 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
205 } | |
206 | |
207 virtual void MouseUp() | |
208 { | |
209 if (accessor_.IsValid()) | |
210 { | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
211 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
354 | 212 } |
213 } | |
214 | |
215 virtual void MouseMove(int displayX, | |
216 int displayY, | |
217 double sceneX, | |
218 double sceneY) | |
219 { | |
220 static const double ROUND_ANGLE = 15.0 / 180.0 * boost::math::constants::pi<double>(); | |
221 | |
222 double angle; | |
223 | |
224 if (accessor_.IsValid() && | |
225 ComputeAngle(angle, sceneX, sceneY)) | |
226 { | |
227 angle = angle - clickAngle_ + originalAngle_; | |
228 | |
229 if (roundAngles_) | |
230 { | |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
231 angle = boost::math::round<double>((angle / ROUND_ANGLE) * ROUND_ANGLE); |
354 | 232 } |
233 | |
407 | 234 accessor_.GetLayer().SetAngle(angle); |
354 | 235 } |
236 } | |
237 }; | |
238 | |
239 | |
408 | 240 class RadiographyLayerMoveTracker : public IWorldSceneMouseTracker |
354 | 241 { |
242 private: | |
408 | 243 UndoRedoStack& undoRedoStack_; |
244 RadiographyScene::LayerAccessor accessor_; | |
245 double clickX_; | |
246 double clickY_; | |
247 double panX_; | |
248 double panY_; | |
249 bool oneAxis_; | |
407 | 250 |
413 | 251 class UndoRedoCommand : public RadiographySceneCommand |
354 | 252 { |
253 private: | |
254 double sourceX_; | |
255 double sourceY_; | |
256 double targetX_; | |
257 double targetY_; | |
258 | |
259 protected: | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
260 virtual void UndoInternal(RadiographyLayer& layer) const |
354 | 261 { |
407 | 262 layer.SetPan(sourceX_, sourceY_); |
354 | 263 } |
264 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
265 virtual void RedoInternal(RadiographyLayer& layer) const |
354 | 266 { |
407 | 267 layer.SetPan(targetX_, targetY_); |
354 | 268 } |
269 | |
270 public: | |
408 | 271 UndoRedoCommand(const RadiographyLayerMoveTracker& tracker) : |
413 | 272 RadiographySceneCommand(tracker.accessor_), |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
273 sourceX_(tracker.panX_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
274 sourceY_(tracker.panY_), |
407 | 275 targetX_(tracker.accessor_.GetLayer().GetPanX()), |
276 targetY_(tracker.accessor_.GetLayer().GetPanY()) | |
354 | 277 { |
278 } | |
279 }; | |
280 | |
281 | |
282 public: | |
408 | 283 RadiographyLayerMoveTracker(UndoRedoStack& undoRedoStack, |
284 RadiographyScene& scene, | |
285 size_t layer, | |
286 double x, | |
287 double y, | |
288 bool oneAxis) : | |
354 | 289 undoRedoStack_(undoRedoStack), |
407 | 290 accessor_(scene, layer), |
354 | 291 clickX_(x), |
292 clickY_(y), | |
293 oneAxis_(oneAxis) | |
294 { | |
295 if (accessor_.IsValid()) | |
296 { | |
407 | 297 panX_ = accessor_.GetLayer().GetPanX(); |
298 panY_ = accessor_.GetLayer().GetPanY(); | |
354 | 299 } |
300 } | |
301 | |
302 virtual bool HasRender() const | |
303 { | |
304 return false; | |
305 } | |
306 | |
307 virtual void Render(CairoContext& context, | |
308 double zoom) | |
309 { | |
310 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
311 } | |
312 | |
313 virtual void MouseUp() | |
314 { | |
315 if (accessor_.IsValid()) | |
316 { | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
317 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
354 | 318 } |
319 } | |
320 | |
321 virtual void MouseMove(int displayX, | |
322 int displayY, | |
323 double sceneX, | |
324 double sceneY) | |
325 { | |
326 if (accessor_.IsValid()) | |
327 { | |
328 double dx = sceneX - clickX_; | |
329 double dy = sceneY - clickY_; | |
330 | |
331 if (oneAxis_) | |
332 { | |
333 if (fabs(dx) > fabs(dy)) | |
334 { | |
407 | 335 accessor_.GetLayer().SetPan(dx + panX_, panY_); |
354 | 336 } |
337 else | |
338 { | |
407 | 339 accessor_.GetLayer().SetPan(panX_, dy + panY_); |
354 | 340 } |
341 } | |
342 else | |
343 { | |
407 | 344 accessor_.GetLayer().SetPan(dx + panX_, dy + panY_); |
354 | 345 } |
346 } | |
347 } | |
348 }; | |
349 | |
350 | |
408 | 351 class RadiographyLayerCropTracker : public IWorldSceneMouseTracker |
354 | 352 { |
353 private: | |
408 | 354 UndoRedoStack& undoRedoStack_; |
355 RadiographyScene::LayerAccessor accessor_; | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
356 Corner corner_; |
408 | 357 unsigned int cropX_; |
358 unsigned int cropY_; | |
359 unsigned int cropWidth_; | |
360 unsigned int cropHeight_; | |
407 | 361 |
413 | 362 class UndoRedoCommand : public RadiographySceneCommand |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
363 { |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
364 private: |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
365 unsigned int sourceCropX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
366 unsigned int sourceCropY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
367 unsigned int sourceCropWidth_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
368 unsigned int sourceCropHeight_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
369 unsigned int targetCropX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
370 unsigned int targetCropY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
371 unsigned int targetCropWidth_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
372 unsigned int targetCropHeight_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
373 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
374 protected: |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
375 virtual void UndoInternal(RadiographyLayer& layer) const |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
376 { |
407 | 377 layer.SetCrop(sourceCropX_, sourceCropY_, sourceCropWidth_, sourceCropHeight_); |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
378 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
379 |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
380 virtual void RedoInternal(RadiographyLayer& layer) const |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
381 { |
407 | 382 layer.SetCrop(targetCropX_, targetCropY_, targetCropWidth_, targetCropHeight_); |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
383 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
384 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
385 public: |
408 | 386 UndoRedoCommand(const RadiographyLayerCropTracker& tracker) : |
413 | 387 RadiographySceneCommand(tracker.accessor_), |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
388 sourceCropX_(tracker.cropX_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
389 sourceCropY_(tracker.cropY_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
390 sourceCropWidth_(tracker.cropWidth_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
391 sourceCropHeight_(tracker.cropHeight_) |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
392 { |
407 | 393 tracker.accessor_.GetLayer().GetCrop(targetCropX_, targetCropY_, |
394 targetCropWidth_, targetCropHeight_); | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
395 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
396 }; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
397 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
398 |
354 | 399 public: |
408 | 400 RadiographyLayerCropTracker(UndoRedoStack& undoRedoStack, |
401 RadiographyScene& scene, | |
402 const ViewportGeometry& view, | |
403 size_t layer, | |
404 double x, | |
405 double y, | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
406 Corner corner) : |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
407 undoRedoStack_(undoRedoStack), |
407 | 408 accessor_(scene, layer), |
354 | 409 corner_(corner) |
410 { | |
411 if (accessor_.IsValid()) | |
412 { | |
407 | 413 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_); |
354 | 414 } |
415 } | |
416 | |
417 virtual bool HasRender() const | |
418 { | |
419 return false; | |
420 } | |
421 | |
422 virtual void Render(CairoContext& context, | |
423 double zoom) | |
424 { | |
425 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
426 } | |
427 | |
428 virtual void MouseUp() | |
429 { | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
430 if (accessor_.IsValid()) |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
431 { |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
432 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
433 } |
354 | 434 } |
435 | |
436 virtual void MouseMove(int displayX, | |
437 int displayY, | |
438 double sceneX, | |
439 double sceneY) | |
440 { | |
441 if (accessor_.IsValid()) | |
442 { | |
443 unsigned int x, y; | |
444 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
445 RadiographyLayer& layer = accessor_.GetLayer(); |
407 | 446 if (layer.GetPixel(x, y, sceneX, sceneY)) |
354 | 447 { |
448 unsigned int targetX, targetWidth; | |
449 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
450 if (corner_ == Corner_TopLeft || |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
451 corner_ == Corner_BottomLeft) |
354 | 452 { |
453 targetX = std::min(x, cropX_ + cropWidth_); | |
454 targetWidth = cropX_ + cropWidth_ - targetX; | |
455 } | |
456 else | |
457 { | |
458 targetX = cropX_; | |
459 targetWidth = std::max(x, cropX_) - cropX_; | |
460 } | |
461 | |
462 unsigned int targetY, targetHeight; | |
463 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
464 if (corner_ == Corner_TopLeft || |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
465 corner_ == Corner_TopRight) |
354 | 466 { |
467 targetY = std::min(y, cropY_ + cropHeight_); | |
468 targetHeight = cropY_ + cropHeight_ - targetY; | |
469 } | |
470 else | |
471 { | |
472 targetY = cropY_; | |
473 targetHeight = std::max(y, cropY_) - cropY_; | |
474 } | |
475 | |
407 | 476 layer.SetCrop(targetX, targetY, targetWidth, targetHeight); |
354 | 477 } |
478 } | |
479 } | |
480 }; | |
481 | |
482 | |
408 | 483 class RadiographyLayerResizeTracker : public IWorldSceneMouseTracker |
354 | 484 { |
485 private: | |
408 | 486 UndoRedoStack& undoRedoStack_; |
487 RadiographyScene::LayerAccessor accessor_; | |
488 bool roundScaling_; | |
489 double originalSpacingX_; | |
490 double originalSpacingY_; | |
491 double originalPanX_; | |
492 double originalPanY_; | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
493 Corner oppositeCorner_; |
408 | 494 double oppositeX_; |
495 double oppositeY_; | |
496 double baseScaling_; | |
354 | 497 |
498 static double ComputeDistance(double x1, | |
499 double y1, | |
500 double x2, | |
501 double y2) | |
502 { | |
503 double dx = x1 - x2; | |
504 double dy = y1 - y2; | |
505 return sqrt(dx * dx + dy * dy); | |
506 } | |
507 | |
413 | 508 class UndoRedoCommand : public RadiographySceneCommand |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
509 { |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
510 private: |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
511 double sourceSpacingX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
512 double sourceSpacingY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
513 double sourcePanX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
514 double sourcePanY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
515 double targetSpacingX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
516 double targetSpacingY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
517 double targetPanX_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
518 double targetPanY_; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
519 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
520 protected: |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
521 virtual void UndoInternal(RadiographyLayer& layer) const |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
522 { |
407 | 523 layer.SetPixelSpacing(sourceSpacingX_, sourceSpacingY_); |
524 layer.SetPan(sourcePanX_, sourcePanY_); | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
525 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
526 |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
527 virtual void RedoInternal(RadiographyLayer& layer) const |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
528 { |
407 | 529 layer.SetPixelSpacing(targetSpacingX_, targetSpacingY_); |
530 layer.SetPan(targetPanX_, targetPanY_); | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
531 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
532 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
533 public: |
408 | 534 UndoRedoCommand(const RadiographyLayerResizeTracker& tracker) : |
413 | 535 RadiographySceneCommand(tracker.accessor_), |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
536 sourceSpacingX_(tracker.originalSpacingX_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
537 sourceSpacingY_(tracker.originalSpacingY_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
538 sourcePanX_(tracker.originalPanX_), |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
539 sourcePanY_(tracker.originalPanY_), |
407 | 540 targetSpacingX_(tracker.accessor_.GetLayer().GetPixelSpacingX()), |
541 targetSpacingY_(tracker.accessor_.GetLayer().GetPixelSpacingY()), | |
542 targetPanX_(tracker.accessor_.GetLayer().GetPanX()), | |
543 targetPanY_(tracker.accessor_.GetLayer().GetPanY()) | |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
544 { |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
545 } |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
546 }; |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
547 |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
548 |
354 | 549 public: |
408 | 550 RadiographyLayerResizeTracker(UndoRedoStack& undoRedoStack, |
551 RadiographyScene& scene, | |
552 size_t layer, | |
553 double x, | |
554 double y, | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
555 Corner corner, |
408 | 556 bool roundScaling) : |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
557 undoRedoStack_(undoRedoStack), |
407 | 558 accessor_(scene, layer), |
354 | 559 roundScaling_(roundScaling) |
560 { | |
561 if (accessor_.IsValid() && | |
407 | 562 accessor_.GetLayer().IsResizeable()) |
354 | 563 { |
407 | 564 originalSpacingX_ = accessor_.GetLayer().GetPixelSpacingX(); |
565 originalSpacingY_ = accessor_.GetLayer().GetPixelSpacingY(); | |
566 originalPanX_ = accessor_.GetLayer().GetPanX(); | |
567 originalPanY_ = accessor_.GetLayer().GetPanY(); | |
354 | 568 |
569 switch (corner) | |
570 { | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
571 case Corner_TopLeft: |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
572 oppositeCorner_ = Corner_BottomRight; |
354 | 573 break; |
574 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
575 case Corner_TopRight: |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
576 oppositeCorner_ = Corner_BottomLeft; |
354 | 577 break; |
578 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
579 case Corner_BottomLeft: |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
580 oppositeCorner_ = Corner_TopRight; |
354 | 581 break; |
582 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
583 case Corner_BottomRight: |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
584 oppositeCorner_ = Corner_TopLeft; |
354 | 585 break; |
586 | |
587 default: | |
588 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
589 } | |
590 | |
407 | 591 accessor_.GetLayer().GetCorner(oppositeX_, oppositeY_, oppositeCorner_); |
354 | 592 |
593 double d = ComputeDistance(x, y, oppositeX_, oppositeY_); | |
594 if (d >= std::numeric_limits<float>::epsilon()) | |
595 { | |
596 baseScaling_ = 1.0 / d; | |
597 } | |
598 else | |
599 { | |
600 // Avoid division by zero in extreme cases | |
601 accessor_.Invalidate(); | |
602 } | |
603 } | |
604 } | |
605 | |
606 virtual bool HasRender() const | |
607 { | |
608 return false; | |
609 } | |
610 | |
611 virtual void Render(CairoContext& context, | |
612 double zoom) | |
613 { | |
614 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
615 } | |
616 | |
617 virtual void MouseUp() | |
618 { | |
357
ec4ad6c5eb99
avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
619 if (accessor_.IsValid() && |
407 | 620 accessor_.GetLayer().IsResizeable()) |
355
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
621 { |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
622 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
d2468dd75b3f
undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
354
diff
changeset
|
623 } |
354 | 624 } |
625 | |
626 virtual void MouseMove(int displayX, | |
627 int displayY, | |
628 double sceneX, | |
629 double sceneY) | |
630 { | |
631 static const double ROUND_SCALING = 0.1; | |
632 | |
633 if (accessor_.IsValid() && | |
407 | 634 accessor_.GetLayer().IsResizeable()) |
354 | 635 { |
636 double scaling = ComputeDistance(oppositeX_, oppositeY_, sceneX, sceneY) * baseScaling_; | |
637 | |
638 if (roundScaling_) | |
639 { | |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
640 scaling = boost::math::round<double>((scaling / ROUND_SCALING) * ROUND_SCALING); |
354 | 641 } |
642 | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
643 RadiographyLayer& layer = accessor_.GetLayer(); |
407 | 644 layer.SetPixelSpacing(scaling * originalSpacingX_, |
645 scaling * originalSpacingY_); | |
354 | 646 |
647 // Keep the opposite corner at a fixed location | |
648 double ox, oy; | |
407 | 649 layer.GetCorner(ox, oy, oppositeCorner_); |
650 layer.SetPan(layer.GetPanX() + oppositeX_ - ox, | |
651 layer.GetPanY() + oppositeY_ - oy); | |
354 | 652 } |
653 } | |
654 }; | |
655 | |
656 | |
408 | 657 class RadiographyWindowingTracker : public IWorldSceneMouseTracker |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
658 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
659 public: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
660 enum Action |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
661 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
662 Action_IncreaseWidth, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
663 Action_DecreaseWidth, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
664 Action_IncreaseCenter, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
665 Action_DecreaseCenter |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
666 }; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
667 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
668 private: |
408 | 669 UndoRedoStack& undoRedoStack_; |
670 RadiographyScene& scene_; | |
671 int clickX_; | |
672 int clickY_; | |
673 Action leftAction_; | |
674 Action rightAction_; | |
675 Action upAction_; | |
676 Action downAction_; | |
677 float strength_; | |
678 float sourceCenter_; | |
679 float sourceWidth_; | |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
680 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
681 static void ComputeAxisEffect(int& deltaCenter, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
682 int& deltaWidth, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
683 int delta, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
684 Action actionNegative, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
685 Action actionPositive) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
686 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
687 if (delta < 0) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
688 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
689 switch (actionNegative) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
690 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
691 case Action_IncreaseWidth: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
692 deltaWidth = -delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
693 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
694 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
695 case Action_DecreaseWidth: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
696 deltaWidth = delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
697 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
698 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
699 case Action_IncreaseCenter: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
700 deltaCenter = -delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
701 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
702 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
703 case Action_DecreaseCenter: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
704 deltaCenter = delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
705 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
706 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
707 default: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
708 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
709 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
710 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
711 else if (delta > 0) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
712 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
713 switch (actionPositive) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
714 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
715 case Action_IncreaseWidth: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
716 deltaWidth = delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
717 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
718 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
719 case Action_DecreaseWidth: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
720 deltaWidth = -delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
721 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
722 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
723 case Action_IncreaseCenter: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
724 deltaCenter = delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
725 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
726 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
727 case Action_DecreaseCenter: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
728 deltaCenter = -delta; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
729 break; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
730 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
731 default: |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
732 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
733 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
734 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
735 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
736 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
737 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
738 class UndoRedoCommand : public UndoRedoStack::ICommand |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
739 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
740 private: |
408 | 741 RadiographyScene& scene_; |
742 float sourceCenter_; | |
743 float sourceWidth_; | |
744 float targetCenter_; | |
745 float targetWidth_; | |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
746 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
747 public: |
408 | 748 UndoRedoCommand(const RadiographyWindowingTracker& tracker) : |
407 | 749 scene_(tracker.scene_), |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
750 sourceCenter_(tracker.sourceCenter_), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
751 sourceWidth_(tracker.sourceWidth_) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
752 { |
407 | 753 scene_.GetWindowingWithDefault(targetCenter_, targetWidth_); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
754 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
755 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
756 virtual void Undo() const |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
757 { |
407 | 758 scene_.SetWindowing(sourceCenter_, sourceWidth_); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
759 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
760 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
761 virtual void Redo() const |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
762 { |
407 | 763 scene_.SetWindowing(targetCenter_, targetWidth_); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
764 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
765 }; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
766 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
767 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
768 public: |
408 | 769 RadiographyWindowingTracker(UndoRedoStack& undoRedoStack, |
770 RadiographyScene& scene, | |
771 int x, | |
772 int y, | |
773 Action leftAction, | |
774 Action rightAction, | |
775 Action upAction, | |
776 Action downAction) : | |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
777 undoRedoStack_(undoRedoStack), |
407 | 778 scene_(scene), |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
779 clickX_(x), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
780 clickY_(y), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
781 leftAction_(leftAction), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
782 rightAction_(rightAction), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
783 upAction_(upAction), |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
784 downAction_(downAction) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
785 { |
407 | 786 scene_.GetWindowingWithDefault(sourceCenter_, sourceWidth_); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
787 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
788 float minValue, maxValue; |
407 | 789 scene.GetRange(minValue, maxValue); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
790 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
791 assert(minValue <= maxValue); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
792 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
793 float tmp; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
794 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
795 float delta = (maxValue - minValue); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
796 if (delta <= 1) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
797 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
798 tmp = 0; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
799 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
800 else |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
801 { |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
802 // NB: Visual Studio 2008 does not provide "log2f()", so we |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
803 // implement it by ourselves |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
369
diff
changeset
|
804 tmp = logf(delta) / logf(2.0f); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
805 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
806 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
807 strength_ = tmp - 7; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
808 if (strength_ < 1) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
809 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
810 strength_ = 1; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
811 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
812 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
813 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
814 virtual bool HasRender() const |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
815 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
816 return false; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
817 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
818 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
819 virtual void Render(CairoContext& context, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
820 double zoom) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
821 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
822 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
823 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
824 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
825 virtual void MouseUp() |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
826 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
827 undoRedoStack_.Add(new UndoRedoCommand(*this)); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
828 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
829 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
830 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
831 virtual void MouseMove(int displayX, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
832 int displayY, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
833 double sceneX, |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
834 double sceneY) |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
835 { |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
836 // https://bitbucket.org/osimis/osimis-webviewer-plugin/src/master/frontend/src/app/viewport/image-plugins/windowing-viewport-tool.class.js |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
837 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
838 static const float SCALE = 1.0; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
839 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
840 int deltaCenter = 0; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
841 int deltaWidth = 0; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
842 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
843 ComputeAxisEffect(deltaCenter, deltaWidth, displayX - clickX_, leftAction_, rightAction_); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
844 ComputeAxisEffect(deltaCenter, deltaWidth, displayY - clickY_, upAction_, downAction_); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
845 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
846 float newCenter = sourceCenter_ + (deltaCenter / SCALE * strength_); |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
847 float newWidth = sourceWidth_ + (deltaWidth / SCALE * strength_); |
407 | 848 scene_.SetWindowing(newCenter, newWidth); |
356
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
849 } |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
850 }; |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
851 |
885f0a5eaa49
mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
355
diff
changeset
|
852 |
358 | 853 |
854 | |
407 | 855 namespace Samples |
358 | 856 { |
408 | 857 class RadiographyEditorInteractor : |
407 | 858 public IWorldSceneInteractor, |
859 public IObserver | |
358 | 860 { |
407 | 861 private: |
862 enum Tool | |
863 { | |
864 Tool_Move, | |
865 Tool_Rotate, | |
866 Tool_Crop, | |
867 Tool_Resize, | |
868 Tool_Windowing | |
869 }; | |
358 | 870 |
871 | |
407 | 872 UndoRedoStack undoRedoStack_; |
873 Tool tool_; | |
874 | |
875 | |
876 static double GetHandleSize() | |
877 { | |
878 return 10.0; | |
879 } | |
358 | 880 |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
881 |
407 | 882 public: |
408 | 883 RadiographyEditorInteractor(MessageBroker& broker) : |
407 | 884 IObserver(broker), |
885 tool_(Tool_Move) | |
886 { | |
887 } | |
358 | 888 |
407 | 889 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& worldWidget, |
890 const ViewportGeometry& view, | |
891 MouseButton button, | |
892 KeyboardModifiers modifiers, | |
893 int viewportX, | |
894 int viewportY, | |
895 double x, | |
896 double y, | |
897 IStatusBar* statusBar) | |
357
ec4ad6c5eb99
avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
898 { |
408 | 899 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 900 |
901 if (button == MouseButton_Left) | |
358 | 902 { |
407 | 903 size_t selected; |
904 | |
905 if (tool_ == Tool_Windowing) | |
358 | 906 { |
408 | 907 return new RadiographyWindowingTracker( |
908 undoRedoStack_, widget.GetScene(), | |
909 viewportX, viewportY, | |
910 RadiographyWindowingTracker::Action_DecreaseWidth, | |
911 RadiographyWindowingTracker::Action_IncreaseWidth, | |
912 RadiographyWindowingTracker::Action_DecreaseCenter, | |
913 RadiographyWindowingTracker::Action_IncreaseCenter); | |
358 | 914 } |
407 | 915 else if (!widget.LookupSelectedLayer(selected)) |
358 | 916 { |
407 | 917 // No layer is currently selected |
918 size_t layer; | |
919 if (widget.GetScene().LookupLayer(layer, x, y)) | |
358 | 920 { |
407 | 921 widget.Select(layer); |
358 | 922 } |
407 | 923 |
924 return NULL; | |
358 | 925 } |
407 | 926 else if (tool_ == Tool_Crop || |
927 tool_ == Tool_Resize) | |
358 | 928 { |
408 | 929 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected); |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
930 |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
931 Corner corner; |
407 | 932 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize())) |
358 | 933 { |
407 | 934 switch (tool_) |
935 { | |
936 case Tool_Crop: | |
408 | 937 return new RadiographyLayerCropTracker |
938 (undoRedoStack_, widget.GetScene(), view, selected, x, y, corner); | |
407 | 939 |
940 case Tool_Resize: | |
408 | 941 return new RadiographyLayerResizeTracker |
942 (undoRedoStack_, widget.GetScene(), selected, x, y, corner, | |
943 (modifiers & KeyboardModifiers_Shift)); | |
407 | 944 |
945 default: | |
946 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
947 } | |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
948 } |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
949 else |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
950 { |
407 | 951 size_t layer; |
358 | 952 |
407 | 953 if (widget.GetScene().LookupLayer(layer, x, y)) |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
954 { |
407 | 955 widget.Select(layer); |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
956 } |
407 | 957 else |
958 { | |
959 widget.Unselect(); | |
960 } | |
961 | |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
962 return NULL; |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
963 } |
358 | 964 } |
965 else | |
966 { | |
407 | 967 size_t layer; |
968 | |
969 if (widget.GetScene().LookupLayer(layer, x, y)) | |
970 { | |
971 if (layer == selected) | |
972 { | |
973 switch (tool_) | |
974 { | |
975 case Tool_Move: | |
408 | 976 return new RadiographyLayerMoveTracker |
977 (undoRedoStack_, widget.GetScene(), layer, x, y, | |
978 (modifiers & KeyboardModifiers_Shift)); | |
407 | 979 |
980 case Tool_Rotate: | |
408 | 981 return new RadiographyLayerRotateTracker |
982 (undoRedoStack_, widget.GetScene(), view, layer, x, y, | |
983 (modifiers & KeyboardModifiers_Shift)); | |
407 | 984 |
985 default: | |
986 break; | |
987 } | |
988 | |
989 return NULL; | |
990 } | |
991 else | |
992 { | |
993 widget.Select(layer); | |
994 return NULL; | |
995 } | |
996 } | |
997 else | |
998 { | |
999 widget.Unselect(); | |
1000 return NULL; | |
1001 } | |
1002 } | |
1003 } | |
1004 else | |
1005 { | |
1006 return NULL; | |
1007 } | |
1008 } | |
1009 | |
1010 virtual void MouseOver(CairoContext& context, | |
1011 WorldSceneWidget& worldWidget, | |
1012 const ViewportGeometry& view, | |
1013 double x, | |
1014 double y, | |
1015 IStatusBar* statusBar) | |
1016 { | |
408 | 1017 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 1018 |
1019 #if 0 | |
1020 if (statusBar != NULL) | |
1021 { | |
1022 char buf[64]; | |
1023 sprintf(buf, "X = %.02f Y = %.02f (in cm)", x / 10.0, y / 10.0); | |
1024 statusBar->SetMessage(buf); | |
1025 } | |
1026 #endif | |
1027 | |
1028 size_t selected; | |
1029 | |
1030 if (widget.LookupSelectedLayer(selected) && | |
1031 (tool_ == Tool_Crop || | |
1032 tool_ == Tool_Resize)) | |
1033 { | |
408 | 1034 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected); |
407 | 1035 |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1036 Corner corner; |
407 | 1037 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize())) |
1038 { | |
1039 accessor.GetLayer().GetCorner(x, y, corner); | |
1040 | |
1041 double z = 1.0 / view.GetZoom(); | |
1042 | |
1043 context.SetSourceColor(255, 0, 0); | |
1044 cairo_t* cr = context.GetObject(); | |
1045 cairo_set_line_width(cr, 2.0 * z); | |
1046 cairo_move_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z); | |
1047 cairo_line_to(cr, x + GetHandleSize() * z, y - GetHandleSize() * z); | |
1048 cairo_line_to(cr, x + GetHandleSize() * z, y + GetHandleSize() * z); | |
1049 cairo_line_to(cr, x - GetHandleSize() * z, y + GetHandleSize() * z); | |
1050 cairo_line_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z); | |
1051 cairo_stroke(cr); | |
358 | 1052 } |
1053 } | |
339 | 1054 } |
407 | 1055 |
1056 virtual void MouseWheel(WorldSceneWidget& widget, | |
1057 MouseWheelDirection direction, | |
1058 KeyboardModifiers modifiers, | |
1059 IStatusBar* statusBar) | |
344
fdec8e6893cb
ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
1060 { |
358 | 1061 } |
407 | 1062 |
1063 virtual void KeyPressed(WorldSceneWidget& worldWidget, | |
1064 KeyboardKeys key, | |
1065 char keyChar, | |
1066 KeyboardModifiers modifiers, | |
1067 IStatusBar* statusBar) | |
345 | 1068 { |
408 | 1069 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget); |
407 | 1070 |
1071 switch (keyChar) | |
358 | 1072 { |
407 | 1073 case 'a': |
1074 widget.FitContent(); | |
1075 break; | |
1076 | |
1077 case 'c': | |
1078 tool_ = Tool_Crop; | |
1079 break; | |
1080 | |
1081 case 'e': | |
1082 { | |
1083 Orthanc::DicomMap tags; | |
1084 | |
1085 // Minimal set of tags to generate a valid CR image | |
1086 tags.SetValue(Orthanc::DICOM_TAG_ACCESSION_NUMBER, "NOPE", false); | |
1087 tags.SetValue(Orthanc::DICOM_TAG_BODY_PART_EXAMINED, "PELVIS", false); | |
1088 tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "1", false); | |
1089 //tags.SetValue(Orthanc::DICOM_TAG_LATERALITY, "", false); | |
1090 tags.SetValue(Orthanc::DICOM_TAG_MANUFACTURER, "OSIMIS", false); | |
1091 tags.SetValue(Orthanc::DICOM_TAG_MODALITY, "CR", false); | |
1092 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_BIRTH_DATE, "20000101", false); | |
1093 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false); | |
1094 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false); | |
1095 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ORIENTATION, "", false); | |
1096 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_SEX, "M", false); | |
1097 tags.SetValue(Orthanc::DICOM_TAG_REFERRING_PHYSICIAN_NAME, "HOUSE^MD", false); | |
1098 tags.SetValue(Orthanc::DICOM_TAG_SERIES_NUMBER, "1", false); | |
1099 tags.SetValue(Orthanc::DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.1", false); | |
1100 tags.SetValue(Orthanc::DICOM_TAG_STUDY_ID, "STUDY", false); | |
1101 tags.SetValue(Orthanc::DICOM_TAG_VIEW_POSITION, "", false); | |
1102 | |
408 | 1103 widget.GetScene().ExportDicom(tags, 0.1, 0.1, widget.IsInverted(), |
1104 widget.GetInterpolation(), EXPORT_USING_PAM); | |
407 | 1105 break; |
1106 } | |
1107 | |
1108 case 'i': | |
1109 widget.SwitchInvert(); | |
1110 break; | |
1111 | |
1112 case 'm': | |
1113 tool_ = Tool_Move; | |
1114 break; | |
1115 | |
1116 case 'n': | |
1117 { | |
1118 switch (widget.GetInterpolation()) | |
1119 { | |
1120 case ImageInterpolation_Nearest: | |
1121 LOG(INFO) << "Switching to bilinear interpolation"; | |
1122 widget.SetInterpolation(ImageInterpolation_Bilinear); | |
1123 break; | |
1124 | |
1125 case ImageInterpolation_Bilinear: | |
1126 LOG(INFO) << "Switching to nearest neighbor interpolation"; | |
1127 widget.SetInterpolation(ImageInterpolation_Nearest); | |
1128 break; | |
1129 | |
1130 default: | |
1131 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
1132 } | |
358 | 1133 |
407 | 1134 break; |
1135 } | |
1136 | |
1137 case 'r': | |
1138 tool_ = Tool_Rotate; | |
1139 break; | |
1140 | |
1141 case 's': | |
1142 tool_ = Tool_Resize; | |
1143 break; | |
1144 | |
1145 case 'w': | |
1146 tool_ = Tool_Windowing; | |
1147 break; | |
1148 | |
1149 case 'y': | |
1150 if (modifiers & KeyboardModifiers_Control) | |
1151 { | |
1152 undoRedoStack_.Redo(); | |
1153 widget.NotifyContentChanged(); | |
1154 } | |
1155 break; | |
1156 | |
1157 case 'z': | |
1158 if (modifiers & KeyboardModifiers_Control) | |
1159 { | |
1160 undoRedoStack_.Undo(); | |
1161 widget.NotifyContentChanged(); | |
1162 } | |
1163 break; | |
1164 | |
1165 default: | |
1166 break; | |
358 | 1167 } |
345 | 1168 } |
407 | 1169 }; |
336
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
1170 |
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
1171 |
358 | 1172 |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1173 class SingleFrameEditorApplication : |
340
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1174 public SampleSingleCanvasApplicationBase, |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1175 public IObserver |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1176 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1177 private: |
334
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
1178 std::auto_ptr<OrthancApiClient> orthancApiClient_; |
408 | 1179 std::auto_ptr<RadiographyScene> scene_; |
1180 RadiographyEditorInteractor interactor_; | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1181 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1182 public: |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1183 SingleFrameEditorApplication(MessageBroker& broker) : |
362
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
1184 IObserver(broker), |
12cec26d08ce
export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
361
diff
changeset
|
1185 interactor_(broker) |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1186 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1187 } |
384
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
1188 |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
1189 virtual ~SingleFrameEditorApplication() |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
1190 { |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
1191 LOG(WARNING) << "Destroying the application"; |
d20d75f20c5d
better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
1192 } |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1193 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1194 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1195 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1196 boost::program_options::options_description generic("Sample options"); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1197 generic.add_options() |
340
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1198 ("instance", boost::program_options::value<std::string>(), |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1199 "Orthanc ID of the instance") |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1200 ("frame", boost::program_options::value<unsigned int>()->default_value(0), |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1201 "Number of the frame, for multi-frame DICOM instances") |
f5d5814a41a0
rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
1202 ; |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1203 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1204 options.add(generic); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1205 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1206 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1207 virtual void Initialize(StoneApplicationContext* context, |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1208 IStatusBar& statusBar, |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1209 const boost::program_options::variables_map& parameters) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1210 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1211 using namespace OrthancStone; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1212 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1213 context_ = context; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1214 |
358 | 1215 statusBar.SetMessage("Use the key \"a\" to reinitialize the layout"); |
1216 statusBar.SetMessage("Use the key \"c\" to crop"); | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
1217 statusBar.SetMessage("Use the key \"e\" to export DICOM to the Orthanc server"); |
358 | 1218 statusBar.SetMessage("Use the key \"f\" to switch full screen"); |
1219 statusBar.SetMessage("Use the key \"i\" to invert contrast"); | |
1220 statusBar.SetMessage("Use the key \"m\" to move objects"); | |
359
100df90bf0ea
preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
358
diff
changeset
|
1221 statusBar.SetMessage("Use the key \"n\" to switch between nearest neighbor and bilinear interpolation"); |
358 | 1222 statusBar.SetMessage("Use the key \"r\" to rotate objects"); |
407 | 1223 statusBar.SetMessage("Use the key \"s\" to resize objects (not applicable to DICOM layers)"); |
358 | 1224 statusBar.SetMessage("Use the key \"w\" to change windowing"); |
1225 | |
1226 statusBar.SetMessage("Use the key \"ctrl-z\" to undo action"); | |
1227 statusBar.SetMessage("Use the key \"ctrl-y\" to redo action"); | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1228 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1229 if (parameters.count("instance") != 1) |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1230 { |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1231 LOG(ERROR) << "The instance ID is missing"; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1232 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1233 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1234 |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1235 std::string instance = parameters["instance"].as<std::string>(); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1236 int frame = parameters["frame"].as<unsigned int>(); |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1237 |
393
e7a494bdd956
removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
392
diff
changeset
|
1238 orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService())); |
337 | 1239 |
343 | 1240 Orthanc::FontRegistry fonts; |
1241 fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); | |
1242 | |
408 | 1243 scene_.reset(new RadiographyScene(GetBroker(), *orthancApiClient_)); |
407 | 1244 scene_->LoadDicomFrame(instance, frame, false); //.SetPan(200, 0); |
1245 //scene_->LoadDicomFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false); | |
354 | 1246 |
1247 { | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1248 RadiographyLayer& layer = scene_->LoadText(fonts.GetFont(0), "Hello\nworld"); |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1249 layer.SetResizeable(true); |
354 | 1250 } |
1251 | |
1252 { | |
410
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1253 RadiographyLayer& layer = scene_->LoadTestBlock(100, 50); |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1254 layer.SetResizeable(true); |
6decc0ba9da5
rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
408
diff
changeset
|
1255 layer.SetPan(0, 200); |
354 | 1256 } |
1257 | |
337 | 1258 |
408 | 1259 mainWidget_ = new RadiographyWidget(GetBroker(), *scene_, "main-widget"); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1260 mainWidget_->SetTransmitMouseOver(true); |
358 | 1261 mainWidget_->SetInteractor(interactor_); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1262 |
407 | 1263 //scene_->SetWindowing(128, 256); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1264 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1265 }; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1266 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff
changeset
|
1267 } |