Mercurial > hg > orthanc-stone
annotate Applications/Samples/SingleFrameApplication.h @ 1124:a8bf81756839 broker
unsuccessful attempt to cache ParseDicomFileCommand
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 05 Nov 2019 18:49:06 +0100 |
parents | 5d1b0d2f4b15 |
children | 0ca50d275b9a |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "SampleApplicationBase.h" | |
25 | |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
26 #include "../../Framework/Deprecated/Layers/DicomSeriesVolumeSlicer.h" |
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
27 #include "../../Framework/Deprecated/Widgets/SliceViewerWidget.h" |
116 | 28 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
29 #include <Core/Logging.h> |
403 | 30 #include <Core/OrthancException.h> |
0 | 31 |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
32 #include <boost/math/constants/constants.hpp> |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
33 |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
34 |
0 | 35 namespace OrthancStone |
36 { | |
37 namespace Samples | |
38 { | |
66 | 39 class SingleFrameApplication : |
326 | 40 public SampleSingleCanvasApplicationBase, |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
41 public ObserverBase<SingleFrameApplication> |
0 | 42 { |
66 | 43 private: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
44 class Interactor : public Deprecated::IWorldSceneInteractor |
85 | 45 { |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
46 private: |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
47 SingleFrameApplication& application_; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
48 |
85 | 49 public: |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
50 Interactor(SingleFrameApplication& application) : |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
51 application_(application) |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
52 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
53 } |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
54 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
55 virtual Deprecated::IWorldSceneMouseTracker* CreateMouseTracker(Deprecated::WorldSceneWidget& widget, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
56 const Deprecated::ViewportGeometry& view, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
57 MouseButton button, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
58 KeyboardModifiers modifiers, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
59 int viewportX, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
60 int viewportY, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
61 double x, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
62 double y, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
63 Deprecated::IStatusBar* statusBar, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
64 const std::vector<Deprecated::Touch>& displayTouches) |
85 | 65 { |
66 return NULL; | |
67 } | |
68 | |
69 virtual void MouseOver(CairoContext& context, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
70 Deprecated::WorldSceneWidget& widget, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
71 const Deprecated::ViewportGeometry& view, |
85 | 72 double x, |
73 double y, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
74 Deprecated::IStatusBar* statusBar) |
85 | 75 { |
76 if (statusBar != NULL) | |
77 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
78 Vector p = dynamic_cast<Deprecated::SliceViewerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y); |
85 | 79 |
80 char buf[64]; | |
81 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)", | |
82 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0); | |
83 statusBar->SetMessage(buf); | |
84 } | |
85 } | |
86 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
87 virtual void MouseWheel(Deprecated::WorldSceneWidget& widget, |
85 | 88 MouseWheelDirection direction, |
89 KeyboardModifiers modifiers, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
90 Deprecated::IStatusBar* statusBar) |
85 | 91 { |
102 | 92 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1); |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
93 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
94 switch (direction) |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
95 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
96 case MouseWheelDirection_Up: |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
97 application_.OffsetSlice(-scale); |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
98 break; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
99 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
100 case MouseWheelDirection_Down: |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
101 application_.OffsetSlice(scale); |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
102 break; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
103 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
104 default: |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
105 break; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
106 } |
85 | 107 } |
108 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
109 virtual void KeyPressed(Deprecated::WorldSceneWidget& widget, |
327 | 110 KeyboardKeys key, |
111 char keyChar, | |
85 | 112 KeyboardModifiers modifiers, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
113 Deprecated::IStatusBar* statusBar) |
85 | 114 { |
327 | 115 switch (keyChar) |
85 | 116 { |
117 case 's': | |
330 | 118 widget.FitContent(); |
85 | 119 break; |
120 | |
121 default: | |
122 break; | |
123 } | |
124 } | |
125 }; | |
126 | |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
127 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
128 void OffsetSlice(int offset) |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
129 { |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
130 if (source_) |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
131 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
132 int slice = static_cast<int>(slice_) + offset; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
133 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
134 if (slice < 0) |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
135 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
136 slice = 0; |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
137 } |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
138 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
528
diff
changeset
|
139 if (slice >= static_cast<int>(source_->GetSlicesCount())) |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
140 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
528
diff
changeset
|
141 slice = static_cast<int>(source_->GetSlicesCount()) - 1; |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
142 } |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
143 |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
144 if (slice != static_cast<int>(slice_)) |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
145 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
146 SetSlice(slice); |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
147 } |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
148 } |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
149 } |
336
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
150 |
c7fdc8bac581
creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
334
diff
changeset
|
151 |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
152 void SetSlice(size_t index) |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
153 { |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
154 if (source_ && |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
528
diff
changeset
|
155 index < source_->GetSlicesCount()) |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
156 { |
528 | 157 slice_ = static_cast<unsigned int>(index); |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
158 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
159 #if 1 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
160 widget_->SetSlice(source_->GetSlice(slice_).GetGeometry()); |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
161 #else |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
162 // TEST for scene extents - Rotate the axes |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
356
diff
changeset
|
163 double a = 15.0 / 180.0 * boost::math::constants::pi<double>(); |
101
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
164 |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
165 #if 1 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
166 Vector x; GeometryToolbox::AssignVector(x, cos(a), sin(a), 0); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
167 Vector y; GeometryToolbox::AssignVector(y, -sin(a), cos(a), 0); |
101
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
168 #else |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
169 // Flip the normal |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
170 Vector x; GeometryToolbox::AssignVector(x, cos(a), sin(a), 0); |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
171 Vector y; GeometryToolbox::AssignVector(y, sin(a), -cos(a), 0); |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
172 #endif |
af312ce4fe59
support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
173 |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
174 SliceGeometry s(source_->GetSlice(slice_).GetGeometry().GetOrigin(), x, y); |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
175 widget_->SetSlice(s); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
176 #endif |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
177 } |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
178 } |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
179 |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
180 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
181 void OnMainWidgetGeometryReady(const Deprecated::IVolumeSlicer::GeometryReadyMessage& message) |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
182 { |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
183 // Once the geometry of the series is downloaded from Orthanc, |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
184 // display its middle slice, and adapt the viewport to fit this |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
185 // slice |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
186 if (source_ && |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
187 source_.get() == &message.GetOrigin()) |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
188 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
528
diff
changeset
|
189 SetSlice(source_->GetSlicesCount() / 2); |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
190 } |
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
191 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
192 widget_->FitContent(); |
66 | 193 } |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
194 |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
195 boost::shared_ptr<Deprecated::SliceViewerWidget> widget_; |
334
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
196 std::auto_ptr<Interactor> mainWidgetInteractor_; |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
197 boost::shared_ptr<Deprecated::DicomSeriesVolumeSlicer> source_; |
334
c34784e5f299
compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
198 unsigned int slice_; |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
199 |
0 | 200 public: |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
201 SingleFrameApplication() : |
98
a33abae66344
scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
202 slice_(0) |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
85
diff
changeset
|
203 { |
66 | 204 } |
205 | |
235
ce4405d98b92
Added SimpleViewerApplication (working in SDL)
am@osimis.io
parents:
212
diff
changeset
|
206 virtual void DeclareStartupOptions(boost::program_options::options_description& options) |
0 | 207 { |
208 boost::program_options::options_description generic("Sample options"); | |
209 generic.add_options() | |
210 ("instance", boost::program_options::value<std::string>(), | |
211 "Orthanc ID of the instance") | |
212 ("frame", boost::program_options::value<unsigned int>()->default_value(0), | |
213 "Number of the frame, for multi-frame DICOM instances") | |
214 ("smooth", boost::program_options::value<bool>()->default_value(true), | |
147
f48c5d422d45
removed meaningless ImageInterpolation_Linear value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
215 "Enable bilinear interpolation to smooth the image") |
0 | 216 ; |
217 | |
218 options.add(generic); | |
219 } | |
220 | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
221 virtual void Initialize(StoneApplicationContext* context, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
222 Deprecated::IStatusBar& statusBar, |
0 | 223 const boost::program_options::variables_map& parameters) |
224 { | |
225 using namespace OrthancStone; | |
226 | |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
227 context_ = context; |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
228 |
85 | 229 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); |
230 | |
0 | 231 if (parameters.count("instance") != 1) |
232 { | |
233 LOG(ERROR) << "The instance ID is missing"; | |
234 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
235 } | |
236 | |
237 std::string instance = parameters["instance"].as<std::string>(); | |
238 int frame = parameters["frame"].as<unsigned int>(); | |
239 | |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
240 widget_.reset(new Deprecated::SliceViewerWidget("main-widget")); |
1069 | 241 SetCentralWidget(widget_); |
0 | 242 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
243 boost::shared_ptr<Deprecated::DicomSeriesVolumeSlicer> layer(new Deprecated::DicomSeriesVolumeSlicer); |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
244 layer->Connect(context->GetOrthancApiClient()); |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
245 source_ = layer; |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
116
diff
changeset
|
246 layer->LoadFrame(instance, frame); |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
247 Register<Deprecated::IVolumeSlicer::GeometryReadyMessage>(*layer, &SingleFrameApplication::OnMainWidgetGeometryReady); |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
248 widget_->AddLayer(layer); |
66 | 249 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
250 Deprecated::RenderStyle s; |
0 | 251 |
252 if (parameters["smooth"].as<bool>()) | |
253 { | |
147
f48c5d422d45
removed meaningless ImageInterpolation_Linear value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
254 s.interpolation_ = ImageInterpolation_Bilinear; |
66 | 255 } |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
256 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
257 widget_->SetLayerStyle(0, s); |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
258 widget_->SetTransmitMouseOver(true); |
66 | 259 |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
260 mainWidgetInteractor_.reset(new Interactor(*this)); |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
261 widget_->SetInteractor(*mainWidgetInteractor_); |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
262 } |
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
263 }; |
85 | 264 |
325
37ab9d83dc9b
reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents:
235
diff
changeset
|
265 |
0 | 266 } |
267 } |