annotate Applications/Samples/SingleFrameApplication.h @ 441:56ddca73396c am-vsol-upgrade

allow null callbacks for HTTP requests
author Alain Mazy <alain@mazy.be>
date Mon, 14 Jan 2019 11:27:26 +0100
parents b70e9be013e4
children 3b4df9925db6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
10 * the License, or (at your option) any later version.
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
47
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
15 * Affero General Public License for more details.
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
16 *
28956ed68280 agpl license
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 40
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "SampleApplicationBase.h"
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
26 #include "../../Framework/Layers/DicomSeriesVolumeSlicer.h"
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
27 #include "../../Framework/Widgets/SliceViewerWidget.h"
116
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
28
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
29 #include <Core/Logging.h>
403
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
30 #include <Core/OrthancException.h>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 namespace Samples
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
39 class SingleFrameApplication :
326
612238b3f3e8 all 4 samples now working in Qt, SDL and wasm
am@osimis.io
parents: 325
diff changeset
40 public SampleSingleCanvasApplicationBase,
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
41 public IObserver
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
43 private:
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
44 class Interactor : public IWorldSceneInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
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
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
55 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
56 const ViewportGeometry& view,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
57 MouseButton button,
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
58 KeyboardModifiers modifiers,
356
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
59 int viewportX,
885f0a5eaa49 mouse tracker to set windowing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
60 int viewportY,
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
61 double x,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
62 double y,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
63 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
64 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
65 return NULL;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
66 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
67
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
68 virtual void MouseOver(CairoContext& context,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
69 WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
70 const ViewportGeometry& view,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
71 double x,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
72 double y,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
73 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
74 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
75 if (statusBar != NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
76 {
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
77 Vector p = dynamic_cast<SliceViewerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y);
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
78
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
79 char buf[64];
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
80 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
81 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
82 statusBar->SetMessage(buf);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
83 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
84 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
86 virtual void MouseWheel(WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
87 MouseWheelDirection direction,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
88 KeyboardModifiers modifiers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
89 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
90 {
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
91 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
92
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
93 switch (direction)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
94 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
95 case MouseWheelDirection_Up:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
96 application_.OffsetSlice(-scale);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
97 break;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
99 case MouseWheelDirection_Down:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
100 application_.OffsetSlice(scale);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
101 break;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
102
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
103 default:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
104 break;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
105 }
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
106 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
107
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
108 virtual void KeyPressed(WorldSceneWidget& widget,
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
109 KeyboardKeys key,
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
110 char keyChar,
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
111 KeyboardModifiers modifiers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
112 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
113 {
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 326
diff changeset
114 switch (keyChar)
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
115 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
116 case 's':
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 327
diff changeset
117 widget.FitContent();
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
118 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
119
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
120 default:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
121 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
122 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
123 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
124 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
125
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
126
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
127 void OffsetSlice(int offset)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
128 {
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
129 if (source_ != NULL)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
130 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
131 int slice = static_cast<int>(slice_) + offset;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
132
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
133 if (slice < 0)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
134 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
135 slice = 0;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
136 }
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 if (slice >= static_cast<int>(source_->GetSliceCount()))
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
139 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
140 slice = source_->GetSliceCount() - 1;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
141 }
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
142
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
143 if (slice != static_cast<int>(slice_))
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
144 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
145 SetSlice(slice);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
146 }
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 }
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
149
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
150
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
151 SliceViewerWidget& GetMainWidget()
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
152 {
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
153 return *dynamic_cast<SliceViewerWidget*>(mainWidget_);
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
154 }
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
155
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
156
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
157 void SetSlice(size_t index)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
158 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
159 if (source_ != NULL &&
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
160 index < source_->GetSliceCount())
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
161 {
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
162 slice_ = index;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
163
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
164 #if 1
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
165 GetMainWidget().SetSlice(source_->GetSlice(slice_).GetGeometry());
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
166 #else
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
167 // 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
168 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
169
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
170 #if 1
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
171 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
172 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
173 #else
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
174 // Flip the normal
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
175 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
176 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
177 #endif
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
178
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
179 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
180 widget_->SetSlice(s);
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
181 #endif
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
182 }
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
183 }
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
184
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
185
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
186 void OnMainWidgetGeometryReady(const IVolumeSlicer::GeometryReadyMessage& message)
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
187 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
188 // 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
189 // 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
190 // slice
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
191 if (source_ == &message.GetOrigin())
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
192 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
193 SetSlice(source_->GetSliceCount() / 2);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
194 }
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
195
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
196 GetMainWidget().FitContent();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
197 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
198
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
199 std::auto_ptr<Interactor> mainWidgetInteractor_;
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
200 const DicomSeriesVolumeSlicer* source_;
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
201 unsigned int slice_;
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
202
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 public:
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
204 SingleFrameApplication(MessageBroker& broker) :
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
205 IObserver(broker),
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
206 source_(NULL),
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
207 slice_(0)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
208 {
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
209 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
210
235
ce4405d98b92 Added SimpleViewerApplication (working in SDL)
am@osimis.io
parents: 212
diff changeset
211 virtual void DeclareStartupOptions(boost::program_options::options_description& options)
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 boost::program_options::options_description generic("Sample options");
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 generic.add_options()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 ("instance", boost::program_options::value<std::string>(),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 "Orthanc ID of the instance")
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 "Number of the frame, for multi-frame DICOM instances")
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 ("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
220 "Enable bilinear interpolation to smooth the image")
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 ;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 options.add(generic);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
226 virtual void Initialize(StoneApplicationContext* context,
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
227 IStatusBar& statusBar,
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 const boost::program_options::variables_map& parameters)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 using namespace OrthancStone;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
232 context_ = context;
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
233
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
234 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
235
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 if (parameters.count("instance") != 1)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 LOG(ERROR) << "The instance ID is missing";
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 std::string instance = parameters["instance"].as<std::string>();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 int frame = parameters["frame"].as<unsigned int>();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
245 mainWidget_ = new SliceViewerWidget(GetBroker(), "main-widget");
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
247 std::auto_ptr<DicomSeriesVolumeSlicer> layer(new DicomSeriesVolumeSlicer(GetBroker(), context->GetOrthancApiClient()));
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
248 source_ = layer.get();
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 116
diff changeset
249 layer->LoadFrame(instance, frame);
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
250 layer->RegisterObserverCallback(new Callable<SingleFrameApplication, IVolumeSlicer::GeometryReadyMessage>(*this, &SingleFrameApplication::OnMainWidgetGeometryReady));
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
251 GetMainWidget().AddLayer(layer.release());
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
252
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
253 RenderStyle s;
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 if (parameters["smooth"].as<bool>())
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 {
147
f48c5d422d45 removed meaningless ImageInterpolation_Linear value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
257 s.interpolation_ = ImageInterpolation_Bilinear;
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
258 }
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
259
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
260 GetMainWidget().SetLayerStyle(0, s);
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
261 GetMainWidget().SetTransmitMouseOver(true);
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
262
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
263 mainWidgetInteractor_.reset(new Interactor(*this));
336
c7fdc8bac581 creating GrayscaleBitmapStack
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 334
diff changeset
264 GetMainWidget().SetInteractor(*mainWidgetInteractor_);
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
265 }
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
266 };
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
267
325
37ab9d83dc9b reactivate SingleFrameApplication sample + Added SingleFrameEditorApplication (SDL only)
am@osimis.io
parents: 235
diff changeset
268
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }