Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Widgets/SliceViewerWidget.cpp @ 1215:9efa66d8d3f8 broker
removed ViewportBase, and removed dependency of ViewportController on IViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 04 Dec 2019 20:12:15 +0100 |
parents | 04a95ee91327 |
children | 0ca50d275b9a |
rev | line source |
---|---|
66 | 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 |
66 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
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. | |
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 | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
16 * |
66 | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
22 #include "SliceViewerWidget.h" |
66 | 23 |
99 | 24 #include "../Layers/SliceOutlineRenderer.h" |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
25 #include "../../Toolbox/GeometryToolbox.h" |
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
26 #include "../Layers/FrameRenderer.h" |
85 | 27 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
28 #include <Core/Logging.h> |
403 | 29 #include <Core/OrthancException.h> |
113
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
30 |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
31 #include <boost/math/constants/constants.hpp> |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
32 |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
33 |
85 | 34 static const double THIN_SLICE_THICKNESS = 100.0 * std::numeric_limits<double>::epsilon(); |
66 | 35 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
36 namespace Deprecated |
66 | 37 { |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
38 class SliceViewerWidget::Scene : public boost::noncopyable |
66 | 39 { |
40 private: | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
41 OrthancStone::CoordinateSystem3D plane_; |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
42 double thickness_; |
66 | 43 size_t countMissing_; |
44 std::vector<ILayerRenderer*> renderers_; | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
45 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
46 public: |
66 | 47 void DeleteLayer(size_t index) |
48 { | |
49 if (index >= renderers_.size()) | |
50 { | |
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
52 } | |
53 | |
54 assert(countMissing_ <= renderers_.size()); | |
55 | |
56 if (renderers_[index] != NULL) | |
57 { | |
58 assert(countMissing_ < renderers_.size()); | |
59 delete renderers_[index]; | |
60 renderers_[index] = NULL; | |
61 countMissing_++; | |
62 } | |
63 } | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
64 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
65 Scene(const OrthancStone::CoordinateSystem3D& plane, |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
66 double thickness, |
66 | 67 size_t countLayers) : |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
68 plane_(plane), |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
69 thickness_(thickness), |
66 | 70 countMissing_(countLayers), |
71 renderers_(countLayers, NULL) | |
72 { | |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
73 if (thickness <= 0) |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
74 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
76 } |
66 | 77 } |
78 | |
79 ~Scene() | |
80 { | |
81 for (size_t i = 0; i < renderers_.size(); i++) | |
82 { | |
83 DeleteLayer(i); | |
84 } | |
85 } | |
86 | |
87 void SetLayer(size_t index, | |
88 ILayerRenderer* renderer) // Takes ownership | |
89 { | |
90 if (renderer == NULL) | |
91 { | |
92 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
93 } | |
94 | |
95 DeleteLayer(index); | |
96 | |
97 renderers_[index] = renderer; | |
98 countMissing_--; | |
99 } | |
100 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
101 const OrthancStone::CoordinateSystem3D& GetPlane() const |
66 | 102 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
103 return plane_; |
66 | 104 } |
105 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
106 bool HasRenderer(size_t index) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
107 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
108 return renderers_[index] != NULL; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
109 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
110 |
66 | 111 bool IsComplete() const |
112 { | |
113 return countMissing_ == 0; | |
114 } | |
115 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
116 unsigned int GetCountMissing() const |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
117 { |
693
9a474e90e832
Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents:
623
diff
changeset
|
118 return static_cast<unsigned int>(countMissing_); |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
119 } |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
120 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
121 bool RenderScene(OrthancStone::CairoContext& context, |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
122 const ViewportGeometry& view, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
123 const OrthancStone::CoordinateSystem3D& viewportPlane) |
66 | 124 { |
125 bool fullQuality = true; | |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
126 cairo_t *cr = context.GetObject(); |
66 | 127 |
128 for (size_t i = 0; i < renderers_.size(); i++) | |
129 { | |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
130 if (renderers_[i] != NULL) |
66 | 131 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
132 const OrthancStone::CoordinateSystem3D& framePlane = renderers_[i]->GetLayerPlane(); |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
133 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
134 double x0, y0, x1, y1, x2, y2; |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
135 viewportPlane.ProjectPoint(x0, y0, framePlane.GetOrigin()); |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
136 viewportPlane.ProjectPoint(x1, y1, framePlane.GetOrigin() + framePlane.GetAxisX()); |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
137 viewportPlane.ProjectPoint(x2, y2, framePlane.GetOrigin() + framePlane.GetAxisY()); |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
138 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
139 /** |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
140 * Now we solve the system of linear equations Ax + b = x', given: |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
141 * A [0 ; 0] + b = [x0 ; y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
142 * A [1 ; 0] + b = [x1 ; y1] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
143 * A [0 ; 1] + b = [x2 ; y2] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
144 * <=> |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
145 * b = [x0 ; y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
146 * A [1 ; 0] = [x1 ; y1] - b = [x1 - x0 ; y1 - y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
147 * A [0 ; 1] = [x2 ; y2] - b = [x2 - x0 ; y2 - y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
148 * <=> |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
149 * b = [x0 ; y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
150 * [a11 ; a21] = [x1 - x0 ; y1 - y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
151 * [a12 ; a22] = [x2 - x0 ; y2 - y0] |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
152 **/ |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
153 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
154 cairo_matrix_t transform; |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
155 cairo_matrix_init(&transform, x1 - x0, y1 - y0, x2 - x0, y2 - y0, x0, y0); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
156 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
157 cairo_save(cr); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
158 cairo_transform(cr, &transform); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
159 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
160 if (!renderers_[i]->RenderLayer(context, view)) |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
161 { |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
162 cairo_restore(cr); |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
163 return false; |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
164 } |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
165 |
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
166 cairo_restore(cr); |
66 | 167 } |
168 | |
169 if (renderers_[i] != NULL && | |
170 !renderers_[i]->IsFullQuality()) | |
171 { | |
172 fullQuality = false; | |
173 } | |
174 } | |
175 | |
176 if (!fullQuality) | |
177 { | |
178 double x, y; | |
179 view.MapDisplayToScene(x, y, static_cast<double>(view.GetDisplayWidth()) / 2.0, 10); | |
180 | |
181 cairo_translate(cr, x, y); | |
95 | 182 |
183 #if 1 | |
184 double s = 5.0 / view.GetZoom(); | |
185 cairo_rectangle(cr, -s, -s, 2.0 * s, 2.0 * s); | |
186 #else | |
376
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
187 // TODO Drawing filled circles makes WebAssembly crash! |
70256a53ff21
fix compatibility with Visual Studio 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
329
diff
changeset
|
188 cairo_arc(cr, 0, 0, 5.0 / view.GetZoom(), 0, 2.0 * boost::math::constants::pi<double>()); |
95 | 189 #endif |
190 | |
66 | 191 cairo_set_line_width(cr, 2.0 / view.GetZoom()); |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
192 cairo_set_source_rgb(cr, 1, 1, 1); |
66 | 193 cairo_stroke_preserve(cr); |
95 | 194 cairo_set_source_rgb(cr, 1, 0, 0); |
66 | 195 cairo_fill(cr); |
196 } | |
197 | |
198 return true; | |
199 } | |
200 | |
201 void SetLayerStyle(size_t index, | |
202 const RenderStyle& style) | |
203 { | |
204 if (renderers_[index] != NULL) | |
205 { | |
206 renderers_[index]->SetLayerStyle(style); | |
207 } | |
208 } | |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
209 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
210 bool ContainsPlane(const OrthancStone::CoordinateSystem3D& plane) const |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
211 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
212 bool isOpposite; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
213 if (!OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
214 plane.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
215 plane_.GetNormal())) |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
216 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
217 return false; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
218 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
219 else |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
220 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
221 double z = (plane_.ProjectAlongNormal(plane.GetOrigin()) - |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
222 plane_.ProjectAlongNormal(plane_.GetOrigin())); |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
223 |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
224 if (z < 0) |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
225 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
226 z = -z; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
227 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
228 |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
229 return z <= thickness_; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
230 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
231 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
232 |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
233 double GetThickness() const |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
234 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
235 return thickness_; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
236 } |
66 | 237 }; |
238 | |
239 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
240 bool SliceViewerWidget::LookupLayer(size_t& index /* out */, |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
241 const IVolumeSlicer& layer) const |
66 | 242 { |
243 LayersIndex::const_iterator found = layersIndex_.find(&layer); | |
244 | |
245 if (found == layersIndex_.end()) | |
246 { | |
247 return false; | |
248 } | |
249 else | |
250 { | |
251 index = found->second; | |
252 assert(index < layers_.size() && | |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
253 layers_[index].get() == &layer); |
66 | 254 return true; |
255 } | |
256 } | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
257 |
85 | 258 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
259 void SliceViewerWidget::GetLayerExtent(OrthancStone::Extent2D& extent, |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
260 IVolumeSlicer& source) const |
85 | 261 { |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
262 extent.Reset(); |
329
b10dfdb96866
removing WorldSceneWidget::IWorldObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
318
diff
changeset
|
263 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
264 std::vector<OrthancStone::Vector> points; |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
265 if (source.GetExtent(points, plane_)) |
85 | 266 { |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
267 for (size_t i = 0; i < points.size(); i++) |
85 | 268 { |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
269 double x, y; |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
270 plane_.ProjectPoint(x, y, points[i]); |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
271 extent.AddPoint(x, y); |
85 | 272 } |
273 } | |
274 } | |
275 | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
276 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
277 OrthancStone::Extent2D SliceViewerWidget::GetSceneExtent() |
66 | 278 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
279 OrthancStone::Extent2D sceneExtent; |
66 | 280 |
281 for (size_t i = 0; i < layers_.size(); i++) | |
282 { | |
283 assert(layers_[i] != NULL); | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
284 OrthancStone::Extent2D layerExtent; |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
285 GetLayerExtent(layerExtent, *layers_[i]); |
66 | 286 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
287 sceneExtent.Union(layerExtent); |
66 | 288 } |
289 | |
109
53bd9277b025
using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
103
diff
changeset
|
290 return sceneExtent; |
66 | 291 } |
292 | |
293 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
294 bool SliceViewerWidget::RenderScene(OrthancStone::CairoContext& context, |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
295 const ViewportGeometry& view) |
66 | 296 { |
297 if (currentScene_.get() != NULL) | |
298 { | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
299 return currentScene_->RenderScene(context, view, plane_); |
66 | 300 } |
301 else | |
302 { | |
303 return true; | |
304 } | |
305 } | |
306 | |
307 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
308 void SliceViewerWidget::ResetPendingScene() |
66 | 309 { |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
310 double thickness; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
311 if (pendingScene_.get() == NULL) |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
312 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
313 thickness = 1.0; |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
314 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
315 else |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
316 { |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
317 thickness = pendingScene_->GetThickness(); |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
318 } |
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
319 |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
320 pendingScene_.reset(new Scene(plane_, thickness, layers_.size())); |
66 | 321 } |
322 | |
323 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
324 void SliceViewerWidget::UpdateLayer(size_t index, |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
325 ILayerRenderer* renderer, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
326 const OrthancStone::CoordinateSystem3D& plane) |
66 | 327 { |
71
30c768873d47
OrthancSliceLoader::ScheduleLoadInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
66
diff
changeset
|
328 LOG(INFO) << "Updating layer " << index; |
66 | 329 |
330 std::auto_ptr<ILayerRenderer> tmp(renderer); | |
331 | |
332 if (renderer == NULL) | |
333 { | |
334 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
335 } | |
336 | |
337 if (index >= layers_.size()) | |
338 { | |
339 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
340 } | |
341 | |
342 assert(layers_.size() == styles_.size()); | |
343 renderer->SetLayerStyle(styles_[index]); | |
344 | |
345 if (currentScene_.get() != NULL && | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
346 currentScene_->ContainsPlane(plane)) |
66 | 347 { |
348 currentScene_->SetLayer(index, tmp.release()); | |
278 | 349 NotifyContentChanged(); |
66 | 350 } |
351 else if (pendingScene_.get() != NULL && | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
352 pendingScene_->ContainsPlane(plane)) |
66 | 353 { |
354 pendingScene_->SetLayer(index, tmp.release()); | |
355 | |
356 if (currentScene_.get() == NULL || | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
357 !currentScene_->IsComplete() || |
66 | 358 pendingScene_->IsComplete()) |
359 { | |
360 currentScene_ = pendingScene_; | |
278 | 361 NotifyContentChanged(); |
66 | 362 } |
363 } | |
364 } | |
365 | |
366 | |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
367 SliceViewerWidget::SliceViewerWidget(const std::string& name) : |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
368 WorldSceneWidget(name), |
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
369 started_(false) |
66 | 370 { |
371 SetBackgroundCleared(true); | |
372 } | |
373 | |
374 | |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
375 void SliceViewerWidget::ObserveLayer(IVolumeSlicer& layer) |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
376 { |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
377 // currently ignoring errors of type IVolumeSlicer::GeometryErrorMessage |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
378 |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
379 Register<IVolumeSlicer::GeometryReadyMessage>(layer, &SliceViewerWidget::OnGeometryReady); |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
380 Register<IVolumeSlicer::SliceContentChangedMessage>(layer, &SliceViewerWidget::OnSliceChanged); |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
381 Register<IVolumeSlicer::ContentChangedMessage>(layer, &SliceViewerWidget::OnContentChanged); |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
382 Register<IVolumeSlicer::LayerReadyMessage>(layer, &SliceViewerWidget::OnLayerReady); |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
383 Register<IVolumeSlicer::LayerErrorMessage>(layer, &SliceViewerWidget::OnLayerError); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
384 } |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
385 |
66 | 386 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
387 size_t SliceViewerWidget::AddLayer(boost::shared_ptr<IVolumeSlicer> layer) |
66 | 388 { |
389 if (layer == NULL) | |
390 { | |
391 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
392 } | |
393 | |
394 size_t index = layers_.size(); | |
395 layers_.push_back(layer); | |
396 styles_.push_back(RenderStyle()); | |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
397 layersIndex_[layer.get()] = index; |
66 | 398 |
399 ResetPendingScene(); | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
400 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
401 ObserveLayer(*layer); |
66 | 402 |
103 | 403 ResetChangedLayers(); |
404 | |
66 | 405 return index; |
406 } | |
407 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
408 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
409 void SliceViewerWidget::ReplaceLayer(size_t index, |
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
410 boost::shared_ptr<IVolumeSlicer> layer) |
219 | 411 { |
412 if (layer == NULL) | |
413 { | |
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
415 } | |
416 | |
417 if (index >= layers_.size()) | |
418 { | |
419 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
420 } | |
421 | |
422 layers_[index] = layer; | |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
423 layersIndex_[layer.get()] = index; |
219 | 424 |
425 ResetPendingScene(); | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
426 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
427 ObserveLayer(*layer); |
219 | 428 |
429 InvalidateLayer(index); | |
430 } | |
431 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
432 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
433 void SliceViewerWidget::RemoveLayer(size_t index) |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
434 { |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
435 if (index >= layers_.size()) |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
436 { |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
437 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
438 } |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
439 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
440 IVolumeSlicer* previousLayer = layers_[index].get(); |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
441 layersIndex_.erase(layersIndex_.find(previousLayer)); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
442 layers_.erase(layers_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
443 changedLayers_.erase(changedLayers_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
444 styles_.erase(styles_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
445 |
1068
04a95ee91327
recovery of OrthancStoneSingleFrame
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1066
diff
changeset
|
446 layers_[index].reset(); |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
447 |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
448 currentScene_->DeleteLayer(index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
449 ResetPendingScene(); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
450 |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
451 NotifyContentChanged(); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
452 } |
219 | 453 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
454 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
455 const RenderStyle& SliceViewerWidget::GetLayerStyle(size_t layer) const |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
456 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
457 if (layer >= layers_.size()) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
458 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
459 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
460 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
461 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
462 assert(layers_.size() == styles_.size()); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
463 return styles_[layer]; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
464 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
465 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
466 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
467 void SliceViewerWidget::SetLayerStyle(size_t layer, |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
468 const RenderStyle& style) |
66 | 469 { |
470 if (layer >= layers_.size()) | |
471 { | |
472 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
473 } | |
474 | |
475 assert(layers_.size() == styles_.size()); | |
476 styles_[layer] = style; | |
477 | |
478 if (currentScene_.get() != NULL) | |
479 { | |
480 currentScene_->SetLayerStyle(layer, style); | |
481 } | |
482 | |
483 if (pendingScene_.get() != NULL) | |
484 { | |
485 pendingScene_->SetLayerStyle(layer, style); | |
486 } | |
487 | |
278 | 488 NotifyContentChanged(); |
66 | 489 } |
490 | |
491 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
492 void SliceViewerWidget::SetSlice(const OrthancStone::CoordinateSystem3D& plane) |
66 | 493 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
494 LOG(INFO) << "Setting slice origin: (" << plane.GetOrigin()[0] |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
495 << "," << plane.GetOrigin()[1] |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
496 << "," << plane.GetOrigin()[2] << ")"; |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
497 |
714
d2c0e347ddc2
deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
693
diff
changeset
|
498 Deprecated::Slice displayedSlice(plane_, THIN_SLICE_THICKNESS); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
499 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
500 //if (!displayedSlice.ContainsPlane(slice)) |
66 | 501 { |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
502 if (currentScene_.get() == NULL || |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
503 (pendingScene_.get() != NULL && |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
504 pendingScene_->IsComplete())) |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
505 { |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
506 currentScene_ = pendingScene_; |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
507 } |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
508 |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
509 plane_ = plane; |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
510 ResetPendingScene(); |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
511 |
92 | 512 InvalidateAllLayers(); // TODO Removing this line avoid loading twice the image in WASM |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
513 } |
400
518f680dbf2e
SliceViewerWidget::DisplayedSliceMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
514 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
515 BroadcastMessage(DisplayedSliceMessage(*this, displayedSlice)); |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
516 } |
66 | 517 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
518 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
519 void SliceViewerWidget::OnGeometryReady(const IVolumeSlicer::GeometryReadyMessage& message) |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
520 { |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
521 size_t i; |
377 | 522 if (LookupLayer(i, message.GetOrigin())) |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
523 { |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
524 LOG(INFO) << ": Geometry ready for layer " << i << " in " << GetName(); |
103 | 525 |
526 changedLayers_[i] = true; | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
527 //layers_[i]->ScheduleLayerCreation(plane_); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
528 } |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
529 BroadcastMessage(GeometryChangedMessage(*this)); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
530 } |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
531 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
532 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
533 void SliceViewerWidget::InvalidateAllLayers() |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
534 { |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
535 for (size_t i = 0; i < layers_.size(); i++) |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
536 { |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
537 assert(layers_[i] != NULL); |
103 | 538 changedLayers_[i] = true; |
539 | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
540 //layers_[i]->ScheduleLayerCreation(plane_); |
66 | 541 } |
542 } | |
543 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
544 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
545 void SliceViewerWidget::InvalidateLayer(size_t layer) |
66 | 546 { |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
547 if (layer >= layers_.size()) |
83 | 548 { |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
549 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
83 | 550 } |
66 | 551 |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
552 assert(layers_[layer] != NULL); |
103 | 553 changedLayers_[layer] = true; |
554 | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
555 //layers_[layer]->ScheduleLayerCreation(plane_); |
77 | 556 } |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
557 |
77 | 558 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
559 void SliceViewerWidget::OnContentChanged(const IVolumeSlicer::ContentChangedMessage& message) |
66 | 560 { |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
561 size_t index; |
377 | 562 if (LookupLayer(index, message.GetOrigin())) |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
563 { |
103 | 564 InvalidateLayer(index); |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
565 } |
379 | 566 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
567 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
66 | 568 } |
569 | |
570 | |
399
885e1ebd315c
rename SliceChange as SliceContentChange
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
571 void SliceViewerWidget::OnSliceChanged(const IVolumeSlicer::SliceContentChangedMessage& message) |
66 | 572 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
573 if (message.GetSlice().ContainsPlane(plane_)) |
66 | 574 { |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
575 size_t index; |
377 | 576 if (LookupLayer(index, message.GetOrigin())) |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
577 { |
103 | 578 InvalidateLayer(index); |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
579 } |
66 | 580 } |
379 | 581 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
582 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
66 | 583 } |
584 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
585 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
586 void SliceViewerWidget::OnLayerReady(const IVolumeSlicer::LayerReadyMessage& message) |
66 | 587 { |
588 size_t index; | |
377 | 589 if (LookupLayer(index, message.GetOrigin())) |
66 | 590 { |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
591 LOG(INFO) << "Renderer ready for layer " << index; |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
592 UpdateLayer(index, message.CreateRenderer(), message.GetSlice()); |
66 | 593 } |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
594 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
595 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
66 | 596 } |
103 | 597 |
598 | |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
599 void SliceViewerWidget::OnLayerError(const IVolumeSlicer::LayerErrorMessage& message) |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
600 { |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
601 size_t index; |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
602 if (LookupLayer(index, message.GetOrigin())) |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
603 { |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
604 LOG(ERROR) << "Using error renderer on layer " << index; |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
605 |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
606 // TODO |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
607 //UpdateLayer(index, new SliceOutlineRenderer(slice), slice); |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
608 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
609 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
610 } |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
611 } |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
612 |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
613 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
614 void SliceViewerWidget::ResetChangedLayers() |
103 | 615 { |
616 changedLayers_.resize(layers_.size()); | |
617 | |
618 for (size_t i = 0; i < changedLayers_.size(); i++) | |
619 { | |
620 changedLayers_[i] = false; | |
621 } | |
622 } | |
623 | |
624 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
625 void SliceViewerWidget::DoAnimation() |
103 | 626 { |
627 assert(changedLayers_.size() <= layers_.size()); | |
628 | |
629 for (size_t i = 0; i < changedLayers_.size(); i++) | |
630 { | |
631 if (changedLayers_[i]) | |
632 { | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
633 layers_[i]->ScheduleLayerCreation(plane_); |
103 | 634 } |
635 } | |
636 | |
637 ResetChangedLayers(); | |
638 } | |
66 | 639 } |