annotate Framework/Deprecated/Widgets/SliceViewerWidget.cpp @ 872:733c6db3e5a3 am-dev

limiting the size of the cache
author Alain Mazy <alain@mazy.be>
date Mon, 01 Jul 2019 13:36:51 +0200
parents c35e98d22764
children b537002f83a9 2d8ab34c8c91
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() &&
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 layers_[index] == &layer);
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
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
89d02de83c03 added declaretion of messages handled/emitted
am@osimis.io
parents: 266
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 SetBackgroundCleared(true);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
378 SliceViewerWidget::~SliceViewerWidget()
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 for (size_t i = 0; i < layers_.size(); i++)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 delete layers_[i];
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 if (layer == NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 size_t index = layers_.size();
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 layers_.push_back(layer);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 styles_.push_back(RenderStyle());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 layersIndex_[layer] = index;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
418 ResetChangedLayers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
419
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 return index;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
425 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
426 if (layer == NULL)
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
427 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
428 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
429 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
430
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
431 if (index >= layers_.size())
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
432 {
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
433 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
434 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
435
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
436 delete layers_[index];
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
437 layers_[index] = layer;
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
438 layersIndex_[layer] = index;
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
439
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
443
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
444 InvalidateLayer(index);
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
445 }
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
26e3bfe30e66 ReplaceLayer()
am@osimis.io
parents: 212
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 if (layer >= layers_.size())
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 assert(layers_.size() == styles_.size());
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 styles_[layer] = style;
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 if (currentScene_.get() != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 currentScene_->SetLayerStyle(layer, style);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 if (pendingScene_.get() != NULL)
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 pendingScene_->SetLayerStyle(layer, style);
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502
278
8a86695fcbc3 renamings
am@osimis.io
parents: 273
diff changeset
503 NotifyContentChanged();
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
961ee171d933 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 90
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
540
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
553 changedLayers_[i] = 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_[i]->ScheduleLayerCreation(plane_);
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 {
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
562 if (layer >= layers_.size())
83
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 78
diff changeset
565 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
567 assert(layers_[layer] != NULL);
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
568 changedLayers_[layer] = true;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
569
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
570 //layers_[layer]->ScheduleLayerCreation(plane_);
77
f5f54ed8d307 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
571 }
89
f244018a4e4b BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 87
diff changeset
572
77
f5f54ed8d307 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 71
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
576 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
577 if (LookupLayer(index, message.GetOrigin()))
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
578 {
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
579 InvalidateLayer(index);
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 {
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
590 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
591 if (LookupLayer(index, message.GetOrigin()))
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
592 {
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
593 InvalidateLayer(index);
87
4a541cd4fa83 OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 86
diff changeset
594 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 }
379
2308fe0b0b05 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
596
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 439
diff changeset
597 BroadcastMessage(SliceViewerWidget::ContentChangedMessage(*this));
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 }
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 {
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 size_t index;
377
8eb4fe74000f refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 376
diff changeset
604 if (LookupLayer(index, message.GetOrigin()))
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
612
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
630 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
631 changedLayers_.resize(layers_.size());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
632
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
633 for (size_t i = 0; i < changedLayers_.size(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
634 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
635 changedLayers_[i] = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
636 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
637 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
638
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
639
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 386
diff changeset
640 void SliceViewerWidget::DoAnimation()
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
641 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
642 assert(changedLayers_.size() <= layers_.size());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
643
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
644 for (size_t i = 0; i < changedLayers_.size(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
645 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
646 if (changedLayers_[i])
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
647 {
394
17d54c028805 rename ILayerRenderer::GetLayerSlice() to GetLayerPlane()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
648 layers_[i]->ScheduleLayerCreation(plane_);
103
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
649 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
650 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
651
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
652 ResetChangedLayers();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 99
diff changeset
653 }
66
298f375dcb68 LayerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }