annotate Applications/Samples/SingleFrameEditorApplication.h @ 414:f7616c010056

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Nov 2018 18:00:48 +0100
parents 18b707fb8620
children c0589c3173fd
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
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 413
diff changeset
26 #include "../../Framework/Radiography/RadiographyLayerMoveTracker.h"
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 413
diff changeset
27 #include "../../Framework/Radiography/RadiographyLayerRotateTracker.h"
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
28 #include "../../Framework/Radiography/RadiographyScene.h"
414
f7616c010056 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 413
diff changeset
29 #include "../../Framework/Radiography/RadiographySceneCommand.h"
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
30 #include "../../Framework/Radiography/RadiographyWidget.h"
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
31
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
32 #include "../../Framework/Toolbox/UndoRedoStack.h"
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
33
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
34 #include <Core/Images/FontRegistry.h>
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
35 #include <Core/Images/Image.h>
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
36 #include <Core/Images/ImageProcessing.h>
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
37 #include <Core/Images/PamReader.h>
361
f559ac66ef55 first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
38 #include <Core/Images/PamWriter.h>
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
39 #include <Core/Images/PngWriter.h>
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
40 #include <Core/Logging.h>
403
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
41 #include <Core/OrthancException.h>
361
f559ac66ef55 first export of a dicom image
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 360
diff changeset
42 #include <Core/Toolbox.h>
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
43 #include <Plugins/Samples/Common/DicomDatasetReader.h>
338
b3b3fa0e3689 BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 337
diff changeset
44 #include <Plugins/Samples/Common/FullOrthancDataset.h>
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
45
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
46
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
47 // Export using PAM is faster than using PNG, but requires Orthanc
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
48 // core >= 1.4.3
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
49 #define EXPORT_USING_PAM 1
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
50
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
51
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
52 #include <boost/math/special_functions/round.hpp>
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
53
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
54
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
55 namespace OrthancStone
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
56 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
57 class RadiographyLayerCropTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
58 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
59 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
60 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
61 RadiographyScene::LayerAccessor accessor_;
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
62 Corner corner_;
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
63 unsigned int cropX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
64 unsigned int cropY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
65 unsigned int cropWidth_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
66 unsigned int cropHeight_;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
67
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
68 class UndoRedoCommand : public RadiographySceneCommand
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
69 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
70 private:
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
71 unsigned int sourceCropX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
72 unsigned int sourceCropY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
73 unsigned int sourceCropWidth_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
74 unsigned int sourceCropHeight_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
75 unsigned int targetCropX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
76 unsigned int targetCropY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
77 unsigned int targetCropWidth_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
78 unsigned int targetCropHeight_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
79
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
80 protected:
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
81 virtual void UndoInternal(RadiographyLayer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
82 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
83 layer.SetCrop(sourceCropX_, sourceCropY_, sourceCropWidth_, sourceCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
84 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
85
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
86 virtual void RedoInternal(RadiographyLayer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
87 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
88 layer.SetCrop(targetCropX_, targetCropY_, targetCropWidth_, targetCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
89 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
90
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
91 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
92 UndoRedoCommand(const RadiographyLayerCropTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
93 RadiographySceneCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
94 sourceCropX_(tracker.cropX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
95 sourceCropY_(tracker.cropY_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
96 sourceCropWidth_(tracker.cropWidth_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
97 sourceCropHeight_(tracker.cropHeight_)
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
98 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
99 tracker.accessor_.GetLayer().GetCrop(targetCropX_, targetCropY_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
100 targetCropWidth_, targetCropHeight_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
101 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
102 };
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
103
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
104
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
105 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
106 RadiographyLayerCropTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
107 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
108 const ViewportGeometry& view,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
109 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
110 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
111 double y,
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
112 Corner corner) :
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
113 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
114 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
115 corner_(corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
116 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
117 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
118 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
119 accessor_.GetLayer().GetCrop(cropX_, cropY_, cropWidth_, cropHeight_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
120 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
121 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
122
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
123 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
124 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
125 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
126 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
127
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
128 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
129 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
130 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
131 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
132 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
133
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
134 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
135 {
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
136 if (accessor_.IsValid())
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
137 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
138 undoRedoStack_.Add(new UndoRedoCommand(*this));
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
139 }
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
140 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
141
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
142 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
143 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
144 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
145 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
146 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
147 if (accessor_.IsValid())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
148 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
149 unsigned int x, y;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
150
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
151 RadiographyLayer& layer = accessor_.GetLayer();
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
152 if (layer.GetPixel(x, y, sceneX, sceneY))
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
153 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
154 unsigned int targetX, targetWidth;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
155
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
156 if (corner_ == Corner_TopLeft ||
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
157 corner_ == Corner_BottomLeft)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
158 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
159 targetX = std::min(x, cropX_ + cropWidth_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
160 targetWidth = cropX_ + cropWidth_ - targetX;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
161 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
162 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
163 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
164 targetX = cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
165 targetWidth = std::max(x, cropX_) - cropX_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
166 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
167
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
168 unsigned int targetY, targetHeight;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
169
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
170 if (corner_ == Corner_TopLeft ||
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
171 corner_ == Corner_TopRight)
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
172 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
173 targetY = std::min(y, cropY_ + cropHeight_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
174 targetHeight = cropY_ + cropHeight_ - targetY;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
175 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
176 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
177 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
178 targetY = cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
179 targetHeight = std::max(y, cropY_) - cropY_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
180 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
181
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
182 layer.SetCrop(targetX, targetY, targetWidth, targetHeight);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
183 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
184 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
185 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
186 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
187
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
188
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
189 class RadiographyLayerResizeTracker : public IWorldSceneMouseTracker
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
190 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
191 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
192 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
193 RadiographyScene::LayerAccessor accessor_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
194 bool roundScaling_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
195 double originalSpacingX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
196 double originalSpacingY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
197 double originalPanX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
198 double originalPanY_;
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
199 Corner oppositeCorner_;
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
200 double oppositeX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
201 double oppositeY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
202 double baseScaling_;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
203
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
204 static double ComputeDistance(double x1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
205 double y1,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
206 double x2,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
207 double y2)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
208 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
209 double dx = x1 - x2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
210 double dy = y1 - y2;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
211 return sqrt(dx * dx + dy * dy);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
212 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
213
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
214 class UndoRedoCommand : public RadiographySceneCommand
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
215 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
216 private:
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
217 double sourceSpacingX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
218 double sourceSpacingY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
219 double sourcePanX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
220 double sourcePanY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
221 double targetSpacingX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
222 double targetSpacingY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
223 double targetPanX_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
224 double targetPanY_;
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
225
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
226 protected:
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
227 virtual void UndoInternal(RadiographyLayer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
228 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
229 layer.SetPixelSpacing(sourceSpacingX_, sourceSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
230 layer.SetPan(sourcePanX_, sourcePanY_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
231 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
232
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
233 virtual void RedoInternal(RadiographyLayer& layer) const
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
234 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
235 layer.SetPixelSpacing(targetSpacingX_, targetSpacingY_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
236 layer.SetPan(targetPanX_, targetPanY_);
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
237 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
238
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
239 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
240 UndoRedoCommand(const RadiographyLayerResizeTracker& tracker) :
413
18b707fb8620 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
241 RadiographySceneCommand(tracker.accessor_),
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
242 sourceSpacingX_(tracker.originalSpacingX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
243 sourceSpacingY_(tracker.originalSpacingY_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
244 sourcePanX_(tracker.originalPanX_),
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
245 sourcePanY_(tracker.originalPanY_),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
246 targetSpacingX_(tracker.accessor_.GetLayer().GetPixelSpacingX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
247 targetSpacingY_(tracker.accessor_.GetLayer().GetPixelSpacingY()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
248 targetPanX_(tracker.accessor_.GetLayer().GetPanX()),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
249 targetPanY_(tracker.accessor_.GetLayer().GetPanY())
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
250 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
251 }
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
252 };
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
253
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
254
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
255 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
256 RadiographyLayerResizeTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
257 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
258 size_t layer,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
259 double x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
260 double y,
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
261 Corner corner,
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
262 bool roundScaling) :
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
263 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
264 accessor_(scene, layer),
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
265 roundScaling_(roundScaling)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
266 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
267 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
268 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
269 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
270 originalSpacingX_ = accessor_.GetLayer().GetPixelSpacingX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
271 originalSpacingY_ = accessor_.GetLayer().GetPixelSpacingY();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
272 originalPanX_ = accessor_.GetLayer().GetPanX();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
273 originalPanY_ = accessor_.GetLayer().GetPanY();
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
274
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
275 switch (corner)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
276 {
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
277 case Corner_TopLeft:
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
278 oppositeCorner_ = Corner_BottomRight;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
279 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
280
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
281 case Corner_TopRight:
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
282 oppositeCorner_ = Corner_BottomLeft;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
283 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
284
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
285 case Corner_BottomLeft:
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
286 oppositeCorner_ = Corner_TopRight;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
287 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
288
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
289 case Corner_BottomRight:
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
290 oppositeCorner_ = Corner_TopLeft;
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
291 break;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
292
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
293 default:
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
294 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
295 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
296
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
297 accessor_.GetLayer().GetCorner(oppositeX_, oppositeY_, oppositeCorner_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
298
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
299 double d = ComputeDistance(x, y, oppositeX_, oppositeY_);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
300 if (d >= std::numeric_limits<float>::epsilon())
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
301 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
302 baseScaling_ = 1.0 / d;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
303 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
304 else
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
305 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
306 // Avoid division by zero in extreme cases
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
307 accessor_.Invalidate();
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
308 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
309 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
310 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
311
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
312 virtual bool HasRender() const
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
313 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
314 return false;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
315 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
316
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
317 virtual void Render(CairoContext& context,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
318 double zoom)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
319 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
320 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
321 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
322
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
323 virtual void MouseUp()
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
324 {
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
325 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
326 accessor_.GetLayer().IsResizeable())
355
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
327 {
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
328 undoRedoStack_.Add(new UndoRedoCommand(*this));
d2468dd75b3f undo redo for all tools
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 354
diff changeset
329 }
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
330 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
331
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
332 virtual void MouseMove(int displayX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
333 int displayY,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
334 double sceneX,
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
335 double sceneY)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
336 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
337 static const double ROUND_SCALING = 0.1;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
338
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
339 if (accessor_.IsValid() &&
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
340 accessor_.GetLayer().IsResizeable())
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
341 {
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
342 double scaling = ComputeDistance(oppositeX_, oppositeY_, sceneX, sceneY) * baseScaling_;
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
343
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
344 if (roundScaling_)
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
345 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
346 scaling = boost::math::round<double>((scaling / ROUND_SCALING) * ROUND_SCALING);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
347 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
348
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
349 RadiographyLayer& layer = accessor_.GetLayer();
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
350 layer.SetPixelSpacing(scaling * originalSpacingX_,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
351 scaling * originalSpacingY_);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
352
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
353 // Keep the opposite corner at a fixed location
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
354 double ox, oy;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
355 layer.GetCorner(ox, oy, oppositeCorner_);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
356 layer.SetPan(layer.GetPanX() + oppositeX_ - ox,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
357 layer.GetPanY() + oppositeY_ - oy);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
358 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
359 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
360 };
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
361
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
362
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
363 class RadiographyWindowingTracker : public IWorldSceneMouseTracker
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
364 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
365 public:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
366 enum Action
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
367 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
368 Action_IncreaseWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
369 Action_DecreaseWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
370 Action_IncreaseCenter,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
371 Action_DecreaseCenter
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
372 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
373
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
374 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
375 UndoRedoStack& undoRedoStack_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
376 RadiographyScene& scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
377 int clickX_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
378 int clickY_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
379 Action leftAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
380 Action rightAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
381 Action upAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
382 Action downAction_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
383 float strength_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
384 float sourceCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
385 float sourceWidth_;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
386
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
387 static void ComputeAxisEffect(int& deltaCenter,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
388 int& deltaWidth,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
389 int delta,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
390 Action actionNegative,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
391 Action actionPositive)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
392 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
393 if (delta < 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
394 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
395 switch (actionNegative)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
396 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
397 case Action_IncreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
398 deltaWidth = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
399 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
400
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
401 case Action_DecreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
402 deltaWidth = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
403 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
404
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
405 case Action_IncreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
406 deltaCenter = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
407 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
408
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
409 case Action_DecreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
410 deltaCenter = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
411 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
412
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
413 default:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
415 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
416 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
417 else if (delta > 0)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
418 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
419 switch (actionPositive)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
420 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
421 case Action_IncreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
422 deltaWidth = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
423 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
424
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
425 case Action_DecreaseWidth:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
426 deltaWidth = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
427 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
428
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
429 case Action_IncreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
430 deltaCenter = delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
431 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
432
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
433 case Action_DecreaseCenter:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
434 deltaCenter = -delta;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
435 break;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
436
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
437 default:
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
438 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
439 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
440 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
441 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
442
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
443
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
444 class UndoRedoCommand : public UndoRedoStack::ICommand
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
445 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
446 private:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
447 RadiographyScene& scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
448 float sourceCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
449 float sourceWidth_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
450 float targetCenter_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
451 float targetWidth_;
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
452
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
453 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
454 UndoRedoCommand(const RadiographyWindowingTracker& tracker) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
455 scene_(tracker.scene_),
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
456 sourceCenter_(tracker.sourceCenter_),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
457 sourceWidth_(tracker.sourceWidth_)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
458 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
459 scene_.GetWindowingWithDefault(targetCenter_, targetWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
460 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
461
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
462 virtual void Undo() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
463 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
464 scene_.SetWindowing(sourceCenter_, sourceWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
465 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
466
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
467 virtual void Redo() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
468 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
469 scene_.SetWindowing(targetCenter_, targetWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
470 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
471 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
472
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
473
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
474 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
475 RadiographyWindowingTracker(UndoRedoStack& undoRedoStack,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
476 RadiographyScene& scene,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
477 int x,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
478 int y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
479 Action leftAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
480 Action rightAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
481 Action upAction,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
482 Action downAction) :
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
483 undoRedoStack_(undoRedoStack),
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
484 scene_(scene),
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
485 clickX_(x),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
486 clickY_(y),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
487 leftAction_(leftAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
488 rightAction_(rightAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
489 upAction_(upAction),
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
490 downAction_(downAction)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
491 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
492 scene_.GetWindowingWithDefault(sourceCenter_, sourceWidth_);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
493
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
494 float minValue, maxValue;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
495 scene.GetRange(minValue, maxValue);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
496
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
497 assert(minValue <= maxValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
498
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
499 float tmp;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
500
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
501 float delta = (maxValue - minValue);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
502 if (delta <= 1)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
503 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
504 tmp = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
505 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
506 else
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
507 {
376
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
508 // 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
509 // implement it by ourselves
70256a53ff21 fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 369
diff changeset
510 tmp = logf(delta) / logf(2.0f);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
511 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
512
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
513 strength_ = tmp - 7;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
514 if (strength_ < 1)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
515 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
516 strength_ = 1;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
517 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
518 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
519
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
520 virtual bool HasRender() const
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
521 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
522 return false;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
523 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
524
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
525 virtual void Render(CairoContext& context,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
526 double zoom)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
527 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
528 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
529 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
530
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
531 virtual void MouseUp()
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
532 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
533 undoRedoStack_.Add(new UndoRedoCommand(*this));
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
534 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
535
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
536
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
537 virtual void MouseMove(int displayX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
538 int displayY,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
539 double sceneX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
540 double sceneY)
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
541 {
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
542 // 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
543
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
544 static const float SCALE = 1.0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
545
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
546 int deltaCenter = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
547 int deltaWidth = 0;
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
548
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
549 ComputeAxisEffect(deltaCenter, deltaWidth, displayX - clickX_, leftAction_, rightAction_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
550 ComputeAxisEffect(deltaCenter, deltaWidth, displayY - clickY_, upAction_, downAction_);
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 float newCenter = sourceCenter_ + (deltaCenter / SCALE * strength_);
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
553 float newWidth = sourceWidth_ + (deltaWidth / SCALE * strength_);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
554 scene_.SetWindowing(newCenter, newWidth);
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
555 }
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
556 };
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
557
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 355
diff changeset
558
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
559
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
560
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
561 namespace Samples
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
562 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
563 class RadiographyEditorInteractor :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
564 public IWorldSceneInteractor,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
565 public IObserver
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
566 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
567 private:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
568 enum Tool
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
569 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
570 Tool_Move,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
571 Tool_Rotate,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
572 Tool_Crop,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
573 Tool_Resize,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
574 Tool_Windowing
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
575 };
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
576
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
577
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
578 UndoRedoStack undoRedoStack_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
579 Tool tool_;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
580
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
581
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
582 static double GetHandleSize()
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
583 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
584 return 10.0;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
585 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
586
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
587
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
588 public:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
589 RadiographyEditorInteractor(MessageBroker& broker) :
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
590 IObserver(broker),
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
591 tool_(Tool_Move)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
592 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
593 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
594
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
595 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
596 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
597 MouseButton button,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
598 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
599 int viewportX,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
600 int viewportY,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
601 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
602 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
603 IStatusBar* statusBar)
357
ec4ad6c5eb99 avoid breaking class hierarchy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 356
diff changeset
604 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
605 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
606
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
607 if (button == MouseButton_Left)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
608 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
609 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
610
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
611 if (tool_ == Tool_Windowing)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
612 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
613 return new RadiographyWindowingTracker(
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
614 undoRedoStack_, widget.GetScene(),
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
615 viewportX, viewportY,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
616 RadiographyWindowingTracker::Action_DecreaseWidth,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
617 RadiographyWindowingTracker::Action_IncreaseWidth,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
618 RadiographyWindowingTracker::Action_DecreaseCenter,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
619 RadiographyWindowingTracker::Action_IncreaseCenter);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
620 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
621 else if (!widget.LookupSelectedLayer(selected))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
622 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
623 // No layer is currently selected
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
624 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
625 if (widget.GetScene().LookupLayer(layer, x, y))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
626 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
627 widget.Select(layer);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
628 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
629
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
630 return NULL;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
631 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
632 else if (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
633 tool_ == Tool_Resize)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
634 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
635 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
636
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
637 Corner corner;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
638 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
639 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
640 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
641 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
642 case Tool_Crop:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
643 return new RadiographyLayerCropTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
644 (undoRedoStack_, widget.GetScene(), view, selected, x, y, corner);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
645
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
646 case Tool_Resize:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
647 return new RadiographyLayerResizeTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
648 (undoRedoStack_, widget.GetScene(), selected, x, y, corner,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
649 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
650
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
651 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
652 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
653 }
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
654 }
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
655 else
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
656 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
657 size_t layer;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
658
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
659 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
660 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
661 widget.Select(layer);
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
662 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
663 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
664 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
665 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
666 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
667
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
668 return NULL;
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
669 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
670 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
671 else
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
672 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
673 size_t layer;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
674
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
675 if (widget.GetScene().LookupLayer(layer, x, y))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
676 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
677 if (layer == selected)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
678 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
679 switch (tool_)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
680 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
681 case Tool_Move:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
682 return new RadiographyLayerMoveTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
683 (undoRedoStack_, widget.GetScene(), layer, x, y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
684 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
685
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
686 case Tool_Rotate:
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
687 return new RadiographyLayerRotateTracker
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
688 (undoRedoStack_, widget.GetScene(), view, layer, x, y,
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
689 (modifiers & KeyboardModifiers_Shift));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
690
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
691 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
692 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
693 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
694
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
695 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
696 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
697 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
698 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
699 widget.Select(layer);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
700 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
701 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
702 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
703 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
704 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
705 widget.Unselect();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
706 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
707 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
708 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
709 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
710 else
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
711 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
712 return NULL;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
713 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
714 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
715
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
716 virtual void MouseOver(CairoContext& context,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
717 WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
718 const ViewportGeometry& view,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
719 double x,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
720 double y,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
721 IStatusBar* statusBar)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
722 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
723 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
724
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
725 #if 0
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
726 if (statusBar != NULL)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
727 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
728 char buf[64];
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
729 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
730 statusBar->SetMessage(buf);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
731 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
732 #endif
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
733
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
734 size_t selected;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
735
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
736 if (widget.LookupSelectedLayer(selected) &&
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
737 (tool_ == Tool_Crop ||
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
738 tool_ == Tool_Resize))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
739 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
740 RadiographyScene::LayerAccessor accessor(widget.GetScene(), selected);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
741
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
742 Corner corner;
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
743 if (accessor.GetLayer().LookupCorner(corner, x, y, view.GetZoom(), GetHandleSize()))
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
744 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
745 accessor.GetLayer().GetCorner(x, y, corner);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
746
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
747 double z = 1.0 / view.GetZoom();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
748
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
749 context.SetSourceColor(255, 0, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
750 cairo_t* cr = context.GetObject();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
751 cairo_set_line_width(cr, 2.0 * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
752 cairo_move_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
753 cairo_line_to(cr, x + GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
754 cairo_line_to(cr, x + GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
755 cairo_line_to(cr, x - GetHandleSize() * z, y + GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
756 cairo_line_to(cr, x - GetHandleSize() * z, y - GetHandleSize() * z);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
757 cairo_stroke(cr);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
758 }
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
759 }
339
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 338
diff changeset
760 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
761
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
762 virtual void MouseWheel(WorldSceneWidget& widget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
763 MouseWheelDirection direction,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
764 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
765 IStatusBar* statusBar)
344
fdec8e6893cb ordering of bitmap layers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 343
diff changeset
766 {
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
767 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
768
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
769 virtual void KeyPressed(WorldSceneWidget& worldWidget,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
770 KeyboardKeys key,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
771 char keyChar,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
772 KeyboardModifiers modifiers,
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
773 IStatusBar* statusBar)
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
774 {
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
775 RadiographyWidget& widget = dynamic_cast<RadiographyWidget&>(worldWidget);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
776
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
777 switch (keyChar)
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
778 {
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
779 case 'a':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
780 widget.FitContent();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
781 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
782
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
783 case 'c':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
784 tool_ = Tool_Crop;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
785 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
786
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
787 case 'e':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
788 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
789 Orthanc::DicomMap tags;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
790
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
791 // Minimal set of tags to generate a valid CR image
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
792 tags.SetValue(Orthanc::DICOM_TAG_ACCESSION_NUMBER, "NOPE", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
793 tags.SetValue(Orthanc::DICOM_TAG_BODY_PART_EXAMINED, "PELVIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
794 tags.SetValue(Orthanc::DICOM_TAG_INSTANCE_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
795 //tags.SetValue(Orthanc::DICOM_TAG_LATERALITY, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
796 tags.SetValue(Orthanc::DICOM_TAG_MANUFACTURER, "OSIMIS", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
797 tags.SetValue(Orthanc::DICOM_TAG_MODALITY, "CR", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
798 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_BIRTH_DATE, "20000101", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
799 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
800 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
801 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ORIENTATION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
802 tags.SetValue(Orthanc::DICOM_TAG_PATIENT_SEX, "M", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
803 tags.SetValue(Orthanc::DICOM_TAG_REFERRING_PHYSICIAN_NAME, "HOUSE^MD", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
804 tags.SetValue(Orthanc::DICOM_TAG_SERIES_NUMBER, "1", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
805 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
806 tags.SetValue(Orthanc::DICOM_TAG_STUDY_ID, "STUDY", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
807 tags.SetValue(Orthanc::DICOM_TAG_VIEW_POSITION, "", false);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
808
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
809 widget.GetScene().ExportDicom(tags, 0.1, 0.1, widget.IsInverted(),
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
810 widget.GetInterpolation(), EXPORT_USING_PAM);
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
811 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
812 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
813
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
814 case 'i':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
815 widget.SwitchInvert();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
816 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
817
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
818 case 'm':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
819 tool_ = Tool_Move;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
820 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
821
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
822 case 'n':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
823 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
824 switch (widget.GetInterpolation())
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
825 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
826 case ImageInterpolation_Nearest:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
827 LOG(INFO) << "Switching to bilinear interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
828 widget.SetInterpolation(ImageInterpolation_Bilinear);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
829 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
830
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
831 case ImageInterpolation_Bilinear:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
832 LOG(INFO) << "Switching to nearest neighbor interpolation";
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
833 widget.SetInterpolation(ImageInterpolation_Nearest);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
834 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
835
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
836 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
837 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
838 }
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
839
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
840 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
841 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
842
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
843 case 'r':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
844 tool_ = Tool_Rotate;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
845 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
846
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
847 case 's':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
848 tool_ = Tool_Resize;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
849 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
850
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
851 case 'w':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
852 tool_ = Tool_Windowing;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
853 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
854
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
855 case 'y':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
856 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
857 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
858 undoRedoStack_.Redo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
859 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
860 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
861 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
862
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
863 case 'z':
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
864 if (modifiers & KeyboardModifiers_Control)
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
865 {
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
866 undoRedoStack_.Undo();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
867 widget.NotifyContentChanged();
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
868 }
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
869 break;
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
870
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
871 default:
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
872 break;
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
873 }
345
55438b1ca317 drawing borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 344
diff changeset
874 }
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
875 };
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
876
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
877
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
878
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
879 class SingleFrameEditorApplication :
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
880 public SampleSingleCanvasApplicationBase,
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
881 public IObserver
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
882 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
883 private:
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
884 std::auto_ptr<OrthancApiClient> orthancApiClient_;
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
885 std::auto_ptr<RadiographyScene> scene_;
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
886 RadiographyEditorInteractor interactor_;
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
887
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
888 public:
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
889 SingleFrameEditorApplication(MessageBroker& broker) :
362
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
890 IObserver(broker),
12cec26d08ce export of a valid DICOM CR
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 361
diff changeset
891 interactor_(broker)
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
892 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
893 }
384
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
894
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
895 virtual ~SingleFrameEditorApplication()
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
896 {
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
897 LOG(WARNING) << "Destroying the application";
d20d75f20c5d better following of the MVC design pattern
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
898 }
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
899
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
900 virtual void DeclareStartupOptions(boost::program_options::options_description& options)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
901 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
902 boost::program_options::options_description generic("Sample options");
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
903 generic.add_options()
340
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
904 ("instance", boost::program_options::value<std::string>(),
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
905 "Orthanc ID of the instance")
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
906 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
907 "Number of the frame, for multi-frame DICOM instances")
f5d5814a41a0 rendering BitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 339
diff changeset
908 ;
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
909
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
910 options.add(generic);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
911 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
912
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
913 virtual void Initialize(StoneApplicationContext* context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
914 IStatusBar& statusBar,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
915 const boost::program_options::variables_map& parameters)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
916 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
917 using namespace OrthancStone;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
918
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
919 context_ = context;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
920
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
921 statusBar.SetMessage("Use the key \"a\" to reinitialize the layout");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
922 statusBar.SetMessage("Use the key \"c\" to crop");
359
100df90bf0ea preparing to implement Export
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
923 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
924 statusBar.SetMessage("Use the key \"f\" to switch full screen");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
925 statusBar.SetMessage("Use the key \"i\" to invert contrast");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
926 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
927 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
928 statusBar.SetMessage("Use the key \"r\" to rotate objects");
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
929 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
930 statusBar.SetMessage("Use the key \"w\" to change windowing");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
931
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
932 statusBar.SetMessage("Use the key \"ctrl-z\" to undo action");
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
933 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
934
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
935 if (parameters.count("instance") != 1)
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
936 {
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
937 LOG(ERROR) << "The instance ID is missing";
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
938 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
939 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
940
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
941 std::string instance = parameters["instance"].as<std::string>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
942 int frame = parameters["frame"].as<unsigned int>();
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
943
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 392
diff changeset
944 orthancApiClient_.reset(new OrthancApiClient(GetBroker(), context_->GetWebService()));
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
945
343
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
946 Orthanc::FontRegistry fonts;
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
947 fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16);
712acc87fa2e text layer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 342
diff changeset
948
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
949 scene_.reset(new RadiographyScene(GetBroker(), *orthancApiClient_));
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
950 scene_->LoadDicomFrame(instance, frame, false); //.SetPan(200, 0);
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
951 //scene_->LoadDicomFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
952
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
953 {
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
954 RadiographyLayer& layer = scene_->LoadText(fonts.GetFont(0), "Hello\nworld");
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
955 layer.SetResizeable(true);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
956 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
957
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
958 {
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
959 RadiographyLayer& layer = scene_->LoadTestBlock(100, 50);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
960 layer.SetResizeable(true);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 408
diff changeset
961 layer.SetPan(0, 200);
354
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
962 }
f806779bd40f UndoRedoStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 353
diff changeset
963
337
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
964
408
6834c236b36d reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 407
diff changeset
965 mainWidget_ = new RadiographyWidget(GetBroker(), *scene_, "main-widget");
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
966 mainWidget_->SetTransmitMouseOver(true);
358
b8eeb49f3e65 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 357
diff changeset
967 mainWidget_->SetInteractor(interactor_);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
968
407
842a3c7cfdc0 renames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
969 //scene_->SetWindowing(128, 256);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
970 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
971 };
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
972 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
diff changeset
973 }