annotate Applications/Samples/SingleFrameApplication.h @ 145:6941b98cf0fd wasm

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Jan 2018 16:44:52 +0100
parents e2fe9352f240
children f48c5d422d45
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
135
e2fe9352f240 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 121
diff changeset
5 * Copyright (C) 2017-2018 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
79
4e21f6b3aa0d cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
26 #include "../../Framework/Layers/OrthancFrameLayerSource.h"
4e21f6b3aa0d cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
27 #include "../../Framework/Widgets/LayerWidget.h"
116
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
28
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
29 #include <Core/Logging.h>
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace Samples
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
35 class SingleFrameApplication :
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
36 public SampleApplicationBase,
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
37 private ILayerSource::IObserver
0
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 private:
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
40 class Interactor : public IWorldSceneInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
41 {
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
42 private:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
43 SingleFrameApplication& application_;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
44
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
45 public:
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
46 Interactor(SingleFrameApplication& application) :
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
47 application_(application)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
48 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
49 }
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
50
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
51 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
52 const ViewportGeometry& view,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
53 MouseButton button,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
54 double x,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
55 double y,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
56 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
57 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
58 return NULL;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
59 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
60
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
61 virtual void MouseOver(CairoContext& context,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
62 WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
63 const ViewportGeometry& view,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
64 double x,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
65 double y,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
66 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
67 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
68 if (statusBar != NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
69 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
70 Vector p = dynamic_cast<LayerWidget&>(widget).GetSlice().MapSliceToWorldCoordinates(x, y);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
71
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
72 char buf[64];
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
73 sprintf(buf, "X = %.02f Y = %.02f Z = %.02f (in cm)",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
74 p[0] / 10.0, p[1] / 10.0, p[2] / 10.0);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
75 statusBar->SetMessage(buf);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
76 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
77 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
78
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
79 virtual void MouseWheel(WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
80 MouseWheelDirection direction,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
81 KeyboardModifiers modifiers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
82 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
83 {
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
84 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
85
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
86 switch (direction)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
87 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
88 case MouseWheelDirection_Up:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
89 application_.OffsetSlice(-scale);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
90 break;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
91
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
92 case MouseWheelDirection_Down:
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
93 application_.OffsetSlice(scale);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
94 break;
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 default:
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 }
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
99 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
100
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
101 virtual void KeyPressed(WorldSceneWidget& widget,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
102 char key,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
103 KeyboardModifiers modifiers,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
104 IStatusBar* statusBar)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
105 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
106 switch (key)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
107 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
108 case 's':
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
109 widget.SetDefaultView();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
110 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
112 default:
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
113 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
114 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
115 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
116 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
117
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
118
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
119 void OffsetSlice(int offset)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
120 {
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
121 if (source_ != NULL)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
122 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
123 int slice = static_cast<int>(slice_) + offset;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
124
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
125 if (slice < 0)
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 slice = 0;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
128 }
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
129
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
130 if (slice >= static_cast<int>(source_->GetSliceCount()))
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 slice = source_->GetSliceCount() - 1;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
133 }
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
134
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
135 if (slice != static_cast<int>(slice_))
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 SetSlice(slice);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
138 }
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 }
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
141
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
142
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
143 void SetSlice(size_t index)
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 if (source_ != NULL &&
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
146 index < source_->GetSliceCount())
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
147 {
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
148 slice_ = index;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
149
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
150 #if 1
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
151 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
152 #else
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
153 // TEST for scene extents - Rotate the axes
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
154 double a = 15.0 / 180.0 * M_PI;
101
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
155
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
156 #if 1
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
157 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
158 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
159 #else
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
160 // Flip the normal
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
161 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
162 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
163 #endif
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
164
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
165 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
166 widget_->SetSlice(s);
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
167 #endif
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
168 }
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
169 }
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
170
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
171
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
172 virtual void NotifyGeometryReady(const ILayerSource& source)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
173 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
174 // Once the geometry of the series is downloaded from Orthanc,
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
175 // display its first slice, and adapt the viewport to fit this
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
176 // slice
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
177 if (source_ == &source)
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
178 {
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
179 SetSlice(source_->GetSliceCount() / 2);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
180 }
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
181
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
182 widget_->SetDefaultView();
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
183 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
184
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
185 virtual void NotifyGeometryError(const ILayerSource& source)
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
186 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
187 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
188
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
189 virtual void NotifyContentChange(const ILayerSource& source)
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
190 {
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
191 }
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
192
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
193 virtual void NotifySliceChange(const ILayerSource& source,
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
194 const Slice& slice)
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
195 {
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
196 }
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
197
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
198 virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer,
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
199 const ILayerSource& source,
121
e66b2c757790 displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
200 const CoordinateSystem3D& slice,
96
f8bce1bebe01 removal of the NotifyLayerError callback
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 94
diff changeset
201 bool isError)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
202 {
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
203 }
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
204
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
205 LayerWidget* widget_;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
206 const OrthancFrameLayerSource* source_;
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
207 unsigned int slice_;
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
208
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
209 public:
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
210 SingleFrameApplication() :
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
211 widget_(NULL),
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
212 source_(NULL),
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
213 slice_(0)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
214 {
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
215 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
216
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 virtual void DeclareCommandLineOptions(boost::program_options::options_description& options)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 boost::program_options::options_description generic("Sample options");
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 generic.add_options()
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 ("instance", boost::program_options::value<std::string>(),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 "Orthanc ID of the instance")
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 "Number of the frame, for multi-frame DICOM instances")
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 ("smooth", boost::program_options::value<bool>()->default_value(true),
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 "Enable linear interpolation to smooth the image")
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 ;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 options.add(generic);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 virtual void Initialize(BasicApplicationContext& context,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 IStatusBar& statusBar,
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 const boost::program_options::variables_map& parameters)
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 using namespace OrthancStone;
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
238 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
239
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 if (parameters.count("instance") != 1)
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 LOG(ERROR) << "The instance ID is missing";
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 std::string instance = parameters["instance"].as<std::string>();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 int frame = parameters["frame"].as<unsigned int>();
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
249 std::auto_ptr<LayerWidget> widget(new LayerWidget);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
250
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 101
diff changeset
251 #if 1
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
252 std::auto_ptr<OrthancFrameLayerSource> layer
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
253 (new OrthancFrameLayerSource(context.GetWebService()));
100
166a555becbf fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 98
diff changeset
254 //layer->SetImageQuality(SliceImageQuality_Jpeg50);
117
42c05a3baee3 loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 116
diff changeset
255 layer->LoadFrame(instance, frame);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
256 //layer->LoadSeries("6f1b492a-e181e200-44e51840-ef8db55e-af529ab6");
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
257 layer->Register(*this);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
258 source_ = layer.get();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
259 widget->AddLayer(layer.release());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
260
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
261 RenderStyle s;
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
262
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
263 if (parameters["smooth"].as<bool>())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
264 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
265 s.interpolation_ = ImageInterpolation_Linear;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
266 }
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
267
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
268 //s.drawGrid_ = true;
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
269 widget->SetLayerStyle(0, s);
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
270 #else
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
271 // 0178023P**
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
272 // Extent of the CT layer: (-35.068 -20.368) => (34.932 49.632)
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
273 std::auto_ptr<OrthancFrameLayerSource> ct;
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
274 ct.reset(new OrthancFrameLayerSource(context.GetWebService()));
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
275 //ct->LoadInstance("c804a1a2-142545c9-33b32fe2-3df4cec0-a2bea6d6", 0);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
276 //ct->LoadInstance("4bd4304f-47478948-71b24af2-51f4f1bc-275b6c1b", 0); // BAD SLICE
101
af312ce4fe59 support of 3D swapping of the normal
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 100
diff changeset
277 //ct->SetImageQuality(SliceImageQuality_Jpeg50);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
278 ct->LoadSeries("dd069910-4f090474-7d2bba07-e5c10783-f9e4fb1d");
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
279
90
64e60018943f fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 89
diff changeset
280 ct->Register(*this);
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
281 widget->AddLayer(ct.release());
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
282
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
283 std::auto_ptr<OrthancFrameLayerSource> pet;
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
284 pet.reset(new OrthancFrameLayerSource(context.GetWebService()));
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
285 //pet->LoadInstance("a1c4dc6b-255d27f0-88069875-8daed730-2f5ee5c6", 0);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
286 pet->LoadSeries("aabad2e7-80702b5d-e599d26c-4f13398e-38d58a9e");
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
287 pet->Register(*this);
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
288 source_ = pet.get();
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
289 widget->AddLayer(pet.release());
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
290
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
291 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
292 RenderStyle s;
97
d18dcc963930 separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 96
diff changeset
293 //s.drawGrid_ = true;
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
294 s.alpha_ = 1;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
295 widget->SetLayerStyle(0, s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
296 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
297
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
298 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
299 RenderStyle s;
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 85
diff changeset
300 //s.drawGrid_ = true;
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
301 s.SetColor(255, 0, 0); // Draw missing PET layer in red
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
302 s.alpha_ = 0.5;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
303 s.applyLut_ = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
304 s.lut_ = Orthanc::EmbeddedResources::COLORMAP_JET;
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
305 s.interpolation_ = ImageInterpolation_Linear;
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
306 widget->SetLayerStyle(1, s);
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
307 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
308 #endif
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
309
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
310 widget_ = widget.get();
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 79
diff changeset
311 widget_->SetTransmitMouseOver(true);
98
a33abae66344 scrolling over series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
312 widget_->SetInteractor(context.AddInteractor(new Interactor(*this)));
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
313 context.SetCentralWidget(widget.release());
0
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 };
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 }
351ab0da0150 initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }