Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Widgets/SliceViewerWidget.cpp @ 819:a68cd7ae8838
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 29 May 2019 13:39:31 +0200 |
parents | c35e98d22764 |
children | b537002f83a9 2d8ab34c8c91 |
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() && | |
253 layers_[index] == &layer); | |
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 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
367 SliceViewerWidget::SliceViewerWidget(OrthancStone::MessageBroker& broker, |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
368 const std::string& name) : |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
369 WorldSceneWidget(name), |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
370 IObserver(broker), |
267 | 371 IObservable(broker), |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
372 started_(false) |
66 | 373 { |
374 SetBackgroundCleared(true); | |
375 } | |
376 | |
377 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
378 SliceViewerWidget::~SliceViewerWidget() |
66 | 379 { |
380 for (size_t i = 0; i < layers_.size(); i++) | |
381 { | |
382 delete layers_[i]; | |
383 } | |
384 } | |
385 | |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
386 void SliceViewerWidget::ObserveLayer(IVolumeSlicer& layer) |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
387 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
388 layer.RegisterObserverCallback(new OrthancStone::Callable<SliceViewerWidget, IVolumeSlicer::GeometryReadyMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
389 (*this, &SliceViewerWidget::OnGeometryReady)); |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
390 // currently ignore errors layer->RegisterObserverCallback(new Callable<SliceViewerWidget, IVolumeSlicer::GeometryErrorMessage>(*this, &SliceViewerWidget::...)); |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
391 layer.RegisterObserverCallback(new OrthancStone::Callable<SliceViewerWidget, IVolumeSlicer::SliceContentChangedMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
392 (*this, &SliceViewerWidget::OnSliceChanged)); |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
393 layer.RegisterObserverCallback(new OrthancStone::Callable<SliceViewerWidget, IVolumeSlicer::ContentChangedMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
394 (*this, &SliceViewerWidget::OnContentChanged)); |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
395 layer.RegisterObserverCallback(new OrthancStone::Callable<SliceViewerWidget, IVolumeSlicer::LayerReadyMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
396 (*this, &SliceViewerWidget::OnLayerReady)); |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
397 layer.RegisterObserverCallback(new OrthancStone::Callable<SliceViewerWidget, IVolumeSlicer::LayerErrorMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
398 (*this, &SliceViewerWidget::OnLayerError)); |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
399 } |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
400 |
66 | 401 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
402 size_t SliceViewerWidget::AddLayer(IVolumeSlicer* layer) // Takes ownership |
66 | 403 { |
404 if (layer == NULL) | |
405 { | |
406 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
407 } | |
408 | |
409 size_t index = layers_.size(); | |
410 layers_.push_back(layer); | |
411 styles_.push_back(RenderStyle()); | |
412 layersIndex_[layer] = index; | |
413 | |
414 ResetPendingScene(); | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
415 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
416 ObserveLayer(*layer); |
66 | 417 |
103 | 418 ResetChangedLayers(); |
419 | |
66 | 420 return index; |
421 } | |
422 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
423 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
424 void SliceViewerWidget::ReplaceLayer(size_t index, IVolumeSlicer* layer) // Takes ownership |
219 | 425 { |
426 if (layer == NULL) | |
427 { | |
428 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | |
429 } | |
430 | |
431 if (index >= layers_.size()) | |
432 { | |
433 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
434 } | |
435 | |
436 delete layers_[index]; | |
437 layers_[index] = layer; | |
438 layersIndex_[layer] = index; | |
439 | |
440 ResetPendingScene(); | |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
441 |
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
442 ObserveLayer(*layer); |
219 | 443 |
444 InvalidateLayer(index); | |
445 } | |
446 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
447 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
448 void SliceViewerWidget::RemoveLayer(size_t index) |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
449 { |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
450 if (index >= layers_.size()) |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
451 { |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
452 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
453 } |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
454 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
455 IVolumeSlicer* previousLayer = layers_[index]; |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
456 layersIndex_.erase(layersIndex_.find(previousLayer)); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
457 layers_.erase(layers_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
458 changedLayers_.erase(changedLayers_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
459 styles_.erase(styles_.begin() + index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
460 |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
461 delete layers_[index]; |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
462 |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
463 currentScene_->DeleteLayer(index); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
464 ResetPendingScene(); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
465 |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
466 NotifyContentChanged(); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
467 } |
219 | 468 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
469 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
470 const RenderStyle& SliceViewerWidget::GetLayerStyle(size_t layer) const |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
471 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
472 if (layer >= layers_.size()) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
473 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
474 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
475 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
476 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
477 assert(layers_.size() == styles_.size()); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
478 return styles_[layer]; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
479 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
480 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
481 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
482 void SliceViewerWidget::SetLayerStyle(size_t layer, |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
483 const RenderStyle& style) |
66 | 484 { |
485 if (layer >= layers_.size()) | |
486 { | |
487 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
488 } | |
489 | |
490 assert(layers_.size() == styles_.size()); | |
491 styles_[layer] = style; | |
492 | |
493 if (currentScene_.get() != NULL) | |
494 { | |
495 currentScene_->SetLayerStyle(layer, style); | |
496 } | |
497 | |
498 if (pendingScene_.get() != NULL) | |
499 { | |
500 pendingScene_->SetLayerStyle(layer, style); | |
501 } | |
502 | |
278 | 503 NotifyContentChanged(); |
66 | 504 } |
505 | |
506 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
507 void SliceViewerWidget::SetSlice(const OrthancStone::CoordinateSystem3D& plane) |
66 | 508 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
509 LOG(INFO) << "Setting slice origin: (" << plane.GetOrigin()[0] |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
510 << "," << plane.GetOrigin()[1] |
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
511 << "," << plane.GetOrigin()[2] << ")"; |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
92
diff
changeset
|
512 |
714
d2c0e347ddc2
deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
693
diff
changeset
|
513 Deprecated::Slice displayedSlice(plane_, THIN_SLICE_THICKNESS); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
514 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
515 //if (!displayedSlice.ContainsPlane(slice)) |
66 | 516 { |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
517 if (currentScene_.get() == NULL || |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
518 (pendingScene_.get() != NULL && |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
519 pendingScene_->IsComplete())) |
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 currentScene_ = pendingScene_; |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
522 } |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
523 |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
524 plane_ = plane; |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
525 ResetPendingScene(); |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
526 |
92 | 527 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
|
528 } |
400
518f680dbf2e
SliceViewerWidget::DisplayedSliceMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
529 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
530 BroadcastMessage(DisplayedSliceMessage(*this, displayedSlice)); |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
531 } |
66 | 532 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
533 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
534 void SliceViewerWidget::OnGeometryReady(const IVolumeSlicer::GeometryReadyMessage& message) |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
535 { |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
536 size_t i; |
377 | 537 if (LookupLayer(i, message.GetOrigin())) |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
538 { |
273
f21ba2468570
force all Widgets to have a name to ease debugging
am@osimis.io
parents:
272
diff
changeset
|
539 LOG(INFO) << ": Geometry ready for layer " << i << " in " << GetName(); |
103 | 540 |
541 changedLayers_[i] = true; | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
542 //layers_[i]->ScheduleLayerCreation(plane_); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
543 } |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
544 BroadcastMessage(GeometryChangedMessage(*this)); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
545 } |
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
546 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
547 |
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
548 void SliceViewerWidget::InvalidateAllLayers() |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
549 { |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
550 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
|
551 { |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
552 assert(layers_[i] != NULL); |
103 | 553 changedLayers_[i] = true; |
554 | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
555 //layers_[i]->ScheduleLayerCreation(plane_); |
66 | 556 } |
557 } | |
558 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
559 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
560 void SliceViewerWidget::InvalidateLayer(size_t layer) |
66 | 561 { |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
562 if (layer >= layers_.size()) |
83 | 563 { |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
564 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
83 | 565 } |
66 | 566 |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
567 assert(layers_[layer] != NULL); |
103 | 568 changedLayers_[layer] = true; |
569 | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
570 //layers_[layer]->ScheduleLayerCreation(plane_); |
77 | 571 } |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
572 |
77 | 573 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
574 void SliceViewerWidget::OnContentChanged(const IVolumeSlicer::ContentChangedMessage& message) |
66 | 575 { |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
576 size_t index; |
377 | 577 if (LookupLayer(index, message.GetOrigin())) |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
578 { |
103 | 579 InvalidateLayer(index); |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
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 | |
585 | |
399
885e1ebd315c
rename SliceChange as SliceContentChange
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
586 void SliceViewerWidget::OnSliceChanged(const IVolumeSlicer::SliceContentChangedMessage& message) |
66 | 587 { |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
588 if (message.GetSlice().ContainsPlane(plane_)) |
66 | 589 { |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
590 size_t index; |
377 | 591 if (LookupLayer(index, message.GetOrigin())) |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
592 { |
103 | 593 InvalidateLayer(index); |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
594 } |
66 | 595 } |
379 | 596 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
597 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
66 | 598 } |
599 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
600 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
601 void SliceViewerWidget::OnLayerReady(const IVolumeSlicer::LayerReadyMessage& message) |
66 | 602 { |
603 size_t index; | |
377 | 604 if (LookupLayer(index, message.GetOrigin())) |
66 | 605 { |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
606 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
|
607 UpdateLayer(index, message.CreateRenderer(), message.GetSlice()); |
66 | 608 } |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
609 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
610 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
66 | 611 } |
103 | 612 |
613 | |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
394
diff
changeset
|
614 void SliceViewerWidget::OnLayerError(const IVolumeSlicer::LayerErrorMessage& message) |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
615 { |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
616 size_t index; |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
617 if (LookupLayer(index, message.GetOrigin())) |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
618 { |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
619 LOG(ERROR) << "Using error renderer on layer " << index; |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
620 |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
621 // TODO |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
622 //UpdateLayer(index, new SliceOutlineRenderer(slice), slice); |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
623 |
623
42dadae61fa9
renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
624 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this)); |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
625 } |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
626 } |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
627 |
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
379
diff
changeset
|
628 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
629 void SliceViewerWidget::ResetChangedLayers() |
103 | 630 { |
631 changedLayers_.resize(layers_.size()); | |
632 | |
633 for (size_t i = 0; i < changedLayers_.size(); i++) | |
634 { | |
635 changedLayers_[i] = false; | |
636 } | |
637 } | |
638 | |
639 | |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
386
diff
changeset
|
640 void SliceViewerWidget::DoAnimation() |
103 | 641 { |
642 assert(changedLayers_.size() <= layers_.size()); | |
643 | |
644 for (size_t i = 0; i < changedLayers_.size(); i++) | |
645 { | |
646 if (changedLayers_[i]) | |
647 { | |
394
17d54c028805
rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
648 layers_[i]->ScheduleLayerCreation(plane_); |
103 | 649 } |
650 } | |
651 | |
652 ResetChangedLayers(); | |
653 } | |
66 | 654 } |