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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 403
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
22 #include "SliceViewerWidget.h"
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
99
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 97
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
27
212
5412adf19980 resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 201
diff changeset
28 #include <Core/Logging.h>
403
99e31898910e IObservable.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 400
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
34 static const double THIN_SLICE_THICKNESS = 100.0 * std::numeric_limits<double>::epsilon();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 size_t countMissing_;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 void DeleteLayer(size_t index)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 if (index >= renderers_.size())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 assert(countMissing_ <= renderers_.size());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 if (renderers_[index] != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 assert(countMissing_ < renderers_.size());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 delete renderers_[index];
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 renderers_[index] = NULL;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 countMissing_++;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 countMissing_(countLayers),
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 renderers_(countLayers, NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ~Scene()
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 for (size_t i = 0; i < renderers_.size(); i++)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 DeleteLayer(i);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 void SetLayer(size_t index,
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 ILayerRenderer* renderer) // Takes ownership
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 if (renderer == NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 DeleteLayer(index);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 renderers_[index] = renderer;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 countMissing_--;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 {
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
103 return plane_;
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 bool IsComplete() const
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 return countMissing_ == 0;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 for (size_t i = 0; i < renderers_.size(); i++)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 if (renderers_[i] != NULL &&
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 !renderers_[i]->IsFullQuality())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 fullQuality = false;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 if (!fullQuality)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 double x, y;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 view.MapDisplayToScene(x, y, static_cast<double>(view.GetDisplayWidth()) / 2.0, 10);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 cairo_translate(cr, x, y);
95
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
182
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
183 #if 1
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
184 double s = 5.0 / view.GetZoom();
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
185 cairo_rectangle(cr, -s, -s, 2.0 * s, 2.0 * s);
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
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
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
189 #endif
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
190
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 cairo_stroke_preserve(cr);
95
f47349f4815c fix for wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 93
diff changeset
194 cairo_set_source_rgb(cr, 1, 0, 0);
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 cairo_fill(cr);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 return true;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 void SetLayerStyle(size_t index,
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 const RenderStyle& style)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 if (renderers_[index] != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 renderers_[index]->SetLayerStyle(style);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 };
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 LayersIndex::const_iterator found = layersIndex_.find(&layer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 if (found == layersIndex_.end())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 return false;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 else
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 index = found->second;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 return true;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 }
251
192e6e349e69 first usage of new message system (in SDL only)
am@osimis.io
parents: 219
diff changeset
257
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
272 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
273 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
274 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 83
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 for (size_t i = 0; i < layers_.size(); i++)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
109
53bd9277b025 using the Extent class
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 103
diff changeset
290 return sceneExtent;
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 if (currentScene_.get() != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 else
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 return true;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
308 void SliceViewerWidget::ResetPendingScene()
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 {
71
30c768873d47 OrthancSliceLoader::ScheduleLoadInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 66
diff changeset
328 LOG(INFO) << "Updating layer " << index;
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 std::auto_ptr<ILayerRenderer> tmp(renderer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 if (renderer == NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 if (index >= layers_.size())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 assert(layers_.size() == styles_.size());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 renderer->SetLayerStyle(styles_[index]);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 currentScene_->SetLayer(index, tmp.release());
278
8a86695fcbc3 renamings
am@osimis.io
parents: 273
diff changeset
349 NotifyContentChanged();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 pendingScene_->SetLayer(index, tmp.release());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 pendingScene_->IsComplete())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 currentScene_ = pendingScene_;
278
8a86695fcbc3 renamings
am@osimis.io
parents: 273
diff changeset
361 NotifyContentChanged();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 SetBackgroundCleared(true);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 if (layer == NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 size_t index = layers_.size();
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 layers_.push_back(layer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
403 ResetChangedLayers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
404
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 return index;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
411 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
412 if (layer == NULL)
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
413 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
415 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
416
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
417 if (index >= layers_.size())
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
418 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
419 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
420 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
421
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
424
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
428
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
429 InvalidateLayer(index);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
430 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 if (layer >= layers_.size())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 assert(layers_.size() == styles_.size());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 styles_[layer] = style;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 if (currentScene_.get() != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 currentScene_->SetLayerStyle(layer, style);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 if (pendingScene_.get() != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 pendingScene_->SetLayerStyle(layer, style);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487
278
8a86695fcbc3 renamings
am@osimis.io
parents: 273
diff changeset
488 NotifyContentChanged();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
961ee171d933 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 90
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
525
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
538 changedLayers_[i] = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
539
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
540 //layers_[i]->ScheduleLayerCreation(plane_);
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 {
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
547 if (layer >= layers_.size())
83
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
550 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
552 assert(layers_[layer] != NULL);
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
553 changedLayers_[layer] = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
554
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
555 //layers_[layer]->ScheduleLayerCreation(plane_);
77
f5f54ed8d307 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
556 }
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
557
77
f5f54ed8d307 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
561 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
562 if (LookupLayer(index, message.GetOrigin()))
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
563 {
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
564 InvalidateLayer(index);
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
565 }
379
2308fe0b0b05 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
566
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
567 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this));
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
575 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
576 if (LookupLayer(index, message.GetOrigin()))
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
577 {
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
578 InvalidateLayer(index);
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
579 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 }
379
2308fe0b0b05 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
581
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
582 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this));
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
589 if (LookupLayer(index, message.GetOrigin()))
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 }
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
597
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
615 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
616 changedLayers_.resize(layers_.size());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
617
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
618 for (size_t i = 0; i < changedLayers_.size(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
619 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
620 changedLayers_[i] = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
621 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
622 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
623
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
624
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
625 void SliceViewerWidget::DoAnimation()
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
626 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
627 assert(changedLayers_.size() <= layers_.size());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
628
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
629 for (size_t i = 0; i < changedLayers_.size(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
630 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
631 if (changedLayers_[i])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
632 {
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
633 layers_[i]->ScheduleLayerCreation(plane_);
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
634 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
635 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
636
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
637 ResetChangedLayers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
638 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 }