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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
26 #include "../../Framework/Radiography/RadiographyScene.h"
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
27 #include "../../Framework/Radiography/RadiographyWidget.h"
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
28
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
29 #include "../../Framework/Toolbox/UndoRedoStack.h"
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
30
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
33 #include <Core/Images/ImageProcessing.h>
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
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
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
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
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
41 #include <Plugins/Samples/Common/FullOrthancDataset.h>
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
42
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
43
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
44 // Export using PAM is faster than using PNG, but requires Orthanc
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
55 class RadiographySceneCommand : public UndoRedoStack::ICommand
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
56 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
57 private:
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
58 RadiographyScene& scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
59 size_t layer_;
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
60
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
65
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
66 public:
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
67 RadiographySceneCommand(RadiographyScene& scene,
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
68 size_t layer) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
69 scene_(scene),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
70 layer_(layer)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
71 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
72 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
73
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
74 RadiographySceneCommand(const RadiographyScene::LayerAccessor& accessor) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
75 scene_(accessor.GetScene()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
76 layer_(accessor.GetIndex())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
77 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
78 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
79
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
80 virtual void Undo() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
81 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
82 RadiographyScene::LayerAccessor accessor(scene_, layer_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
83
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
84 if (accessor.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
85 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
86 UndoInternal(accessor.GetLayer());
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
87 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
88 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
89
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
90 virtual void Redo() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
91 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
92 RadiographyScene::LayerAccessor accessor(scene_, layer_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
93
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
94 if (accessor.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
95 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
96 RedoInternal(accessor.GetLayer());
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
97 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
98 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
99 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
100
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
101
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
102 class RadiographyLayerRotateTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
103 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
104 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
105 UndoRedoStack& undoRedoStack_;
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
106 RadiographyScene::LayerAccessor accessor_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
107 double centerX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
108 double centerY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
109 double originalAngle_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
110 double clickAngle_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
111 bool roundAngles_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
112
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
113 bool ComputeAngle(double& angle /* out */,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
114 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
115 double sceneY) const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
116 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
117 Vector u;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
118 LinearAlgebra::AssignVector(u, sceneX - centerX_, sceneY - centerY_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
119
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
120 double nu = boost::numeric::ublas::norm_2(u);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
121
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
122 if (!LinearAlgebra::IsCloseToZero(nu))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
123 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
124 u /= nu;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
125 angle = atan2(u[1], u[0]);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
126 return true;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
127 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
128 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
129 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
130 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
131 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
132 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
133
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
134
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
135 class UndoRedoCommand : public RadiographySceneCommand
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
136 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
137 private:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
138 double sourceAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
139 double targetAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
140
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
141 static int ToDegrees(double angle)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
144 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
145
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
148 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
149 LOG(INFO) << "Undo - Set angle to " << ToDegrees(sourceAngle_) << " degrees";
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
150 layer.SetAngle(sourceAngle_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
151 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
154 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
155 LOG(INFO) << "Redo - Set angle to " << ToDegrees(sourceAngle_) << " degrees";
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
156 layer.SetAngle(targetAngle_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
157 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
158
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
159 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
160 UndoRedoCommand(const RadiographyLayerRotateTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
163 targetAngle_(tracker.accessor_.GetLayer().GetAngle())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
164 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
165 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
166 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
167
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
168
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
169 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
170 RadiographyLayerRotateTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
171 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
172 const ViewportGeometry& view,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
173 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
174 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
175 double y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
176 bool roundAngles) :
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
177 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
178 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
179 roundAngles_(roundAngles)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
180 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
181 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
182 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
183 accessor_.GetLayer().GetCenter(centerX_, centerY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
184 originalAngle_ = accessor_.GetLayer().GetAngle();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
185
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
186 double sceneX, sceneY;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
187 view.MapDisplayToScene(sceneX, sceneY, x, y);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
188
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
189 if (!ComputeAngle(clickAngle_, x, y))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
190 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
191 accessor_.Invalidate();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
192 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
193 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
194 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
195
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
196 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
197 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
198 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
199 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
200
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
201 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
202 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
203 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
204 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
205 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
206
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
207 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
208 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
209 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
212 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
213 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
214
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
215 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
216 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
217 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
218 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
219 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
220 static const double ROUND_ANGLE = 15.0 / 180.0 * boost::math::constants::pi<double>();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
221
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
222 double angle;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
223
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
224 if (accessor_.IsValid() &&
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
225 ComputeAngle(angle, sceneX, sceneY))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
226 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
227 angle = angle - clickAngle_ + originalAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
228
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
229 if (roundAngles_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
232 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
233
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
234 accessor_.GetLayer().SetAngle(angle);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
235 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
236 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
237 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
238
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
239
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
240 class RadiographyLayerMoveTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
241 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
242 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
243 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
244 RadiographyScene::LayerAccessor accessor_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
245 double clickX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
246 double clickY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
247 double panX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
248 double panY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
249 bool oneAxis_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
250
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
251 class UndoRedoCommand : public RadiographySceneCommand
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
252 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
253 private:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
254 double sourceX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
255 double sourceY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
256 double targetX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
257 double targetY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
258
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
261 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
262 layer.SetPan(sourceX_, sourceY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
263 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
266 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
267 layer.SetPan(targetX_, targetY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
268 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
269
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
270 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
271 UndoRedoCommand(const RadiographyLayerMoveTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
275 targetX_(tracker.accessor_.GetLayer().GetPanX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
276 targetY_(tracker.accessor_.GetLayer().GetPanY())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
277 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
278 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
279 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
280
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
281
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
282 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
283 RadiographyLayerMoveTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
284 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
285 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
286 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
287 double y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
288 bool oneAxis) :
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
289 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
290 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
291 clickX_(x),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
292 clickY_(y),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
293 oneAxis_(oneAxis)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
294 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
295 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
296 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
297 panX_ = accessor_.GetLayer().GetPanX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
298 panY_ = accessor_.GetLayer().GetPanY();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
299 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
300 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
301
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
302 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
303 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
304 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
305 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
306
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
307 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
308 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
309 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
310 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
311 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
312
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
313 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
314 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
315 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
318 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
319 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
320
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
321 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
322 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
323 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
324 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
325 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
326 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
327 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
328 double dx = sceneX - clickX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
329 double dy = sceneY - clickY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
330
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
331 if (oneAxis_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
332 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
333 if (fabs(dx) > fabs(dy))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
334 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
335 accessor_.GetLayer().SetPan(dx + panX_, panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
336 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
337 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
338 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
339 accessor_.GetLayer().SetPan(panX_, dy + panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
340 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
341 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
342 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
343 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
344 accessor_.GetLayer().SetPan(dx + panX_, dy + panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
345 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
346 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
347 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
348 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
349
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
350
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
351 class RadiographyLayerCropTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
352 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
353 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
354 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
357 unsigned int cropX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
358 unsigned int cropY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
359 unsigned int cropWidth_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
360 unsigned int cropHeight_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
361
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
386 UndoRedoCommand(const RadiographyLayerCropTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
393 tracker.accessor_.GetLayer().GetCrop(targetCropX_, targetCropY_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
399 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
400 RadiographyLayerCropTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
401 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
402 const ViewportGeometry& view,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
403 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
404 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
408 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
409 corner_(corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
410 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
411 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
412 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
413 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
414 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
415 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
416
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
417 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
418 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
419 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
420 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
421
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
422 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
423 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
424 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
425 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
426 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
427
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
428 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
434 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
435
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
436 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
437 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
438 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
439 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
440 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
441 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
442 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
443 unsigned int x, y;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
444
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
445 RadiographyLayer& layer = accessor_.GetLayer();
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
446 if (layer.GetPixel(x, y, sceneX, sceneY))
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
447 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
448 unsigned int targetX, targetWidth;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
452 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
453 targetX = std::min(x, cropX_ + cropWidth_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
454 targetWidth = cropX_ + cropWidth_ - targetX;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
455 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
456 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
457 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
458 targetX = cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
459 targetWidth = std::max(x, cropX_) - cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
460 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
461
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
462 unsigned int targetY, targetHeight;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
466 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
467 targetY = std::min(y, cropY_ + cropHeight_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
468 targetHeight = cropY_ + cropHeight_ - targetY;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
469 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
470 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
471 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
472 targetY = cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
473 targetHeight = std::max(y, cropY_) - cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
474 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
475
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
476 layer.SetCrop(targetX, targetY, targetWidth, targetHeight);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
477 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
478 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
479 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
480 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
481
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
482
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
483 class RadiographyLayerResizeTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
484 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
485 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
486 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
487 RadiographyScene::LayerAccessor accessor_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
488 bool roundScaling_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
489 double originalSpacingX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
490 double originalSpacingY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
491 double originalPanX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
492 double originalPanY_;
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
493 Corner oppositeCorner_;
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
494 double oppositeX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
495 double oppositeY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
496 double baseScaling_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
497
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
498 static double ComputeDistance(double x1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
499 double y1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
500 double x2,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
501 double y2)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
502 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
503 double dx = x1 - x2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
504 double dy = y1 - y2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
505 return sqrt(dx * dx + dy * dy);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
506 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
507
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
523 layer.SetPixelSpacing(sourceSpacingX_, sourceSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
529 layer.SetPixelSpacing(targetSpacingX_, targetSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
534 UndoRedoCommand(const RadiographyLayerResizeTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
540 targetSpacingX_(tracker.accessor_.GetLayer().GetPixelSpacingX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
541 targetSpacingY_(tracker.accessor_.GetLayer().GetPixelSpacingY()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
542 targetPanX_(tracker.accessor_.GetLayer().GetPanX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
549 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
550 RadiographyLayerResizeTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
551 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
552 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
553 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
554 double y,
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
555 Corner corner,
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
556 bool roundScaling) :
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
557 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
558 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
559 roundScaling_(roundScaling)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
560 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
561 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
562 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
563 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
564 originalSpacingX_ = accessor_.GetLayer().GetPixelSpacingX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
565 originalSpacingY_ = accessor_.GetLayer().GetPixelSpacingY();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
566 originalPanX_ = accessor_.GetLayer().GetPanX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
567 originalPanY_ = accessor_.GetLayer().GetPanY();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
568
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
569 switch (corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
573 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
577 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
581 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
585 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
586
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
587 default:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
588 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
589 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
590
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
591 accessor_.GetLayer().GetCorner(oppositeX_, oppositeY_, oppositeCorner_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
592
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
593 double d = ComputeDistance(x, y, oppositeX_, oppositeY_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
594 if (d >= std::numeric_limits<float>::epsilon())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
595 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
596 baseScaling_ = 1.0 / d;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
597 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
598 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
599 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
600 // Avoid division by zero in extreme cases
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
601 accessor_.Invalidate();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
602 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
603 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
604 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
605
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
606 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
607 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
608 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
609 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
610
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
611 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
612 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
613 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
614 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
615 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
616
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
617 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
618 {
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
619 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
624 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
625
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
626 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
627 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
628 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
629 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
630 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
631 static const double ROUND_SCALING = 0.1;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
632
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
633 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
634 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
635 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
636 double scaling = ComputeDistance(oppositeX_, oppositeY_, sceneX, sceneY) * baseScaling_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
637
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
638 if (roundScaling_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
641 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
642
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
643 RadiographyLayer& layer = accessor_.GetLayer();
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
644 layer.SetPixelSpacing(scaling * originalSpacingX_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
645 scaling * originalSpacingY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
646
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
647 // Keep the opposite corner at a fixed location
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
648 double ox, oy;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
649 layer.GetCorner(ox, oy, oppositeCorner_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
650 layer.SetPan(layer.GetPanX() + oppositeX_ - ox,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
651 layer.GetPanY() + oppositeY_ - oy);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
652 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
653 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
654 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
655
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
656
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
669 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
670 RadiographyScene& scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
671 int clickX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
672 int clickY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
673 Action leftAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
674 Action rightAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
675 Action upAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
676 Action downAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
677 float strength_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
678 float sourceCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
741 RadiographyScene& scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
742 float sourceCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
743 float sourceWidth_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
744 float targetCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
748 UndoRedoCommand(const RadiographyWindowingTracker& tracker) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
769 RadiographyWindowingTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
770 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
771 int x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
772 int y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
773 Action leftAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
774 Action rightAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
775 Action upAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
776 Action downAction) :
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
777 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
853
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
854
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
855 namespace Samples
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
856 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
857 class RadiographyEditorInteractor :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
858 public IWorldSceneInteractor,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
859 public IObserver
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
860 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
861 private:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
862 enum Tool
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
863 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
864 Tool_Move,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
865 Tool_Rotate,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
866 Tool_Crop,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
867 Tool_Resize,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
868 Tool_Windowing
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
869 };
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
870
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
871
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
872 UndoRedoStack undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
873 Tool tool_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
874
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
875
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
876 static double GetHandleSize()
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
877 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
878 return 10.0;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
879 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
880
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
881
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
882 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
883 RadiographyEditorInteractor(MessageBroker& broker) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
884 IObserver(broker),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
885 tool_(Tool_Move)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
886 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
887 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
888
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
889 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
890 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
891 MouseButton button,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
892 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
893 int viewportX,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
894 int viewportY,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
895 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
896 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
897 IStatusBar* statusBar)
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
898 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
899 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
900
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
901 if (button == MouseButton_Left)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
902 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
903 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
904
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
905 if (tool_ == Tool_Windowing)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
906 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
907 return new RadiographyWindowingTracker(
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
908 undoRedoStack_, widget.GetScene(),
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
909 viewportX, viewportY,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
910 RadiographyWindowingTracker::Action_DecreaseWidth,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
911 RadiographyWindowingTracker::Action_IncreaseWidth,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
912 RadiographyWindowingTracker::Action_DecreaseCenter,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
913 RadiographyWindowingTracker::Action_IncreaseCenter);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
914 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
915 else if (!widget.LookupSelectedLayer(selected))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
916 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
917 // No layer is currently selected
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
918 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
919 if (widget.GetScene().LookupLayer(layer, x, y))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
920 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
921 widget.Select(layer);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
922 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
923
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
924 return NULL;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
925 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
926 else if (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
927 tool_ == Tool_Resize)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
928 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
932 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
933 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
934 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
935 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
936 case Tool_Crop:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
937 return new RadiographyLayerCropTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
938 (undoRedoStack_, widget.GetScene(), view, selected, x, y, corner);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
939
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
940 case Tool_Resize:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
941 return new RadiographyLayerResizeTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
942 (undoRedoStack_, widget.GetScene(), selected, x, y, corner,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
943 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
944
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
945 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
946 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
951 size_t layer;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
952
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
957 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
958 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
959 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
960 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
964 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
965 else
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
966 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
967 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
968
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
969 if (widget.GetScene().LookupLayer(layer, x, y))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
970 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
971 if (layer == selected)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
972 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
973 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
974 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
975 case Tool_Move:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
976 return new RadiographyLayerMoveTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
977 (undoRedoStack_, widget.GetScene(), layer, x, y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
978 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
979
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
980 case Tool_Rotate:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
981 return new RadiographyLayerRotateTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
982 (undoRedoStack_, widget.GetScene(), view, layer, x, y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
983 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
984
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
985 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
986 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
987 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
988
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
989 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
990 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
991 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
992 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
993 widget.Select(layer);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
994 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
995 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
996 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
997 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
998 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
999 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1000 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1001 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1002 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1003 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1004 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1005 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1006 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1007 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1008 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1009
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1010 virtual void MouseOver(CairoContext& context,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1011 WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1012 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1013 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1014 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1015 IStatusBar* statusBar)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1016 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1017 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1018
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1019 #if 0
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1020 if (statusBar != NULL)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1021 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1022 char buf[64];
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1023 sprintf(buf, "X = %.02f Y = %.02f (in cm)", x / 10.0, y / 10.0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1024 statusBar->SetMessage(buf);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1025 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1026 #endif
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1027
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1028 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1029
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1030 if (widget.LookupSelectedLayer(selected) &&
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1031 (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1032 tool_ == Tool_Resize))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1033 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1034 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1035
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
1036 Corner corner;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1037 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1038 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1039 accessor.GetLayer().GetCorner(x, y, corner);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1040
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1041 double z = 1.0 / view.GetZoom();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1042
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1043 context.SetSourceColor(255, 0, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1044 cairo_t* cr = context.GetObject();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1045 cairo_set_line_width(cr, 2.0 * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1046 cairo_move_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1047 cairo_line_to(cr, x + GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1048 cairo_line_to(cr, x + GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1049 cairo_line_to(cr, x - GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1050 cairo_line_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1051 cairo_stroke(cr);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1052 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1053 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1054 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1055
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1056 virtual void MouseWheel(WorldSceneWidget& widget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1057 MouseWheelDirection direction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1058 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1059 IStatusBar* statusBar)
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1060 {
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1061 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1062
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1063 virtual void KeyPressed(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1064 KeyboardKeys key,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1065 char keyChar,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1066 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1067 IStatusBar* statusBar)
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1068 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1069 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1070
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1071 switch (keyChar)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1072 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1073 case 'a':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1074 widget.FitContent();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1075 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1076
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1077 case 'c':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1078 tool_ = Tool_Crop;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1079 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1080
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1081 case 'e':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1082 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1083 Orthanc::DicomMap tags;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1084
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1085 // Minimal set of tags to generate a valid CR image
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1086 tags.SetValue(Orthanc::DICOM_TAG_ACCESSION_NUMBER, "NOPE", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1087 tags.SetValue(Orthanc::DICOM_TAG_BODY_PART_EXAMINED, "PELVIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1088 tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1089 //tags.SetValue(Orthanc::DICOM_TAG_LATERALITY, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1090 tags.SetValue(Orthanc::DICOM_TAG_MANUFACTURER, "OSIMIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1091 tags.SetValue(Orthanc::DICOM_TAG_MODALITY, "CR", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1092 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_BIRTH_DATE, "20000101", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1093 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1094 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1095 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ORIENTATION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1096 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_SEX, "M", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1097 tags.SetValue(Orthanc::DICOM_TAG_REFERRING_PHYSICIAN_NAME, "HOUSE^MD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1098 tags.SetValue(Orthanc::DICOM_TAG_SERIES_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1099 tags.SetValue(Orthanc::DICOM_TAG_SOP_CLASS_UID, "1.2.840.10008.5.1.4.1.1.1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1100 tags.SetValue(Orthanc::DICOM_TAG_STUDY_ID, "STUDY", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1101 tags.SetValue(Orthanc::DICOM_TAG_VIEW_POSITION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1102
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1103 widget.GetScene().ExportDicom(tags, 0.1, 0.1, widget.IsInverted(),
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1104 widget.GetInterpolation(), EXPORT_USING_PAM);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1105 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1106 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1107
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1108 case 'i':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1109 widget.SwitchInvert();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1110 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1111
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1112 case 'm':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1113 tool_ = Tool_Move;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1114 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1115
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1116 case 'n':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1117 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1118 switch (widget.GetInterpolation())
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1119 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1120 case ImageInterpolation_Nearest:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1121 LOG(INFO) << "Switching to bilinear interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1122 widget.SetInterpolation(ImageInterpolation_Bilinear);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1123 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1124
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1125 case ImageInterpolation_Bilinear:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1126 LOG(INFO) << "Switching to nearest neighbor interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1127 widget.SetInterpolation(ImageInterpolation_Nearest);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1128 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1129
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1130 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1131 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1132 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1133
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1134 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1135 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1136
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1137 case 'r':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1138 tool_ = Tool_Rotate;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1139 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1140
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1141 case 's':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1142 tool_ = Tool_Resize;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1143 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1144
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1145 case 'w':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1146 tool_ = Tool_Windowing;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1147 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1148
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1149 case 'y':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1150 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1151 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1152 undoRedoStack_.Redo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1153 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1154 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1155 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1156
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1157 case 'z':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1158 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1159 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1160 undoRedoStack_.Undo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1161 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1162 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1163 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1164
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1165 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1166 break;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1167 }
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1168 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
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
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1179 std::auto_ptr<RadiographyScene> scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1215 statusBar.SetMessage("Use the key \"a\" to reinitialize the layout");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1218 statusBar.SetMessage("Use the key \"f\" to switch full screen");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1219 statusBar.SetMessage("Use the key \"i\" to invert contrast");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1222 statusBar.SetMessage("Use the key \"r\" to rotate objects");
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1223 statusBar.SetMessage("Use the key \"s\" to resize objects (not applicable to DICOM layers)");
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1224 statusBar.SetMessage("Use the key \"w\" to change windowing");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1225
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1226 statusBar.SetMessage("Use the key \"ctrl-z\" to undo action");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
1239
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1240 Orthanc::FontRegistry fonts;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1241 fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1242
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
1243 scene_.reset(new RadiographyScene(GetBroker(), *orthancApiClient_));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1244 scene_->LoadDicomFrame(instance, frame, false); //.SetPan(200, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1245 //scene_->LoadDicomFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1246
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1250 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1251
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
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
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1256 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1257
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
1258
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
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
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
1261 mainWidget_->SetInteractor(interactor_);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
1262
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
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 }