annotate Applications/Samples/SingleFrameEditorApplication.h @ 407:842a3c7cfdc0

renames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Nov 2018 11:44:20 +0100
parents 99e31898910e
children 6834c236b36d
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
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
26 #include "../../Framework/Toolbox/ImageGeometry.h"
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
27 #include "../../Framework/Toolbox/OrthancApiClient.h"
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
28 #include "../../Framework/Toolbox/DicomFrameConverter.h"
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
29
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
30 #include <Core/Images/FontRegistry.h>
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
31 #include <Core/Images/Image.h>
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
32 #include <Core/Images/ImageProcessing.h>
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
33 #include <Core/Images/PamReader.h>
361
f559ac66ef55 first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
34 #include <Core/Images/PamWriter.h>
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
35 #include <Core/Images/PngWriter.h>
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
36 #include <Core/Logging.h>
403
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
37 #include <Core/OrthancException.h>
361
f559ac66ef55 first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
38 #include <Core/Toolbox.h>
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
39 #include <Plugins/Samples/Common/DicomDatasetReader.h>
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
40 #include <Plugins/Samples/Common/FullOrthancDataset.h>
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
41
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
42
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
43 // Export using PAM is faster than using PNG, but requires Orthanc
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
44 // core >= 1.4.3
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
45 #define EXPORT_USING_PAM 1
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
46
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
47
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
48 #include <boost/math/constants/constants.hpp>
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
49 #include <boost/math/special_functions/round.hpp>
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
50
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
51
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
52 namespace OrthancStone
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
53 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
54 class RadiologyScene :
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
55 public IObserver,
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
56 public IObservable
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
57 {
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
58 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
59 typedef OriginMessage<MessageType_Widget_GeometryChanged, RadiologyScene> GeometryChangedMessage;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
60 typedef OriginMessage<MessageType_Widget_ContentChanged, RadiologyScene> ContentChangedMessage;
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
61
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
62
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
63 enum Corner
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
64 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
65 Corner_TopLeft,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
66 Corner_TopRight,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
67 Corner_BottomLeft,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
68 Corner_BottomRight
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
69 };
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
70
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
71
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
72
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
73 class Layer : public boost::noncopyable
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
74 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
75 friend class RadiologyScene;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
76
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
77 private:
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
78 size_t index_;
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
79 bool hasSize_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
80 unsigned int width_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
81 unsigned int height_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
82 bool hasCrop_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
83 unsigned int cropX_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
84 unsigned int cropY_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
85 unsigned int cropWidth_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
86 unsigned int cropHeight_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
87 Matrix transform_;
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
88 Matrix transformInverse_;
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
89 double pixelSpacingX_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
90 double pixelSpacingY_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
91 double panX_;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
92 double panY_;
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
93 double angle_;
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
94 bool resizeable_;
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
95
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
96
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
97 protected:
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
98 const Matrix& GetTransform() const
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
99 {
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
100 return transform_;
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
101 }
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
102
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
103
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
104 private:
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
105 static void ApplyTransform(double& x /* inout */,
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
106 double& y /* inout */,
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
107 const Matrix& transform)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
108 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
109 Vector p;
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
110 LinearAlgebra::AssignVector(p, x, y, 1);
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
111
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
112 Vector q = LinearAlgebra::Product(transform, p);
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
113
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
114 if (!LinearAlgebra::IsNear(q[2], 1.0))
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
115 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
116 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
117 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
118 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
119 {
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
120 x = q[0];
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
121 y = q[1];
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
122 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
123 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
124
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
125
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
126 void UpdateTransform()
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
127 {
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
128 transform_ = CreateScalingMatrix(pixelSpacingX_, pixelSpacingY_);
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
129
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
130 double centerX, centerY;
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
131 GetCenter(centerX, centerY);
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
132
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
133 transform_ = LinearAlgebra::Product(
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
134 CreateOffsetMatrix(panX_ + centerX, panY_ + centerY),
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
135 CreateRotationMatrix(angle_),
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
136 CreateOffsetMatrix(-centerX, -centerY),
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
137 transform_);
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
138
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
139 LinearAlgebra::InvertMatrix(transformInverse_, transform_);
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
140 }
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
141
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
142
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
143 void AddToExtent(Extent2D& extent,
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
144 double x,
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
145 double y) const
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
146 {
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
147 ApplyTransform(x, y, transform_);
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
148 extent.AddPoint(x, y);
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
149 }
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
150
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
151
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
152 void GetCornerInternal(double& x,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
153 double& y,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
154 Corner corner,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
155 unsigned int cropX,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
156 unsigned int cropY,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
157 unsigned int cropWidth,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
158 unsigned int cropHeight) const
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
159 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
160 double dx = static_cast<double>(cropX);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
161 double dy = static_cast<double>(cropY);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
162 double dwidth = static_cast<double>(cropWidth);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
163 double dheight = static_cast<double>(cropHeight);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
164
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
165 switch (corner)
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
166 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
167 case Corner_TopLeft:
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
168 x = dx;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
169 y = dy;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
170 break;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
171
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
172 case Corner_TopRight:
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
173 x = dx + dwidth;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
174 y = dy;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
175 break;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
176
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
177 case Corner_BottomLeft:
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
178 x = dx;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
179 y = dy + dheight;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
180 break;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
181
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
182 case Corner_BottomRight:
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
183 x = dx + dwidth;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
184 y = dy + dheight;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
185 break;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
186
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
187 default:
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
188 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
189 }
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
190
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
191 ApplyTransform(x, y, transform_);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
192 }
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
193
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
194
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
195 void SetIndex(size_t index)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
196 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
197 index_ = index;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
198 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
199
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
200
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
201 bool Contains(double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
202 double y) const
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
203 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
204 ApplyTransform(x, y, transformInverse_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
205
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
206 unsigned int cropX, cropY, cropWidth, cropHeight;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
207 GetCrop(cropX, cropY, cropWidth, cropHeight);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
208
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
209 return (x >= cropX && x <= cropX + cropWidth &&
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
210 y >= cropY && y <= cropY + cropHeight);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
211 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
212
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
213
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
214 void DrawBorders(CairoContext& context,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
215 double zoom)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
216 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
217 unsigned int cx, cy, width, height;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
218 GetCrop(cx, cy, width, height);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
219
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
220 double dx = static_cast<double>(cx);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
221 double dy = static_cast<double>(cy);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
222 double dwidth = static_cast<double>(width);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
223 double dheight = static_cast<double>(height);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
224
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
225 cairo_t* cr = context.GetObject();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
226 cairo_set_line_width(cr, 2.0 / zoom);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
227
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
228 double x, y;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
229 x = dx;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
230 y = dy;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
231 ApplyTransform(x, y, transform_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
232 cairo_move_to(cr, x, y);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
233
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
234 x = dx + dwidth;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
235 y = dy;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
236 ApplyTransform(x, y, transform_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
237 cairo_line_to(cr, x, y);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
238
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
239 x = dx + dwidth;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
240 y = dy + dheight;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
241 ApplyTransform(x, y, transform_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
242 cairo_line_to(cr, x, y);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
243
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
244 x = dx;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
245 y = dy + dheight;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
246 ApplyTransform(x, y, transform_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
247 cairo_line_to(cr, x, y);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
248
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
249 x = dx;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
250 y = dy;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
251 ApplyTransform(x, y, transform_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
252 cairo_line_to(cr, x, y);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
253
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
254 cairo_stroke(cr);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
255 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
256
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
257
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
258 static double Square(double x)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
259 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
260 return x * x;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
261 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
262
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
263
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
264 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
265 Layer() :
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
266 index_(0),
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
267 hasSize_(false),
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
268 width_(0),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
269 height_(0),
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
270 hasCrop_(false),
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
271 pixelSpacingX_(1),
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
272 pixelSpacingY_(1),
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
273 panX_(0),
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
274 panY_(0),
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
275 angle_(0),
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
276 resizeable_(false)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
277 {
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
278 UpdateTransform();
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
279 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
280
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
281 virtual ~Layer()
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
282 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
283 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
284
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
285 size_t GetIndex() const
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
286 {
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
287 return index_;
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
288 }
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
289
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
290 void ResetCrop()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
291 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
292 hasCrop_ = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
293 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
294
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
295 void SetCrop(unsigned int x,
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
296 unsigned int y,
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
297 unsigned int width,
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
298 unsigned int height)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
299 {
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
300 if (!hasSize_)
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
301 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
302 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
303 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
304
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
305 if (x + width > width_ ||
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
306 y + height > height_)
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
307 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
308 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
309 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
310
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
311 hasCrop_ = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
312 cropX_ = x;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
313 cropY_ = y;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
314 cropWidth_ = width;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
315 cropHeight_ = height;
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
316
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
317 UpdateTransform();
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
318 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
319
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
320 void GetCrop(unsigned int& x,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
321 unsigned int& y,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
322 unsigned int& width,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
323 unsigned int& height) const
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
324 {
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
325 if (hasCrop_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
326 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
327 x = cropX_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
328 y = cropY_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
329 width = cropWidth_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
330 height = cropHeight_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
331 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
332 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
333 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
334 x = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
335 y = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
336 width = width_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
337 height = height_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
338 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
339 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
340
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
341 void SetAngle(double angle)
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
342 {
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
343 angle_ = angle;
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
344 UpdateTransform();
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
345 }
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
347 double GetAngle() const
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
348 {
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
349 return angle_;
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
350 }
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
351
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
352 void SetSize(unsigned int width,
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
353 unsigned int height)
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
354 {
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
355 if (hasSize_ &&
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
356 (width != width_ ||
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
357 height != height_))
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
358 {
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
359 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize);
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
360 }
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
361
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
362 hasSize_ = true;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
363 width_ = width;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
364 height_ = height;
346
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
365
c2e040ea8fbe rotation transform
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 345
diff changeset
366 UpdateTransform();
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
367 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
368
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
369
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
370 unsigned int GetWidth() const
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
371 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
372 return width_;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
373 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
374
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
375
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
376 unsigned int GetHeight() const
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
377 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
378 return height_;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
379 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
380
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
381
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
382 Extent2D GetExtent() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
383 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
384 Extent2D extent;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
385
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
386 unsigned int x, y, width, height;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
387 GetCrop(x, y, width, height);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
388
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
389 double dx = static_cast<double>(x);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
390 double dy = static_cast<double>(y);
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
391 double dwidth = static_cast<double>(width);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
392 double dheight = static_cast<double>(height);
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
393
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
394 AddToExtent(extent, dx, dy);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
395 AddToExtent(extent, dx + dwidth, dy);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
396 AddToExtent(extent, dx, dy + dheight);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
397 AddToExtent(extent, dx + dwidth, dy + dheight);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
398
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
399 return extent;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
400 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
401
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
402
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
403 bool GetPixel(unsigned int& imageX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
404 unsigned int& imageY,
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
405 double sceneX,
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
406 double sceneY) const
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
407 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
408 if (width_ == 0 ||
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
409 height_ == 0)
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
410 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
411 return false;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
412 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
413 else
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
414 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
415 ApplyTransform(sceneX, sceneY, transformInverse_);
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
416
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
417 int x = static_cast<int>(std::floor(sceneX));
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
418 int y = static_cast<int>(std::floor(sceneY));
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
419
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
420 if (x < 0)
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
421 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
422 imageX = 0;
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
423 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
424 else if (x >= static_cast<int>(width_))
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
425 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
426 imageX = width_;
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
427 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
428 else
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
429 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
430 imageX = static_cast<unsigned int>(x);
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
431 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
432
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
433 if (y < 0)
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
434 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
435 imageY = 0;
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
436 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
437 else if (y >= static_cast<int>(height_))
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
438 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
439 imageY = height_;
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
440 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
441 else
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
442 {
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
443 imageY = static_cast<unsigned int>(y);
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
444 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
445
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
446 return true;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
447 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
448 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
449
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
450
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
451 void SetPan(double x,
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
452 double y)
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
453 {
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
454 panX_ = x;
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
455 panY_ = y;
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
456 UpdateTransform();
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
457 }
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
458
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
459
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
460 void SetPixelSpacing(double x,
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
461 double y)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
462 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
463 pixelSpacingX_ = x;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
464 pixelSpacingY_ = y;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
465 UpdateTransform();
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
466 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
467
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
468 double GetPixelSpacingX() const
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
469 {
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
470 return pixelSpacingX_;
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
471 }
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
472
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
473 double GetPixelSpacingY() const
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
474 {
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
475 return pixelSpacingY_;
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
476 }
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
477
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
478 double GetPanX() const
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
479 {
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
480 return panX_;
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
481 }
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
482
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
483 double GetPanY() const
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
484 {
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
485 return panY_;
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
486 }
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
487
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
488 void GetCenter(double& centerX,
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
489 double& centerY) const
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
490 {
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
491 centerX = static_cast<double>(width_) / 2.0;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
492 centerY = static_cast<double>(height_) / 2.0;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
493 ApplyTransform(centerX, centerY, transform_);
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
494 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
495
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
496
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
497 void GetCorner(double& x /* out */,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
498 double& y /* out */,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
499 Corner corner) const
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
500 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
501 unsigned int cropX, cropY, cropWidth, cropHeight;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
502 GetCrop(cropX, cropY, cropWidth, cropHeight);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
503 GetCornerInternal(x, y, corner, cropX, cropY, cropWidth, cropHeight);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
504 }
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
505
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
506
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
507 bool LookupCorner(Corner& corner /* out */,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
508 double x,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
509 double y,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
510 double zoom,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
511 double viewportDistance) const
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
512 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
513 static const Corner CORNERS[] = {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
514 Corner_TopLeft,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
515 Corner_TopRight,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
516 Corner_BottomLeft,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
517 Corner_BottomRight
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
518 };
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
519
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
520 unsigned int cropX, cropY, cropWidth, cropHeight;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
521 GetCrop(cropX, cropY, cropWidth, cropHeight);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
522
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
523 double threshold = Square(viewportDistance / zoom);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
524
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
525 for (size_t i = 0; i < 4; i++)
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
526 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
527 double cx, cy;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
528 GetCornerInternal(cx, cy, CORNERS[i], cropX, cropY, cropWidth, cropHeight);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
529
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
530 double d = Square(cx - x) + Square(cy - y);
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
531
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
532 if (d <= threshold)
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
533 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
534 corner = CORNERS[i];
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
535 return true;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
536 }
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
537 }
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
538
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
539 return false;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
540 }
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
541
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
542 bool IsResizeable() const
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
543 {
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
544 return resizeable_;
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
545 }
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
546
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
547 void SetResizeable(bool resizeable)
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
548 {
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
549 resizeable_ = resizeable;
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
550 }
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
551
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
552 virtual bool GetDefaultWindowing(float& center,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
553 float& width) const = 0;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
554
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
555 virtual void Render(Orthanc::ImageAccessor& buffer,
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
556 const Matrix& viewTransform,
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
557 ImageInterpolation interpolation) const = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
558
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
559 virtual bool GetRange(float& minValue,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
560 float& maxValue) const = 0;
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
561 };
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
562
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
563
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
564 class LayerAccessor : public boost::noncopyable
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
565 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
566 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
567 RadiologyScene& scene_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
568 size_t index_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
569 Layer* layer_;
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
570
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
571 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
572 LayerAccessor(RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
573 size_t index) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
574 scene_(scene),
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
575 index_(index)
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
576 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
577 Layers::iterator layer = scene.layers_.find(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
578 if (layer == scene.layers_.end())
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
579 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
580 layer_ = NULL;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
581 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
582 else
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
583 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
584 assert(layer->second != NULL);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
585 layer_ = layer->second;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
586 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
587 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
588
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
589 LayerAccessor(RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
590 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
591 double y) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
592 scene_(scene),
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
593 index_(0) // Dummy initialization
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
594 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
595 if (scene.LookupLayer(index_, x, y))
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
596 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
597 Layers::iterator layer = scene.layers_.find(index_);
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
598
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
599 if (layer == scene.layers_.end())
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
600 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
601 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
602 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
603 else
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
604 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
605 assert(layer->second != NULL);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
606 layer_ = layer->second;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
607 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
608 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
609 else
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
610 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
611 layer_ = NULL;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
612 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
613 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
614
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
615 void Invalidate()
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
616 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
617 layer_ = NULL;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
618 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
619
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
620 bool IsValid() const
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
621 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
622 return layer_ != NULL;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
623 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
624
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
625 RadiologyScene& GetScene() const
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
626 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
627 if (IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
628 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
629 return scene_;
354
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 else
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
634 }
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
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
637 size_t GetIndex() const
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
638 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
639 if (IsValid())
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
640 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
641 return index_;
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
642 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
643 else
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
644 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
645 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
646 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
647 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
648
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
649 Layer& GetLayer() const
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
650 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
651 if (IsValid())
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
652 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
653 return *layer_;
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
654 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
655 else
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
656 {
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
657 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
658 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
659 }
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
660 };
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
661
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
662
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
663 private:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
664 class AlphaLayer : public Layer
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
665 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
666 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
667 const RadiologyScene& scene_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
668 std::auto_ptr<Orthanc::ImageAccessor> alpha_; // Grayscale8
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
669 bool useWindowing_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
670 float foreground_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
671
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
672 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
673 AlphaLayer(const RadiologyScene& scene) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
674 scene_(scene),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
675 useWindowing_(true),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
676 foreground_(0)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
677 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
678 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
679
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
680
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
681 void SetForegroundValue(float foreground)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
682 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
683 useWindowing_ = false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
684 foreground_ = foreground;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
685 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
686
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
687
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
688 void SetAlpha(Orthanc::ImageAccessor* image)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
689 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
690 std::auto_ptr<Orthanc::ImageAccessor> raii(image);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
691
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
692 if (image == NULL)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
693 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
694 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
695 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
696
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
697 if (image->GetFormat() != Orthanc::PixelFormat_Grayscale8)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
698 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
699 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
700 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
701
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
702 SetSize(image->GetWidth(), image->GetHeight());
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
703 alpha_ = raii;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
704 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
705
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
706
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
707 void LoadText(const Orthanc::Font& font,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
708 const std::string& utf8)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
709 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
710 SetAlpha(font.RenderAlpha(utf8));
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
711 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
712
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
713
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
714 virtual bool GetDefaultWindowing(float& center,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
715 float& width) const
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
716 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
717 return false;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
718 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
719
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
720
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
721 virtual void Render(Orthanc::ImageAccessor& buffer,
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
722 const Matrix& viewTransform,
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
723 ImageInterpolation interpolation) const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
724 {
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
725 if (alpha_.get() == NULL)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
726 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
727 return;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
728 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
729
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
730 if (buffer.GetFormat() != Orthanc::PixelFormat_Float32)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
731 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
732 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
733 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
734
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
735 unsigned int cropX, cropY, cropWidth, cropHeight;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
736 GetCrop(cropX, cropY, cropWidth, cropHeight);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
737
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
738 Matrix m = LinearAlgebra::Product(viewTransform,
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
739 GetTransform(),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
740 CreateOffsetMatrix(cropX, cropY));
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
741
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
742 Orthanc::ImageAccessor cropped;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
743 alpha_->GetRegion(cropped, cropX, cropY, cropWidth, cropHeight);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
744
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
745 Orthanc::Image tmp(Orthanc::PixelFormat_Grayscale8, buffer.GetWidth(), buffer.GetHeight(), false);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
746 ApplyProjectiveTransform(tmp, cropped, m, interpolation, true /* clear */);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
747
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
748 // Blit
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
749 const unsigned int width = buffer.GetWidth();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
750 const unsigned int height = buffer.GetHeight();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
751
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
752 float value = foreground_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
753
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
754 if (useWindowing_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
755 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
756 float center, width;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
757 if (scene_.GetWindowing(center, width))
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
758 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
759 value = center + width / 2.0f;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
760 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
761 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
762
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
763 for (unsigned int y = 0; y < height; y++)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
764 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
765 float *q = reinterpret_cast<float*>(buffer.GetRow(y));
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
766 const uint8_t *p = reinterpret_cast<uint8_t*>(tmp.GetRow(y));
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
767
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
768 for (unsigned int x = 0; x < width; x++, p++, q++)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
769 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
770 float a = static_cast<float>(*p) / 255.0f;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
771
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
772 *q = (a * value + (1.0f - a) * (*q));
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
773 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
774 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
775 }
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
776
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
777
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
778 virtual bool GetRange(float& minValue,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
779 float& maxValue) const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
780 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
781 if (useWindowing_)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
782 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
783 return false;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
784 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
785 else
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
786 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
787 minValue = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
788 maxValue = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
789
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
790 if (foreground_ < 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
791 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
792 minValue = foreground_;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
793 }
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 if (foreground_ > 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
796 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
797 maxValue = foreground_;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
798 }
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 return true;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
801 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
802 }
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
803 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
804
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
805
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
806
347
cd65103c9172 RotateBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 346
diff changeset
807 private:
392
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
808 static Matrix CreateOffsetMatrix(double dx,
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
809 double dy)
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
810 {
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
811 Matrix m = LinearAlgebra::IdentityMatrix(3);
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
812 m(0, 2) = dx;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
813 m(1, 2) = dy;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
814 return m;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
815 }
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
816
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
817
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
818 static Matrix CreateScalingMatrix(double sx,
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
819 double sy)
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
820 {
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
821 Matrix m = LinearAlgebra::IdentityMatrix(3);
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
822 m(0, 0) = sx;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
823 m(1, 1) = sy;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
824 return m;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
825 }
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
826
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
827
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
828 static Matrix CreateRotationMatrix(double angle)
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
829 {
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
830 Matrix m;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
831 const double v[] = { cos(angle), -sin(angle), 0,
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
832 sin(angle), cos(angle), 0,
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
833 0, 0, 1 };
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
834 LinearAlgebra::FillMatrix(m, 3, 3, v);
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
835 return m;
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
836 }
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
837
d87fe075d31b to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 384
diff changeset
838
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
839 class DicomLayer : public Layer
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
840 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
841 private:
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
842 std::auto_ptr<Orthanc::ImageAccessor> source_; // Content of PixelData
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
843 std::auto_ptr<DicomFrameConverter> converter_;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
844 std::auto_ptr<Orthanc::ImageAccessor> converted_; // Float32
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
845
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
846 static OrthancPlugins::DicomTag ConvertTag(const Orthanc::DicomTag& tag)
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
847 {
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
848 return OrthancPlugins::DicomTag(tag.GetGroup(), tag.GetElement());
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
849 }
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
850
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
851
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
852 void ApplyConverter()
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
853 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
854 if (source_.get() != NULL &&
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
855 converter_.get() != NULL)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
856 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
857 converted_.reset(converter_->ConvertFrame(*source_));
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
858 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
859 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
860
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
861 public:
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
862 void SetDicomTags(const OrthancPlugins::FullOrthancDataset& dataset)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
863 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
864 converter_.reset(new DicomFrameConverter);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
865 converter_->ReadParameters(dataset);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
866 ApplyConverter();
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
867
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
868 std::string tmp;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
869 Vector pixelSpacing;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
870
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
871 if (dataset.GetStringValue(tmp, ConvertTag(Orthanc::DICOM_TAG_PIXEL_SPACING)) &&
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
872 LinearAlgebra::ParseVector(pixelSpacing, tmp) &&
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
873 pixelSpacing.size() == 2)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
874 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
875 SetPixelSpacing(pixelSpacing[0], pixelSpacing[1]);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
876 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
877
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
878 //SetPan(-0.5 * GetPixelSpacingX(), -0.5 * GetPixelSpacingY());
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
879
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
880 OrthancPlugins::DicomDatasetReader reader(dataset);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
881
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
882 unsigned int width, height;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
883 if (!reader.GetUnsignedIntegerValue(width, ConvertTag(Orthanc::DICOM_TAG_COLUMNS)) ||
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
884 !reader.GetUnsignedIntegerValue(height, ConvertTag(Orthanc::DICOM_TAG_ROWS)))
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
885 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
886 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
887 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
888 else
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
889 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
890 SetSize(width, height);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
891 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
892 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
893
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
894
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
895 void SetSourceImage(Orthanc::ImageAccessor* image) // Takes ownership
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
896 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
897 std::auto_ptr<Orthanc::ImageAccessor> raii(image);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
898
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
899 if (image == NULL)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
900 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
901 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
902 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
903
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
904 SetSize(image->GetWidth(), image->GetHeight());
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
905
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
906 source_ = raii;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
907 ApplyConverter();
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
908 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
909
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
910
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
911 virtual void Render(Orthanc::ImageAccessor& buffer,
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
912 const Matrix& viewTransform,
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
913 ImageInterpolation interpolation) const
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
914 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
915 if (converted_.get() != NULL)
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
916 {
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
917 if (converted_->GetFormat() != Orthanc::PixelFormat_Float32)
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
918 {
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
919 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
920 }
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
921
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
922 unsigned int cropX, cropY, cropWidth, cropHeight;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
923 GetCrop(cropX, cropY, cropWidth, cropHeight);
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
924
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
925 Matrix m = LinearAlgebra::Product(viewTransform,
351
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
926 GetTransform(),
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
927 CreateOffsetMatrix(cropX, cropY));
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
928
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
929 Orthanc::ImageAccessor cropped;
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
930 converted_->GetRegion(cropped, cropX, cropY, cropWidth, cropHeight);
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
931
da25d2423314 CornerBitmapTracker to crop images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 350
diff changeset
932 ApplyProjectiveTransform(buffer, cropped, m, interpolation, false);
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
933 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
934 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
935
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
936
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
937 virtual bool GetDefaultWindowing(float& center,
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
938 float& width) const
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
939 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
940 if (converter_.get() != NULL &&
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
941 converter_->HasDefaultWindow())
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
942 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
943 center = static_cast<float>(converter_->GetDefaultWindowCenter());
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
944 width = static_cast<float>(converter_->GetDefaultWindowWidth());
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
945 return true;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
946 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
947 else
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
948 {
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
949 return false;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
950 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
951 }
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
952
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
953
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
954 virtual bool GetRange(float& minValue,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
955 float& maxValue) const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
956 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
957 if (converted_.get() != NULL)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
958 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
959 if (converted_->GetFormat() != Orthanc::PixelFormat_Float32)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
960 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
961 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
962 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
963
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
964 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, *converted_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
965 return true;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
966 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
967 else
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
968 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
969 return false;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
970 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
971 }
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
972 };
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
973
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
974
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
975
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
976
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
977 typedef std::map<size_t, Layer*> Layers;
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
978
341
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
979 OrthancApiClient& orthanc_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
980 size_t countLayers_;
341
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
981 bool hasWindowing_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
982 float windowingCenter_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
983 float windowingWidth_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
984 Layers layers_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
985
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
986
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
987 Layer& RegisterLayer(Layer* layer)
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 if (layer == 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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
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
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
994 std::auto_ptr<Layer> raii(layer);
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 size_t index = countLayers_++;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
997 raii->SetIndex(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
998 layers_[index] = raii.release();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
999
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1000 EmitMessage(GeometryChangedMessage(*this));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1001 EmitMessage(ContentChangedMessage(*this));
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 return *layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1004 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1005
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1006
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1007 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1008 RadiologyScene(MessageBroker& broker,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1009 OrthancApiClient& orthanc) :
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1010 IObserver(broker),
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1011 IObservable(broker),
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1012 orthanc_(orthanc),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1013 countLayers_(0),
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1014 hasWindowing_(false),
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1015 windowingCenter_(0), // Dummy initialization
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1016 windowingWidth_(0) // Dummy initialization
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1017 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1018 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1019
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1020
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1021 virtual ~RadiologyScene()
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1022 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1023 for (Layers::iterator it = layers_.begin(); it != layers_.end(); it++)
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1024 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1025 assert(it->second != NULL);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1026 delete it->second;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1027 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1028 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1029
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1030
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1031 bool GetWindowing(float& center,
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1032 float& width) const
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1033 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1034 if (hasWindowing_)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1035 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1036 center = windowingCenter_;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1037 width = windowingWidth_;
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1038 return true;
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1039 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1040 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1041 {
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1042 return false;
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1043 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1044 }
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1045
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1046
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1047 void GetWindowingWithDefault(float& center,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1048 float& width) const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1049 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1050 if (!GetWindowing(center, width))
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1051 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1052 center = 128;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1053 width = 256;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1054 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1055 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1056
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1057
350
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1058 void SetWindowing(float center,
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1059 float width)
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1060
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1061 {
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1062 hasWindowing_ = true;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1063 windowingCenter_ = center;
c57e049ed079 drawing corners for cropping
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 348
diff changeset
1064 windowingWidth_ = width;
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1065 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1066
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1067
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1068 Layer& LoadText(const Orthanc::Font& font,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1069 const std::string& utf8)
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1070 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1071 std::auto_ptr<AlphaLayer> alpha(new AlphaLayer(*this));
352
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
1072 alpha->LoadText(font, utf8);
d95e65ebe0b9 ResizeBitmapTracker
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 351
diff changeset
1073
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1074 return RegisterLayer(alpha.release());
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1075 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1076
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1077
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1078 Layer& LoadTestBlock(unsigned int width,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1079 unsigned int height)
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1080 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1081 std::auto_ptr<Orthanc::Image> block(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, width, height, false));
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1082
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1083 for (unsigned int padding = 0;
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1084 (width > 2 * padding) && (height > 2 * padding);
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1085 padding++)
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1086 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1087 uint8_t color;
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1088 if (255 > 10 * padding)
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1089 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1090 color = 255 - 10 * padding;
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1091 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1092 else
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1093 {
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1094 color = 0;
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1095 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1096
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1097 Orthanc::ImageAccessor region;
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1098 block->GetRegion(region, padding, padding, width - 2 * padding, height - 2 * padding);
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1099 Orthanc::ImageProcessing::Set(region, color);
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1100 }
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1101
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1102 std::auto_ptr<AlphaLayer> alpha(new AlphaLayer(*this));
348
dadee0f7f1b3 testing crop
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 347
diff changeset
1103 alpha->SetAlpha(block.release());
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1104
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1105 return RegisterLayer(alpha.release());
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1106 }
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1107
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
1108
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1109 Layer& LoadDicomFrame(const std::string& instance,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1110 unsigned int frame,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1111 bool httpCompression)
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1112 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1113 Layer& layer = RegisterLayer(new DicomLayer);
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1114
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1115 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1116 IWebService::Headers headers;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1117 std::string uri = "/instances/" + instance + "/tags";
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1118 orthanc_.GetBinaryAsync(uri, headers,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1119 new Callable<RadiologyScene, OrthancApiClient::BinaryResponseReadyMessage>
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1120 (*this, &RadiologyScene::OnTagsReceived), NULL,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1121 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1122 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1123
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1124 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1125 IWebService::Headers headers;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1126 headers["Accept"] = "image/x-portable-arbitrarymap";
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1127
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1128 if (httpCompression)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1129 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1130 headers["Accept-Encoding"] = "gzip";
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1131 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1132
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1133 std::string uri = "/instances/" + instance + "/frames/" + boost::lexical_cast<std::string>(frame) + "/image-uint16";
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1134 orthanc_.GetBinaryAsync(uri, headers,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1135 new Callable<RadiologyScene, OrthancApiClient::BinaryResponseReadyMessage>
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1136 (*this, &RadiologyScene::OnFrameReceived), NULL,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1137 new Orthanc::SingleValueObject<size_t>(layer.GetIndex()));
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1138 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1139
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1140 return layer;
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1141 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1142
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1143
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1144 void OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1145 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1146 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>(message.GetPayload()).GetValue();
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1147
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1148 LOG(INFO) << "JSON received: " << message.GetUri().c_str()
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1149 << " (" << message.GetAnswerSize() << " bytes) for layer " << index;
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1150
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1151 Layers::iterator layer = layers_.find(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1152 if (layer != layers_.end())
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1153 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1154 assert(layer->second != NULL);
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1155
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1156 OrthancPlugins::FullOrthancDataset dicom(message.GetAnswer(), message.GetAnswerSize());
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1157 dynamic_cast<DicomLayer*>(layer->second)->SetDicomTags(dicom);
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1158
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1159 float c, w;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1160 if (!hasWindowing_ &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1161 layer->second->GetDefaultWindowing(c, w))
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1162 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1163 hasWindowing_ = true;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1164 windowingCenter_ = c;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1165 windowingWidth_ = w;
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1166 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1167
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1168 EmitMessage(GeometryChangedMessage(*this));
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1169 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1170 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1171
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1172
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1173 void OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message)
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1174 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1175 size_t index = dynamic_cast<const Orthanc::SingleValueObject<size_t>&>(message.GetPayload()).GetValue();
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1176
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1177 LOG(INFO) << "DICOM frame received: " << message.GetUri().c_str()
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1178 << " (" << message.GetAnswerSize() << " bytes) for layer " << index;
341
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
1179
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1180 Layers::iterator layer = layers_.find(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1181 if (layer != layers_.end())
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1182 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1183 assert(layer->second != NULL);
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1184
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1185 std::string content;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1186 if (message.GetAnswerSize() > 0)
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1187 {
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
1188 content.assign(reinterpret_cast<const char*>(message.GetAnswer()), message.GetAnswerSize());
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1189 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1190
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1191 std::auto_ptr<Orthanc::PamReader> reader(new Orthanc::PamReader);
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1192 reader->ReadFromMemory(content);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1193 dynamic_cast<DicomLayer*>(layer->second)->SetSourceImage(reader.release());
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1194
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1195 EmitMessage(ContentChangedMessage(*this));
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1196 }
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1197 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1198
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1199
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1200 Extent2D GetSceneExtent() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1201 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1202 Extent2D extent;
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
1203
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1204 for (Layers::const_iterator it = layers_.begin();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1205 it != layers_.end(); ++it)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1206 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1207 assert(it->second != NULL);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1208 extent.Union(it->second->GetExtent());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1209 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1210
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1211 return extent;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1212 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1213
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1214
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1215 void Render(Orthanc::ImageAccessor& buffer,
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
1216 const Matrix& viewTransform,
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1217 ImageInterpolation interpolation) const
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1218 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1219 Orthanc::ImageProcessing::Set(buffer, 0);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1220
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1221 // Render layers in the background-to-foreground order
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1222 for (size_t index = 0; index < countLayers_; index++)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1223 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1224 Layers::const_iterator it = layers_.find(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1225 if (it != layers_.end())
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1226 {
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1227 assert(it->second != NULL);
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
1228 it->second->Render(buffer, viewTransform, interpolation);
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1229 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1230 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
1231 }
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1232
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1233
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1234 bool LookupLayer(size_t& index /* out */,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1235 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1236 double y) const
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1237 {
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1238 // Render layers in the foreground-to-background order
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1239 for (size_t i = countLayers_; i > 0; i--)
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1240 {
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1241 index = i - 1;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1242 Layers::const_iterator it = layers_.find(index);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1243 if (it != layers_.end())
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1244 {
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1245 assert(it->second != NULL);
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1246 if (it->second->Contains(x, y))
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1247 {
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1248 return true;
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
1249 }
342
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1250 }
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1251 }
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1252
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1253 return false;
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1254 }
4297d6c5eef9 moving bitmap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 341
diff changeset
1255
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1256
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1257 void DrawBorder(CairoContext& context,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1258 unsigned int layer,
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1259 double zoom)
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1260 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1261 Layers::const_iterator found = layers_.find(layer);
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1262
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1263 if (found != layers_.end())
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1264 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1265 context.SetSourceColor(255, 0, 0);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1266 found->second->DrawBorders(context, zoom);
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1267 }
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
1268 }
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1269
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1270
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1271 void GetRange(float& minValue,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1272 float& maxValue) const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1273 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1274 bool first = true;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1275
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1276 for (Layers::const_iterator it = layers_.begin();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1277 it != layers_.end(); it++)
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1278 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1279 assert(it->second != NULL);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1280
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1281 float a, b;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1282 if (it->second->GetRange(a, b))
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1283 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1284 if (first)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1285 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1286 minValue = a;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1287 maxValue = b;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1288 first = false;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1289 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1290 else
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1291 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1292 minValue = std::min(a, minValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1293 maxValue = std::max(b, maxValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1294 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1295 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1296 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1297
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1298 if (first)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1299 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1300 minValue = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1301 maxValue = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1302 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
1303 }
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1304
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1305
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1306 // Export using PAM is faster than using PNG, but requires Orthanc
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1307 // core >= 1.4.3
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1308 void Export(const Orthanc::DicomMap& dicom,
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1309 double pixelSpacingX,
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1310 double pixelSpacingY,
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1311 bool invert,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1312 ImageInterpolation interpolation,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1313 bool usePam)
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1314 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1315 if (pixelSpacingX <= 0 ||
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1316 pixelSpacingY <= 0)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1317 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1318 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1319 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1320
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1321 LOG(INFO) << "Exporting DICOM";
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1322
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1323 Extent2D extent = GetSceneExtent();
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1324
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1325 int w = std::ceil(extent.GetWidth() / pixelSpacingX);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1326 int h = std::ceil(extent.GetHeight() / pixelSpacingY);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1327
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1328 if (w < 0 || h < 0)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1329 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1330 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1331 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1332
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1333 Orthanc::Image layers(Orthanc::PixelFormat_Float32,
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1334 static_cast<unsigned int>(w),
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1335 static_cast<unsigned int>(h), false);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1336
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1337 Matrix view = LinearAlgebra::Product(
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1338 CreateScalingMatrix(1.0 / pixelSpacingX, 1.0 / pixelSpacingY),
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1339 CreateOffsetMatrix(-extent.GetX1(), -extent.GetY1()));
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1340
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1341 Render(layers, view, interpolation);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1342
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1343 Orthanc::Image rendered(Orthanc::PixelFormat_Grayscale16,
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1344 layers.GetWidth(), layers.GetHeight(), false);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1345 Orthanc::ImageProcessing::Convert(rendered, layers);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1346
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1347 std::string base64;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1348
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1349 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1350 std::string content;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1351
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1352 if (usePam)
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1353 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1354 Orthanc::PamWriter writer;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1355 writer.WriteToMemory(content, rendered);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1356 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1357 else
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1358 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1359 Orthanc::PngWriter writer;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1360 writer.WriteToMemory(content, rendered);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1361 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1362
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1363 Orthanc::Toolbox::EncodeBase64(base64, content);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1364 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1365
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1366 std::set<Orthanc::DicomTag> tags;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1367 dicom.GetTags(tags);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1368
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1369 Json::Value json = Json::objectValue;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1370 json["Tags"] = Json::objectValue;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1371
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1372 for (std::set<Orthanc::DicomTag>::const_iterator
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1373 tag = tags.begin(); tag != tags.end(); ++tag)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1374 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1375 const Orthanc::DicomValue& value = dicom.GetValue(*tag);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1376 if (!value.IsNull() &&
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1377 !value.IsBinary())
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1378 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1379 json["Tags"][tag->Format()] = value.GetContent();
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1380 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1381 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1382
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1383 json["Tags"][Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION.Format()] =
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1384 (invert ? "MONOCHROME1" : "MONOCHROME2");
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1385
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1386 // WARNING: The order of PixelSpacing is Y/X. We use "%0.8f" to
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1387 // avoid floating-point numbers to grow over 16 characters,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1388 // which would be invalid according to DICOM standard
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1389 // ("dciodvfy" would complain).
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1390 char buf[32];
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1391 sprintf(buf, "%0.8f\\%0.8f", pixelSpacingY, pixelSpacingX);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1392
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1393 json["Tags"][Orthanc::DICOM_TAG_PIXEL_SPACING.Format()] = buf;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1394
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1395 float center, width;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1396 if (GetWindowing(center, width))
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1397 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1398 json["Tags"][Orthanc::DICOM_TAG_WINDOW_CENTER.Format()] =
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1399 boost::lexical_cast<std::string>(boost::math::iround(center));
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1400
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1401 json["Tags"][Orthanc::DICOM_TAG_WINDOW_WIDTH.Format()] =
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1402 boost::lexical_cast<std::string>(boost::math::iround(width));
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1403 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1404
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1405 // This is Data URI scheme: https://en.wikipedia.org/wiki/Data_URI_scheme
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1406 json["Content"] = ("data:" +
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1407 std::string(usePam ? Orthanc::MIME_PAM : Orthanc::MIME_PNG) +
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1408 ";base64," + base64);
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1409
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1410 orthanc_.PostJsonAsyncExpectJson(
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1411 "/tools/create-dicom", json,
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1412 new Callable<RadiologyScene, OrthancApiClient::JsonResponseReadyMessage>
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1413 (*this, &RadiologyScene::OnDicomExported),
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1414 NULL, NULL);
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1415 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1416
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1417
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1418 void OnDicomExported(const OrthancApiClient::JsonResponseReadyMessage& message)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1419 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1420 LOG(INFO) << "DICOM export was successful:"
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1421 << message.GetJson().toStyledString();
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
1422 }
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1423 };
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
1424
341
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 340
diff changeset
1425
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1426 class UndoRedoStack : public boost::noncopyable
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1427 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1428 public:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1429 class ICommand : public boost::noncopyable
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1430 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1431 public:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1432 virtual ~ICommand()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1433 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1434 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1435
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1436 virtual void Undo() const = 0;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1437
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1438 virtual void Redo() const = 0;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1439 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1440
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1441 private:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1442 typedef std::list<ICommand*> Stack;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1443
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1444 Stack stack_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1445 Stack::iterator current_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1446
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1447 void Clear(Stack::iterator from)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1448 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1449 for (Stack::iterator it = from; it != stack_.end(); ++it)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1450 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1451 assert(*it != NULL);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1452 delete *it;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1453 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1454
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1455 stack_.erase(from, stack_.end());
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1456 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1457
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1458 public:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1459 UndoRedoStack() :
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1460 current_(stack_.end())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1461 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1462 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1463
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1464 ~UndoRedoStack()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1465 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1466 Clear(stack_.begin());
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1467 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1468
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1469 void Add(ICommand* command)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1470 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1471 if (command == NULL)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1472 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1473 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1474 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1475
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1476 Clear(current_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1477
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1478 stack_.push_back(command);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1479 current_ = stack_.end();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1480 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1481
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1482 void Undo()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1483 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1484 if (current_ != stack_.begin())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1485 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1486 --current_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1487
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1488 assert(*current_ != NULL);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1489 (*current_)->Undo();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1490 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1491 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1492
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1493 void Redo()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1494 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1495 if (current_ != stack_.end())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1496 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1497 assert(*current_ != NULL);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1498 (*current_)->Redo();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1499
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1500 ++current_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1501 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1502 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1503 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1504
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1505
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1506 class RadiologyLayerCommand : public UndoRedoStack::ICommand
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1507 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1508 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1509 RadiologyScene& scene_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1510 size_t layer_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1511
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1512 protected:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1513 virtual void UndoInternal(RadiologyScene::Layer& layer) const = 0;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1514
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1515 virtual void RedoInternal(RadiologyScene::Layer& layer) const = 0;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1516
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1517 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1518 RadiologyLayerCommand(RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1519 size_t layer) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1520 scene_(scene),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1521 layer_(layer)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1522 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1523 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1524
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1525 RadiologyLayerCommand(const RadiologyScene::LayerAccessor& accessor) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1526 scene_(accessor.GetScene()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1527 layer_(accessor.GetIndex())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1528 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1529 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1530
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1531 virtual void Undo() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1532 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1533 RadiologyScene::LayerAccessor accessor(scene_, layer_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1534
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1535 if (accessor.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1536 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1537 UndoInternal(accessor.GetLayer());
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1538 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1539 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1540
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1541 virtual void Redo() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1542 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1543 RadiologyScene::LayerAccessor accessor(scene_, layer_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1544
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1545 if (accessor.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1546 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1547 RedoInternal(accessor.GetLayer());
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1548 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1549 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1550 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1551
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1552
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1553 class RadiologyLayerRotateTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1554 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1555 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1556 UndoRedoStack& undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1557 RadiologyScene::LayerAccessor accessor_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1558 double centerX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1559 double centerY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1560 double originalAngle_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1561 double clickAngle_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1562 bool roundAngles_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1563
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1564 bool ComputeAngle(double& angle /* out */,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1565 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1566 double sceneY) const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1567 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1568 Vector u;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1569 LinearAlgebra::AssignVector(u, sceneX - centerX_, sceneY - centerY_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1570
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1571 double nu = boost::numeric::ublas::norm_2(u);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1572
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1573 if (!LinearAlgebra::IsCloseToZero(nu))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1574 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1575 u /= nu;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1576 angle = atan2(u[1], u[0]);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1577 return true;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1578 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1579 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1580 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1581 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1582 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1583 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1584
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1585
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1586 class UndoRedoCommand : public RadiologyLayerCommand
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1587 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1588 private:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1589 double sourceAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1590 double targetAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1591
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1592 static int ToDegrees(double angle)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1593 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
1594 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
1595 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1596
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1597 protected:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1598 virtual void UndoInternal(RadiologyScene::Layer& layer) const
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1599 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1600 LOG(INFO) << "Undo - Set angle to " << ToDegrees(sourceAngle_) << " degrees";
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1601 layer.SetAngle(sourceAngle_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1602 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1603
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1604 virtual void RedoInternal(RadiologyScene::Layer& layer) const
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1605 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1606 LOG(INFO) << "Redo - Set angle to " << ToDegrees(sourceAngle_) << " degrees";
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1607 layer.SetAngle(targetAngle_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1608 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1609
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1610 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1611 UndoRedoCommand(const RadiologyLayerRotateTracker& tracker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1612 RadiologyLayerCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1613 sourceAngle_(tracker.originalAngle_),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1614 targetAngle_(tracker.accessor_.GetLayer().GetAngle())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1615 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1616 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1617 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1618
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1619
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1620 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1621 RadiologyLayerRotateTracker(UndoRedoStack& undoRedoStack,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1622 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1623 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1624 size_t layer,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1625 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1626 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1627 bool roundAngles) :
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1628 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1629 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1630 roundAngles_(roundAngles)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1631 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1632 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1633 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1634 accessor_.GetLayer().GetCenter(centerX_, centerY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1635 originalAngle_ = accessor_.GetLayer().GetAngle();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1636
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1637 double sceneX, sceneY;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1638 view.MapDisplayToScene(sceneX, sceneY, x, y);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1639
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1640 if (!ComputeAngle(clickAngle_, x, y))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1641 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1642 accessor_.Invalidate();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1643 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1644 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1645 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1646
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1647 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1648 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1649 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1650 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1651
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1652 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1653 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1654 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1655 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1656 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1657
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1658 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1659 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1660 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1661 {
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1662 undoRedoStack_.Add(new UndoRedoCommand(*this));
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1663 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1664 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1665
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1666 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1667 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1668 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1669 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1670 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1671 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
1672
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1673 double angle;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1674
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1675 if (accessor_.IsValid() &&
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1676 ComputeAngle(angle, sceneX, sceneY))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1677 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1678 angle = angle - clickAngle_ + originalAngle_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1679
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1680 if (roundAngles_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1681 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
1682 angle = boost::math::round<double>((angle / ROUND_ANGLE) * ROUND_ANGLE);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1683 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1684
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1685 accessor_.GetLayer().SetAngle(angle);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1686 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1687 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1688 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1689
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1690
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1691 class RadiologyLayerMoveTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1692 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1693 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1694 UndoRedoStack& undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1695 RadiologyScene::LayerAccessor accessor_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1696 double clickX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1697 double clickY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1698 double panX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1699 double panY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1700 bool oneAxis_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1701
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1702 class UndoRedoCommand : public RadiologyLayerCommand
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1703 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1704 private:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1705 double sourceX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1706 double sourceY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1707 double targetX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1708 double targetY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1709
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1710 protected:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1711 virtual void UndoInternal(RadiologyScene::Layer& layer) const
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1712 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1713 layer.SetPan(sourceX_, sourceY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1714 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1715
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1716 virtual void RedoInternal(RadiologyScene::Layer& layer) const
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1717 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1718 layer.SetPan(targetX_, targetY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1719 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1720
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1721 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1722 UndoRedoCommand(const RadiologyLayerMoveTracker& tracker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1723 RadiologyLayerCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1724 sourceX_(tracker.panX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1725 sourceY_(tracker.panY_),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1726 targetX_(tracker.accessor_.GetLayer().GetPanX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1727 targetY_(tracker.accessor_.GetLayer().GetPanY())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1728 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1729 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1730 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1731
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1732
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1733 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1734 RadiologyLayerMoveTracker(UndoRedoStack& undoRedoStack,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1735 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1736 size_t layer,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1737 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1738 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1739 bool oneAxis) :
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1740 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1741 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1742 clickX_(x),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1743 clickY_(y),
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1744 oneAxis_(oneAxis)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1745 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1746 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1747 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1748 panX_ = accessor_.GetLayer().GetPanX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1749 panY_ = accessor_.GetLayer().GetPanY();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1750 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1751 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1752
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1753 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1754 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1755 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1756 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1757
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1758 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1759 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1760 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1761 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1762 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1763
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1764 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1765 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1766 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1767 {
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1768 undoRedoStack_.Add(new UndoRedoCommand(*this));
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1769 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1770 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1771
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1772 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1773 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1774 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1775 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1776 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1777 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1778 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1779 double dx = sceneX - clickX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1780 double dy = sceneY - clickY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1781
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1782 if (oneAxis_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1783 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1784 if (fabs(dx) > fabs(dy))
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1785 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1786 accessor_.GetLayer().SetPan(dx + panX_, panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1787 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1788 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1789 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1790 accessor_.GetLayer().SetPan(panX_, dy + panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1791 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1792 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1793 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1794 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1795 accessor_.GetLayer().SetPan(dx + panX_, dy + panY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1796 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1797 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1798 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1799 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1800
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1801
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1802 class RadiologyLayerCropTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1803 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1804 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1805 UndoRedoStack& undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1806 RadiologyScene::LayerAccessor accessor_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1807 RadiologyScene::Corner corner_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1808 unsigned int cropX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1809 unsigned int cropY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1810 unsigned int cropWidth_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1811 unsigned int cropHeight_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1812
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1813 class UndoRedoCommand : public RadiologyLayerCommand
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1814 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1815 private:
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1816 unsigned int sourceCropX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1817 unsigned int sourceCropY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1818 unsigned int sourceCropWidth_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1819 unsigned int sourceCropHeight_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1820 unsigned int targetCropX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1821 unsigned int targetCropY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1822 unsigned int targetCropWidth_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1823 unsigned int targetCropHeight_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1824
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1825 protected:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1826 virtual void UndoInternal(RadiologyScene::Layer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1827 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1828 layer.SetCrop(sourceCropX_, sourceCropY_, sourceCropWidth_, sourceCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1829 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1830
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1831 virtual void RedoInternal(RadiologyScene::Layer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1832 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1833 layer.SetCrop(targetCropX_, targetCropY_, targetCropWidth_, targetCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1834 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1835
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1836 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1837 UndoRedoCommand(const RadiologyLayerCropTracker& tracker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1838 RadiologyLayerCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1839 sourceCropX_(tracker.cropX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1840 sourceCropY_(tracker.cropY_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1841 sourceCropWidth_(tracker.cropWidth_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1842 sourceCropHeight_(tracker.cropHeight_)
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1843 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1844 tracker.accessor_.GetLayer().GetCrop(targetCropX_, targetCropY_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1845 targetCropWidth_, targetCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1846 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1847 };
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1848
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1849
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1850 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1851 RadiologyLayerCropTracker(UndoRedoStack& undoRedoStack,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1852 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1853 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1854 size_t layer,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1855 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1856 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1857 RadiologyScene::Corner corner) :
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1858 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1859 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1860 corner_(corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1861 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1862 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1863 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1864 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1865 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1866 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1867
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1868 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1869 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1870 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1871 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1872
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1873 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1874 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1875 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1876 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1877 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1878
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1879 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1880 {
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1881 if (accessor_.IsValid())
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1882 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1883 undoRedoStack_.Add(new UndoRedoCommand(*this));
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1884 }
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1885 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1886
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1887 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1888 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1889 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1890 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1891 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1892 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1893 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1894 unsigned int x, y;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1895
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1896 RadiologyScene::Layer& layer = accessor_.GetLayer();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1897 if (layer.GetPixel(x, y, sceneX, sceneY))
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1898 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1899 unsigned int targetX, targetWidth;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1900
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1901 if (corner_ == RadiologyScene::Corner_TopLeft ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1902 corner_ == RadiologyScene::Corner_BottomLeft)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1903 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1904 targetX = std::min(x, cropX_ + cropWidth_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1905 targetWidth = cropX_ + cropWidth_ - targetX;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1906 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1907 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1908 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1909 targetX = cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1910 targetWidth = std::max(x, cropX_) - cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1911 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1912
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1913 unsigned int targetY, targetHeight;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1914
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1915 if (corner_ == RadiologyScene::Corner_TopLeft ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1916 corner_ == RadiologyScene::Corner_TopRight)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1917 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1918 targetY = std::min(y, cropY_ + cropHeight_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1919 targetHeight = cropY_ + cropHeight_ - targetY;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1920 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1921 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1922 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1923 targetY = cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1924 targetHeight = std::max(y, cropY_) - cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1925 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1926
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1927 layer.SetCrop(targetX, targetY, targetWidth, targetHeight);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1928 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1929 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1930 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1931 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1932
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1933
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1934 class RadiologyLayerResizeTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1935 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1936 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1937 UndoRedoStack& undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1938 RadiologyScene::LayerAccessor accessor_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1939 bool roundScaling_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1940 double originalSpacingX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1941 double originalSpacingY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1942 double originalPanX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1943 double originalPanY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1944 RadiologyScene::Corner oppositeCorner_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1945 double oppositeX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1946 double oppositeY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1947 double baseScaling_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1948
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1949 static double ComputeDistance(double x1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1950 double y1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1951 double x2,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1952 double y2)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1953 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1954 double dx = x1 - x2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1955 double dy = y1 - y2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1956 return sqrt(dx * dx + dy * dy);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1957 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
1958
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1959 class UndoRedoCommand : public RadiologyLayerCommand
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1960 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1961 private:
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1962 double sourceSpacingX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1963 double sourceSpacingY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1964 double sourcePanX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1965 double sourcePanY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1966 double targetSpacingX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1967 double targetSpacingY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1968 double targetPanX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1969 double targetPanY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1970
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1971 protected:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1972 virtual void UndoInternal(RadiologyScene::Layer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1973 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1974 layer.SetPixelSpacing(sourceSpacingX_, sourceSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1975 layer.SetPan(sourcePanX_, sourcePanY_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1976 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1977
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1978 virtual void RedoInternal(RadiologyScene::Layer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1979 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1980 layer.SetPixelSpacing(targetSpacingX_, targetSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1981 layer.SetPan(targetPanX_, targetPanY_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1982 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1983
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1984 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1985 UndoRedoCommand(const RadiologyLayerResizeTracker& tracker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1986 RadiologyLayerCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1987 sourceSpacingX_(tracker.originalSpacingX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1988 sourceSpacingY_(tracker.originalSpacingY_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1989 sourcePanX_(tracker.originalPanX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1990 sourcePanY_(tracker.originalPanY_),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1991 targetSpacingX_(tracker.accessor_.GetLayer().GetPixelSpacingX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1992 targetSpacingY_(tracker.accessor_.GetLayer().GetPixelSpacingY()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1993 targetPanX_(tracker.accessor_.GetLayer().GetPanX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
1994 targetPanY_(tracker.accessor_.GetLayer().GetPanY())
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1995 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1996 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1997 };
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1998
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
1999
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2000 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2001 RadiologyLayerResizeTracker(UndoRedoStack& undoRedoStack,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2002 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2003 size_t layer,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2004 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2005 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2006 RadiologyScene::Corner corner,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2007 bool roundScaling) :
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
2008 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2009 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2010 roundScaling_(roundScaling)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2011 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2012 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2013 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2014 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2015 originalSpacingX_ = accessor_.GetLayer().GetPixelSpacingX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2016 originalSpacingY_ = accessor_.GetLayer().GetPixelSpacingY();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2017 originalPanX_ = accessor_.GetLayer().GetPanX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2018 originalPanY_ = accessor_.GetLayer().GetPanY();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2019
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2020 switch (corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2021 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2022 case RadiologyScene::Corner_TopLeft:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2023 oppositeCorner_ = RadiologyScene::Corner_BottomRight;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2024 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2025
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2026 case RadiologyScene::Corner_TopRight:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2027 oppositeCorner_ = RadiologyScene::Corner_BottomLeft;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2028 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2029
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2030 case RadiologyScene::Corner_BottomLeft:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2031 oppositeCorner_ = RadiologyScene::Corner_TopRight;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2032 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2033
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2034 case RadiologyScene::Corner_BottomRight:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2035 oppositeCorner_ = RadiologyScene::Corner_TopLeft;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2036 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2037
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2038 default:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2039 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2040 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2041
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2042 accessor_.GetLayer().GetCorner(oppositeX_, oppositeY_, oppositeCorner_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2043
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2044 double d = ComputeDistance(x, y, oppositeX_, oppositeY_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2045 if (d >= std::numeric_limits<float>::epsilon())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2046 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2047 baseScaling_ = 1.0 / d;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2048 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2049 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2050 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2051 // Avoid division by zero in extreme cases
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2052 accessor_.Invalidate();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2053 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2054 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2055 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2056
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2057 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2058 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2059 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2060 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2061
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2062 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2063 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2064 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2065 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2066 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2067
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2068 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2069 {
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2070 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2071 accessor_.GetLayer().IsResizeable())
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
2072 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
2073 undoRedoStack_.Add(new UndoRedoCommand(*this));
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
2074 }
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2075 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2076
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2077 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2078 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2079 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2080 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2081 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2082 static const double ROUND_SCALING = 0.1;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2083
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2084 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2085 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2086 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2087 double scaling = ComputeDistance(oppositeX_, oppositeY_, sceneX, sceneY) * baseScaling_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2088
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2089 if (roundScaling_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2090 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
2091 scaling = boost::math::round<double>((scaling / ROUND_SCALING) * ROUND_SCALING);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2092 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2093
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2094 RadiologyScene::Layer& layer = accessor_.GetLayer();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2095 layer.SetPixelSpacing(scaling * originalSpacingX_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2096 scaling * originalSpacingY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2097
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2098 // Keep the opposite corner at a fixed location
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2099 double ox, oy;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2100 layer.GetCorner(ox, oy, oppositeCorner_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2101 layer.SetPan(layer.GetPanX() + oppositeX_ - ox,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2102 layer.GetPanY() + oppositeY_ - oy);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2103 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2104 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2105 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2106
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2107
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2108 class RadiologyWindowingTracker : public IWorldSceneMouseTracker
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2109 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2110 public:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2111 enum Action
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2112 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2113 Action_IncreaseWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2114 Action_DecreaseWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2115 Action_IncreaseCenter,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2116 Action_DecreaseCenter
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2117 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2118
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2119 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2120 UndoRedoStack& undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2121 RadiologyScene& scene_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2122 int clickX_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2123 int clickY_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2124 Action leftAction_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2125 Action rightAction_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2126 Action upAction_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2127 Action downAction_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2128 float strength_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2129 float sourceCenter_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2130 float sourceWidth_;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2131
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2132 static void ComputeAxisEffect(int& deltaCenter,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2133 int& deltaWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2134 int delta,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2135 Action actionNegative,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2136 Action actionPositive)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2137 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2138 if (delta < 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2139 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2140 switch (actionNegative)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2141 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2142 case Action_IncreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2143 deltaWidth = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2144 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2145
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2146 case Action_DecreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2147 deltaWidth = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2148 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2149
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2150 case Action_IncreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2151 deltaCenter = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2152 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2153
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2154 case Action_DecreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2155 deltaCenter = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2156 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2157
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2158 default:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2159 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2160 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2161 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2162 else if (delta > 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2163 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2164 switch (actionPositive)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2165 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2166 case Action_IncreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2167 deltaWidth = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2168 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2169
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2170 case Action_DecreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2171 deltaWidth = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2172 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2173
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2174 case Action_IncreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2175 deltaCenter = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2176 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2177
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2178 case Action_DecreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2179 deltaCenter = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2180 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2181
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2182 default:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2183 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2184 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2185 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2186 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2187
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2188
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2189 class UndoRedoCommand : public UndoRedoStack::ICommand
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2190 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2191 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2192 RadiologyScene& scene_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2193 float sourceCenter_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2194 float sourceWidth_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2195 float targetCenter_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2196 float targetWidth_;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2197
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2198 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2199 UndoRedoCommand(const RadiologyWindowingTracker& tracker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2200 scene_(tracker.scene_),
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2201 sourceCenter_(tracker.sourceCenter_),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2202 sourceWidth_(tracker.sourceWidth_)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2203 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2204 scene_.GetWindowingWithDefault(targetCenter_, targetWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2205 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2206
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2207 virtual void Undo() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2208 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2209 scene_.SetWindowing(sourceCenter_, sourceWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2210 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2211
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2212 virtual void Redo() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2213 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2214 scene_.SetWindowing(targetCenter_, targetWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2215 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2216 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2217
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2218
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2219 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2220 RadiologyWindowingTracker(UndoRedoStack& undoRedoStack,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2221 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2222 int x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2223 int y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2224 Action leftAction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2225 Action rightAction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2226 Action upAction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2227 Action downAction) :
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2228 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2229 scene_(scene),
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2230 clickX_(x),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2231 clickY_(y),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2232 leftAction_(leftAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2233 rightAction_(rightAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2234 upAction_(upAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2235 downAction_(downAction)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2236 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2237 scene_.GetWindowingWithDefault(sourceCenter_, sourceWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2238
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2239 float minValue, maxValue;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2240 scene.GetRange(minValue, maxValue);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2241
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2242 assert(minValue <= maxValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2243
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2244 float tmp;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2245
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2246 float delta = (maxValue - minValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2247 if (delta <= 1)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2248 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2249 tmp = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2250 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2251 else
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2252 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
2253 // 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
2254 // implement it by ourselves
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
2255 tmp = logf(delta) / logf(2.0f);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2256 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2257
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2258 strength_ = tmp - 7;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2259 if (strength_ < 1)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2260 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2261 strength_ = 1;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2262 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2263 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2264
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2265 virtual bool HasRender() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2266 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2267 return false;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2268 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2269
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2270 virtual void Render(CairoContext& context,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2271 double zoom)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2272 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2273 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2274 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2275
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2276 virtual void MouseUp()
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2277 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2278 undoRedoStack_.Add(new UndoRedoCommand(*this));
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2279 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2280
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2281
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2282 virtual void MouseMove(int displayX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2283 int displayY,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2284 double sceneX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2285 double sceneY)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2286 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2287 // 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
2288
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2289 static const float SCALE = 1.0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2290
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2291 int deltaCenter = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2292 int deltaWidth = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2293
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2294 ComputeAxisEffect(deltaCenter, deltaWidth, displayX - clickX_, leftAction_, rightAction_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2295 ComputeAxisEffect(deltaCenter, deltaWidth, displayY - clickY_, upAction_, downAction_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2296
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2297 float newCenter = sourceCenter_ + (deltaCenter / SCALE * strength_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2298 float newWidth = sourceWidth_ + (deltaWidth / SCALE * strength_);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2299 scene_.SetWindowing(newCenter, newWidth);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2300 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2301 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2302
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
2303
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2304 class RadiologyWidget :
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
2305 public WorldSceneWidget,
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
2306 public IObserver
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
2307 {
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
2308 private:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2309 RadiologyScene& scene_;
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2310 std::auto_ptr<Orthanc::Image> floatBuffer_;
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2311 std::auto_ptr<CairoSurface> cairoBuffer_;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2312 bool invert_;
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2313 ImageInterpolation interpolation_;
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2314 bool hasSelection_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2315 size_t selectedLayer_;
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2316
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2317 virtual bool RenderInternal(unsigned int width,
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2318 unsigned int height,
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2319 ImageInterpolation interpolation)
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2320 {
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2321 float windowCenter, windowWidth;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2322 scene_.GetWindowingWithDefault(windowCenter, windowWidth);
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2324 float x0 = windowCenter - windowWidth / 2.0f;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2325 float x1 = windowCenter + windowWidth / 2.0f;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2326
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2327 if (windowWidth <= 0.001f) // Avoid division by zero at (*)
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2328 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2329 return false;
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2330 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2331 else
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2332 {
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2333 if (floatBuffer_.get() == NULL ||
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2334 floatBuffer_->GetWidth() != width ||
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2335 floatBuffer_->GetHeight() != height)
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2336 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2337 floatBuffer_.reset(new Orthanc::Image(Orthanc::PixelFormat_Float32, width, height, false));
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2338 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2339
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2340 if (cairoBuffer_.get() == NULL ||
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2341 cairoBuffer_->GetWidth() != width ||
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2342 cairoBuffer_->GetHeight() != height)
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2343 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2344 cairoBuffer_.reset(new CairoSurface(width, height));
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2345 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2346
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2347 scene_.Render(*floatBuffer_, GetView().GetMatrix(), interpolation);
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2348
360
8262e4e9826d export to png
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
2349 // Conversion from Float32 to BGRA32 (cairo). Very similar to
8262e4e9826d export to png
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
2350 // GrayscaleFrameRenderer => TODO MERGE?
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2351
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2352 Orthanc::ImageAccessor target;
369
557c8ff1db5c integration mainline->am-2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 365
diff changeset
2353 cairoBuffer_->GetWriteableAccessor(target);
360
8262e4e9826d export to png
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
2354
8262e4e9826d export to png
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
2355 float scaling = 255.0f / (x1 - x0);
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2356
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2357 for (unsigned int y = 0; y < height; y++)
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2358 {
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2359 const float* p = reinterpret_cast<const float*>(floatBuffer_->GetConstRow(y));
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2360 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2361
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2362 for (unsigned int x = 0; x < width; x++, p++, q += 4)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2363 {
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2364 uint8_t v = 0;
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2365 if (*p >= x1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2366 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2367 v = 255;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2368 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2369 else if (*p <= x0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2370 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2371 v = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2372 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2373 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2374 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2375 // https://en.wikipedia.org/wiki/Linear_interpolation
360
8262e4e9826d export to png
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
2376 v = static_cast<uint8_t>(scaling * (*p - x0)); // (*)
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2377 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2378
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2379 if (invert_)
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2380 {
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2381 v = 255 - v;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2382 }
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2383
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2384 q[0] = v;
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2385 q[1] = v;
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2386 q[2] = v;
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2387 q[3] = 255;
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2388 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2389 }
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2390
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2391 return true;
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2392 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2393 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2394
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2395 protected:
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2396 virtual Extent2D GetSceneExtent()
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2397 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2398 return scene_.GetSceneExtent();
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2399 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2400
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2401 virtual bool RenderScene(CairoContext& context,
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2402 const ViewportGeometry& view)
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2403 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2404 cairo_t* cr = context.GetObject();
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2405
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2406 if (RenderInternal(context.GetWidth(), context.GetHeight(), interpolation_))
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2407 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2408 // https://www.cairographics.org/FAQ/#paint_from_a_surface
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2409 cairo_save(cr);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2410 cairo_identity_matrix(cr);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2411 cairo_set_source_surface(cr, cairoBuffer_->GetObject(), 0, 0);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2412 cairo_paint(cr);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2413 cairo_restore(cr);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2414 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2415 else
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2416 {
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2417 // https://www.cairographics.org/FAQ/#clear_a_surface
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2418 context.SetSourceColor(0, 0, 0);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2419 cairo_paint(cr);
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2420 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2421
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2422 if (hasSelection_)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2423 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2424 scene_.DrawBorder(context, selectedLayer_, view.GetZoom());
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2425 }
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2426
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2427 return true;
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2428 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2429
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2430 public:
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2431 RadiologyWidget(MessageBroker& broker,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2432 RadiologyScene& scene,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2433 const std::string& name) :
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2434 WorldSceneWidget(name),
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2435 IObserver(broker),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2436 scene_(scene),
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2437 invert_(false),
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2438 interpolation_(ImageInterpolation_Nearest),
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2439 hasSelection_(false),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2440 selectedLayer_(0) // Dummy initialization
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2441 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2442 scene.RegisterObserverCallback(
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2443 new Callable<RadiologyWidget, RadiologyScene::GeometryChangedMessage>
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2444 (*this, &RadiologyWidget::OnGeometryChanged));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2445
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2446 scene.RegisterObserverCallback(
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2447 new Callable<RadiologyWidget, RadiologyScene::ContentChangedMessage>
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2448 (*this, &RadiologyWidget::OnContentChanged));
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2449 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2450
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2451 RadiologyScene& GetScene() const
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2452 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2453 return scene_;
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2454 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2455
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2456 void Unselect()
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2457 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2458 hasSelection_ = false;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2459 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2460
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2461 void Select(size_t layer)
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2462 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2463 hasSelection_ = true;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2464 selectedLayer_ = layer;
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2465 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2466
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2467 bool LookupSelectedLayer(size_t& layer)
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2468 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2469 if (hasSelection_)
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2470 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2471 layer = selectedLayer_;
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2472 return true;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2473 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2474 else
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2475 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2476 return false;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2477 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2478 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2479
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2480 void OnGeometryChanged(const RadiologyScene::GeometryChangedMessage& message)
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2481 {
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2482 LOG(INFO) << "Geometry has changed";
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2483 FitContent();
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2484 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2485
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2486 void OnContentChanged(const RadiologyScene::ContentChangedMessage& message)
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2487 {
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2488 LOG(INFO) << "Content has changed";
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2489 NotifyContentChanged();
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2490 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2491
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2492 void SetInvert(bool invert)
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2493 {
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2494 if (invert_ != invert)
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2495 {
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2496 invert_ = invert;
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2497 NotifyContentChanged();
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2498 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2499 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2500
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2501 void SwitchInvert()
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2502 {
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2503 invert_ = !invert_;
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2504 NotifyContentChanged();
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2505 }
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2506
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2507 bool IsInverted() const
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2508 {
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2509 return invert_;
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2510 }
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2511
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2512 void SetInterpolation(ImageInterpolation interpolation)
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2513 {
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2514 if (interpolation_ != interpolation)
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2515 {
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2516 interpolation_ = interpolation;
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2517 NotifyContentChanged();
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2518 }
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2519 }
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2520
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2521 ImageInterpolation GetInterpolation() const
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2522 {
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2523 return interpolation_;
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2524 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2525 };
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2526
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2527
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2528 namespace Samples
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2529 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2530 class RadiologyEditorInteractor :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2531 public IWorldSceneInteractor,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2532 public IObserver
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2533 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2534 private:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2535 enum Tool
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2536 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2537 Tool_Move,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2538 Tool_Rotate,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2539 Tool_Crop,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2540 Tool_Resize,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2541 Tool_Windowing
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2542 };
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2543
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2544
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2545 UndoRedoStack undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2546 Tool tool_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2547
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2548
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2549 static double GetHandleSize()
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2550 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2551 return 10.0;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2552 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2553
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2554
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2555 public:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2556 RadiologyEditorInteractor(MessageBroker& broker) :
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2557 IObserver(broker),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2558 tool_(Tool_Move)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2559 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2560 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2561
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2562 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2563 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2564 MouseButton button,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2565 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2566 int viewportX,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2567 int viewportY,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2568 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2569 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2570 IStatusBar* statusBar)
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
2571 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2572 RadiologyWidget& widget = dynamic_cast<RadiologyWidget&>(worldWidget);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2573
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2574 if (button == MouseButton_Left)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2575 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2576 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2577
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2578 if (tool_ == Tool_Windowing)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2579 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2580 return new RadiologyWindowingTracker(undoRedoStack_, widget.GetScene(),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2581 viewportX, viewportY,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2582 RadiologyWindowingTracker::Action_DecreaseWidth,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2583 RadiologyWindowingTracker::Action_IncreaseWidth,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2584 RadiologyWindowingTracker::Action_DecreaseCenter,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2585 RadiologyWindowingTracker::Action_IncreaseCenter);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2586 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2587 else if (!widget.LookupSelectedLayer(selected))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2588 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2589 // No layer is currently selected
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2590 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2591 if (widget.GetScene().LookupLayer(layer, x, y))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2592 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2593 widget.Select(layer);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2594 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2595
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2596 return NULL;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2597 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2598 else if (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2599 tool_ == Tool_Resize)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2600 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2601 RadiologyScene::LayerAccessor accessor(widget.GetScene(), selected);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2602 RadiologyScene::Corner corner;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2603 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2604 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2605 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2606 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2607 case Tool_Crop:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2608 return new RadiologyLayerCropTracker(undoRedoStack_, widget.GetScene(), view, selected, x, y, corner);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2609
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2610 case Tool_Resize:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2611 return new RadiologyLayerResizeTracker(undoRedoStack_, widget.GetScene(), selected, x, y, corner,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2612 (modifiers & KeyboardModifiers_Shift));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2613
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2614 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2615 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2616 }
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2617 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2618 else
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2619 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2620 size_t layer;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2621
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2622 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
2623 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2624 widget.Select(layer);
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2625 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2626 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2627 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2628 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2629 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2630
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2631 return NULL;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2632 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2633 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2634 else
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2635 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2636 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2637
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2638 if (widget.GetScene().LookupLayer(layer, x, y))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2639 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2640 if (layer == selected)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2641 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2642 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2643 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2644 case Tool_Move:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2645 return new RadiologyLayerMoveTracker(undoRedoStack_, widget.GetScene(), layer, x, y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2646 (modifiers & KeyboardModifiers_Shift));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2647
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2648 case Tool_Rotate:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2649 return new RadiologyLayerRotateTracker(undoRedoStack_, widget.GetScene(), view, layer, x, y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2650 (modifiers & KeyboardModifiers_Shift));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2651
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2652 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2653 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2654 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2655
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2656 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2657 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2658 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2659 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2660 widget.Select(layer);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2661 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2662 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2663 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2664 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2665 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2666 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2667 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2668 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2669 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2670 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2671 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2672 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2673 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2674 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2675 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2676
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2677 virtual void MouseOver(CairoContext& context,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2678 WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2679 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2680 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2681 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2682 IStatusBar* statusBar)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2683 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2684 RadiologyWidget& widget = dynamic_cast<RadiologyWidget&>(worldWidget);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2685
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2686 #if 0
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2687 if (statusBar != NULL)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2688 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2689 char buf[64];
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2690 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
2691 statusBar->SetMessage(buf);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2692 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2693 #endif
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2694
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2695 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2696
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2697 if (widget.LookupSelectedLayer(selected) &&
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2698 (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2699 tool_ == Tool_Resize))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2700 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2701 RadiologyScene::LayerAccessor accessor(widget.GetScene(), selected);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2702
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2703 RadiologyScene::Corner corner;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2704 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2705 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2706 accessor.GetLayer().GetCorner(x, y, corner);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2707
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2708 double z = 1.0 / view.GetZoom();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2709
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2710 context.SetSourceColor(255, 0, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2711 cairo_t* cr = context.GetObject();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2712 cairo_set_line_width(cr, 2.0 * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2713 cairo_move_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2714 cairo_line_to(cr, x + GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2715 cairo_line_to(cr, x + GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2716 cairo_line_to(cr, x - GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2717 cairo_line_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2718 cairo_stroke(cr);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2719 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2720 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
2721 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2722
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2723 virtual void MouseWheel(WorldSceneWidget& widget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2724 MouseWheelDirection direction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2725 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2726 IStatusBar* statusBar)
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
2727 {
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2728 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2729
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2730 virtual void KeyPressed(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2731 KeyboardKeys key,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2732 char keyChar,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2733 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2734 IStatusBar* statusBar)
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
2735 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2736 RadiologyWidget& widget = dynamic_cast<RadiologyWidget&>(worldWidget);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2737
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2738 switch (keyChar)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2739 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2740 case 'a':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2741 widget.FitContent();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2742 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2743
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2744 case 'c':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2745 tool_ = Tool_Crop;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2746 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2747
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2748 case 'e':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2749 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2750 Orthanc::DicomMap tags;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2751
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2752 // Minimal set of tags to generate a valid CR image
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2753 tags.SetValue(Orthanc::DICOM_TAG_ACCESSION_NUMBER, "NOPE", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2754 tags.SetValue(Orthanc::DICOM_TAG_BODY_PART_EXAMINED, "PELVIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2755 tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2756 //tags.SetValue(Orthanc::DICOM_TAG_LATERALITY, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2757 tags.SetValue(Orthanc::DICOM_TAG_MANUFACTURER, "OSIMIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2758 tags.SetValue(Orthanc::DICOM_TAG_MODALITY, "CR", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2759 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_BIRTH_DATE, "20000101", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2760 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2761 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2762 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ORIENTATION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2763 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_SEX, "M", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2764 tags.SetValue(Orthanc::DICOM_TAG_REFERRING_PHYSICIAN_NAME, "HOUSE^MD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2765 tags.SetValue(Orthanc::DICOM_TAG_SERIES_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2766 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
2767 tags.SetValue(Orthanc::DICOM_TAG_STUDY_ID, "STUDY", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2768 tags.SetValue(Orthanc::DICOM_TAG_VIEW_POSITION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2769
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2770 widget.GetScene().Export(tags, 0.1, 0.1, widget.IsInverted(),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2771 widget.GetInterpolation(), EXPORT_USING_PAM);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2772 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2773 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2774
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2775 case 'i':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2776 widget.SwitchInvert();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2777 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2778
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2779 case 'm':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2780 tool_ = Tool_Move;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2781 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2782
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2783 case 'n':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2784 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2785 switch (widget.GetInterpolation())
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2786 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2787 case ImageInterpolation_Nearest:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2788 LOG(INFO) << "Switching to bilinear interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2789 widget.SetInterpolation(ImageInterpolation_Bilinear);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2790 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2791
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2792 case ImageInterpolation_Bilinear:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2793 LOG(INFO) << "Switching to nearest neighbor interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2794 widget.SetInterpolation(ImageInterpolation_Nearest);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2795 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2796
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2797 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2798 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2799 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2800
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2801 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2802 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2803
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2804 case 'r':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2805 tool_ = Tool_Rotate;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2806 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2807
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2808 case 's':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2809 tool_ = Tool_Resize;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2810 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2811
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2812 case 'w':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2813 tool_ = Tool_Windowing;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2814 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2815
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2816 case 'y':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2817 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2818 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2819 undoRedoStack_.Redo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2820 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2821 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2822 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2823
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2824 case 'z':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2825 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2826 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2827 undoRedoStack_.Undo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2828 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2829 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2830 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2831
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2832 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2833 break;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2834 }
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
2835 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2836 };
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
2837
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
2838
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2839
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2840 class SingleFrameEditorApplication :
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2841 public SampleSingleCanvasApplicationBase,
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2842 public IObserver
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2843 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2844 private:
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
2845 std::auto_ptr<OrthancApiClient> orthancApiClient_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2846 std::auto_ptr<RadiologyScene> scene_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2847 RadiologyEditorInteractor interactor_;
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2848
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2849 public:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2850 SingleFrameEditorApplication(MessageBroker& broker) :
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
2851 IObserver(broker),
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
2852 interactor_(broker)
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2853 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2854 }
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2855
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2856 virtual ~SingleFrameEditorApplication()
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2857 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2858 LOG(WARNING) << "Destroying the application";
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
2859 }
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2860
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2861 virtual void DeclareStartupOptions(boost::program_options::options_description& options)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2862 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2863 boost::program_options::options_description generic("Sample options");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2864 generic.add_options()
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2865 ("instance", boost::program_options::value<std::string>(),
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2866 "Orthanc ID of the instance")
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2867 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2868 "Number of the frame, for multi-frame DICOM instances")
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
2869 ;
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2870
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2871 options.add(generic);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2872 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2873
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2874 virtual void Initialize(StoneApplicationContext* context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2875 IStatusBar& statusBar,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2876 const boost::program_options::variables_map& parameters)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2877 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2878 using namespace OrthancStone;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2879
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2880 context_ = context;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2881
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2882 statusBar.SetMessage("Use the key \"a\" to reinitialize the layout");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2883 statusBar.SetMessage("Use the key \"c\" to crop");
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
2884 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
2885 statusBar.SetMessage("Use the key \"f\" to switch full screen");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2886 statusBar.SetMessage("Use the key \"i\" to invert contrast");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2887 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
2888 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
2889 statusBar.SetMessage("Use the key \"r\" to rotate objects");
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2890 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
2891 statusBar.SetMessage("Use the key \"w\" to change windowing");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2892
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2893 statusBar.SetMessage("Use the key \"ctrl-z\" to undo action");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2894 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
2895
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2896 if (parameters.count("instance") != 1)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2897 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2898 LOG(ERROR) << "The instance ID is missing";
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2899 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2900 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2901
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2902 std::string instance = parameters["instance"].as<std::string>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2903 int frame = parameters["frame"].as<unsigned int>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2904
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 392
diff changeset
2905 orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService()));
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
2906
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
2907 Orthanc::FontRegistry fonts;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
2908 fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
2909
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2910 scene_.reset(new RadiologyScene(GetBroker(), *orthancApiClient_));
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2911 scene_->LoadDicomFrame(instance, frame, false); //.SetPan(200, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2912 //scene_->LoadDicomFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2913
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2914 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2915 RadiologyScene::Layer& layer = scene_->LoadText(fonts.GetFont(0), "Hello\nworld");
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2916 //dynamic_cast<RadiologyScene::Layer&>(layer).SetForegroundValue(256);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2917 dynamic_cast<RadiologyScene::Layer&>(layer).SetResizeable(true);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2918 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2919
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2920 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2921 RadiologyScene::Layer& layer = scene_->LoadTestBlock(100, 50);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2922 //dynamic_cast<RadiologyScene::Layer&>(layer).SetForegroundValue(256);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2923 dynamic_cast<RadiologyScene::Layer&>(layer).SetResizeable(true);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2924 dynamic_cast<RadiologyScene::Layer&>(layer).SetPan(0, 200);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2925 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
2926
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
2927
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2928 mainWidget_ = new RadiologyWidget(GetBroker(), *scene_, "main-widget");
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2929 mainWidget_->SetTransmitMouseOver(true);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
2930 mainWidget_->SetInteractor(interactor_);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2931
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
2932 //scene_->SetWindowing(128, 256);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2933 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2934 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2935 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
2936 }