Mercurial > hg > orthanc-stone
annotate Framework/dev.h @ 436:04711a2e12cd am-vsol-upgrade
fix crop + export photometric interpretation correctly
author | am@osimis.io |
---|---|
date | Thu, 06 Dec 2018 11:53:37 +0100 |
parents | 5d359b115b29 |
children | b70e9be013e4 |
rev | line source |
---|---|
102 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
102 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
16 * |
102 | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "Layers/FrameRenderer.h" | |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
25 #include "Layers/LineLayerRenderer.h" |
102 | 26 #include "Layers/SliceOutlineRenderer.h" |
27 #include "Toolbox/DownloadStack.h" | |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
28 #include "Toolbox/GeometryToolbox.h" |
102 | 29 #include "Toolbox/OrthancSlicesLoader.h" |
30 #include "Volumes/ImageBuffer3D.h" | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
31 #include "Volumes/ISlicedVolume.h" |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
32 #include "Widgets/SliceViewerWidget.h" |
102 | 33 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
34 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
35 #include <Core/Images/ImageProcessing.h> |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
36 #include <Core/OrthancException.h> |
102 | 37 |
38 #include <boost/math/special_functions/round.hpp> | |
39 | |
40 | |
41 namespace OrthancStone | |
42 { | |
136
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
43 // TODO: Handle errors while loading |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
44 class OrthancVolumeImage : |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
45 public ISlicedVolume, |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
46 public IObserver |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
47 { |
102 | 48 private: |
49 OrthancSlicesLoader loader_; | |
50 std::auto_ptr<ImageBuffer3D> image_; | |
51 std::auto_ptr<DownloadStack> downloadStack_; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
52 bool computeRange_; |
136
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
53 size_t pendingSlices_; |
102 | 54 |
55 void ScheduleSliceDownload() | |
56 { | |
57 assert(downloadStack_.get() != NULL); | |
58 | |
59 unsigned int slice; | |
60 if (downloadStack_->Pop(slice)) | |
61 { | |
62 loader_.ScheduleLoadSliceImage(slice, SliceImageQuality_Jpeg90); | |
63 } | |
64 } | |
65 | |
66 | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
67 static bool IsCompatible(const Slice& a, |
102 | 68 const Slice& b) |
69 { | |
70 if (!GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(), | |
71 b.GetGeometry().GetNormal())) | |
72 { | |
73 LOG(ERROR) << "Some slice in the volume image is not parallel to the others"; | |
74 return false; | |
75 } | |
76 | |
77 if (a.GetConverter().GetExpectedPixelFormat() != b.GetConverter().GetExpectedPixelFormat()) | |
78 { | |
79 LOG(ERROR) << "The pixel format changes across the slices of the volume image"; | |
80 return false; | |
81 } | |
82 | |
83 if (a.GetWidth() != b.GetWidth() || | |
84 a.GetHeight() != b.GetHeight()) | |
85 { | |
86 LOG(ERROR) << "The width/height of the slices change across the volume image"; | |
87 return false; | |
88 } | |
89 | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
90 if (!LinearAlgebra::IsNear(a.GetPixelSpacingX(), b.GetPixelSpacingX()) || |
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
91 !LinearAlgebra::IsNear(a.GetPixelSpacingY(), b.GetPixelSpacingY())) |
102 | 92 { |
93 LOG(ERROR) << "The pixel spacing of the slices change across the volume image"; | |
94 return false; | |
95 } | |
96 | |
97 return true; | |
98 } | |
99 | |
100 | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
101 static double GetDistance(const Slice& a, |
102 | 102 const Slice& b) |
103 { | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
104 return fabs(a.GetGeometry().ProjectAlongNormal(a.GetGeometry().GetOrigin()) - |
102 | 105 a.GetGeometry().ProjectAlongNormal(b.GetGeometry().GetOrigin())); |
106 } | |
107 | |
108 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
109 void OnSliceGeometryReady(const OrthancSlicesLoader::SliceGeometryReadyMessage& message) |
102 | 110 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
111 assert(&message.GetOrigin() == &loader_); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
112 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
113 if (loader_.GetSliceCount() == 0) |
102 | 114 { |
115 LOG(ERROR) << "Empty volume image"; | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
116 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
102 | 117 return; |
118 } | |
119 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
120 for (size_t i = 1; i < loader_.GetSliceCount(); i++) |
102 | 121 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
122 if (!IsCompatible(loader_.GetSlice(0), loader_.GetSlice(i))) |
102 | 123 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
124 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
102 | 125 return; |
126 } | |
127 } | |
128 | |
129 double spacingZ; | |
130 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
131 if (loader_.GetSliceCount() > 1) |
102 | 132 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
133 spacingZ = GetDistance(loader_.GetSlice(0), loader_.GetSlice(1)); |
102 | 134 } |
135 else | |
136 { | |
137 // This is a volume with one single slice: Choose a dummy | |
138 // z-dimension for voxels | |
139 spacingZ = 1; | |
140 } | |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
141 |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
142 for (size_t i = 1; i < loader_.GetSliceCount(); i++) |
102 | 143 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
144 if (!LinearAlgebra::IsNear(spacingZ, GetDistance(loader_.GetSlice(i - 1), loader_.GetSlice(i)), |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
138
diff
changeset
|
145 0.001 /* this is expressed in mm */)) |
102 | 146 { |
147 LOG(ERROR) << "The distance between successive slices is not constant in a volume image"; | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
148 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
102 | 149 return; |
150 } | |
151 } | |
152 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
153 unsigned int width = loader_.GetSlice(0).GetWidth(); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
154 unsigned int height = loader_.GetSlice(0).GetHeight(); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
155 Orthanc::PixelFormat format = loader_.GetSlice(0).GetConverter().GetExpectedPixelFormat(); |
266
c9cf95b49a86
removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents:
252
diff
changeset
|
156 LOG(INFO) << "Creating a volume image of size " << width << "x" << height |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
157 << "x" << loader_.GetSliceCount() << " in " << Orthanc::EnumerationToString(format); |
102 | 158 |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
159 image_.reset(new ImageBuffer3D(format, width, height, loader_.GetSliceCount(), computeRange_)); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
160 image_->SetAxialGeometry(loader_.GetSlice(0).GetGeometry()); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
161 image_->SetVoxelDimensions(loader_.GetSlice(0).GetPixelSpacingX(), |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
162 loader_.GetSlice(0).GetPixelSpacingY(), spacingZ); |
102 | 163 image_->Clear(); |
266
c9cf95b49a86
removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents:
252
diff
changeset
|
164 |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
165 downloadStack_.reset(new DownloadStack(loader_.GetSliceCount())); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
166 pendingSlices_ = loader_.GetSliceCount(); |
102 | 167 |
168 for (unsigned int i = 0; i < 4; i++) // Limit to 4 simultaneous downloads | |
169 { | |
170 ScheduleSliceDownload(); | |
171 } | |
172 | |
173 // TODO Check the DicomFrameConverter are constant | |
174 | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
175 EmitMessage(ISlicedVolume::GeometryReadyMessage(*this)); |
102 | 176 } |
177 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
178 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
179 void OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message) |
102 | 180 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
181 assert(&message.GetOrigin() == &loader_); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
182 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
183 LOG(ERROR) << "Unable to download a volume image"; |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
184 EmitMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
185 } |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
186 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
187 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
188 void OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
189 { |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
190 assert(&message.GetOrigin() == &loader_); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
191 |
102 | 192 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
193 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, message.GetSliceIndex()); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
194 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage()); |
102 | 195 } |
196 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
197 EmitMessage(ISlicedVolume::SliceContentChangedMessage |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
198 (*this, message.GetSliceIndex(), message.GetSlice())); |
136
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
199 |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
200 if (pendingSlices_ == 1) |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
201 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
202 EmitMessage(ISlicedVolume::VolumeReadyMessage(*this)); |
136
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
203 pendingSlices_ = 0; |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
204 } |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
205 else if (pendingSlices_ > 1) |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
206 { |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
207 pendingSlices_ -= 1; |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
208 } |
102 | 209 |
210 ScheduleSliceDownload(); | |
211 } | |
212 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
213 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
214 void OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message) |
102 | 215 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
216 assert(&message.GetOrigin() == &loader_); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
217 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
218 LOG(ERROR) << "Cannot download slice " << message.GetSliceIndex() << " in a volume image"; |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
219 ScheduleSliceDownload(); |
102 | 220 } |
221 | |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
222 |
102 | 223 public: |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
216
diff
changeset
|
224 OrthancVolumeImage(MessageBroker& broker, |
300
b4abaeb783b1
messaging refactoring almost complete: works fine in native
am@osimis.io
parents:
299
diff
changeset
|
225 OrthancApiClient& orthanc, |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
226 bool computeRange) : |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
227 ISlicedVolume(broker), |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
228 IObserver(broker), |
266
c9cf95b49a86
removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents:
252
diff
changeset
|
229 loader_(broker, orthanc), |
136
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
230 computeRange_(computeRange), |
a06ad9d7406e
ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
231 pendingSlices_(0) |
102 | 232 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
233 loader_.RegisterObserverCallback( |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
234 new Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryReadyMessage> |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
235 (*this, &OrthancVolumeImage::OnSliceGeometryReady)); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
236 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
237 loader_.RegisterObserverCallback( |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
238 new Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryErrorMessage> |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
239 (*this, &OrthancVolumeImage::OnSliceGeometryError)); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
240 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
241 loader_.RegisterObserverCallback( |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
242 new Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageReadyMessage> |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
243 (*this, &OrthancVolumeImage::OnSliceImageReady)); |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
244 |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
245 loader_.RegisterObserverCallback( |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
246 new Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageErrorMessage> |
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
405
diff
changeset
|
247 (*this, &OrthancVolumeImage::OnSliceImageError)); |
102 | 248 } |
249 | |
250 void ScheduleLoadSeries(const std::string& seriesId) | |
251 { | |
252 loader_.ScheduleLoadSeries(seriesId); | |
253 } | |
254 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
255 void ScheduleLoadInstance(const std::string& instanceId) |
102 | 256 { |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
257 loader_.ScheduleLoadInstance(instanceId); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
258 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
259 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
260 void ScheduleLoadFrame(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
261 unsigned int frame) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
262 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
263 loader_.ScheduleLoadFrame(instanceId, frame); |
102 | 264 } |
265 | |
266 virtual size_t GetSliceCount() const | |
267 { | |
268 return loader_.GetSliceCount(); | |
269 } | |
270 | |
271 virtual const Slice& GetSlice(size_t index) const | |
272 { | |
273 return loader_.GetSlice(index); | |
274 } | |
275 | |
276 ImageBuffer3D& GetImage() const | |
277 { | |
278 if (image_.get() == NULL) | |
279 { | |
280 // The geometry is not ready yet | |
281 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
282 } | |
283 else | |
284 { | |
285 return *image_; | |
286 } | |
287 } | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
288 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
289 bool FitWindowingToRange(RenderStyle& style, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
290 const DicomFrameConverter& converter) const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
291 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
292 if (image_.get() == NULL) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
293 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
294 return false; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
295 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
296 else |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
297 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
298 return image_->FitWindowingToRange(style, converter); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
299 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
300 } |
102 | 301 }; |
302 | |
303 | |
304 class VolumeImageGeometry | |
305 { | |
306 private: | |
307 unsigned int width_; | |
308 unsigned int height_; | |
309 size_t depth_; | |
310 double pixelSpacingX_; | |
311 double pixelSpacingY_; | |
312 double sliceThickness_; | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
313 CoordinateSystem3D reference_; |
102 | 314 DicomFrameConverter converter_; |
315 | |
316 double ComputeAxialThickness(const OrthancVolumeImage& volume) const | |
317 { | |
318 double thickness; | |
319 | |
320 size_t n = volume.GetSliceCount(); | |
321 if (n > 1) | |
322 { | |
323 const Slice& a = volume.GetSlice(0); | |
324 const Slice& b = volume.GetSlice(n - 1); | |
325 thickness = ((reference_.ProjectAlongNormal(b.GetGeometry().GetOrigin()) - | |
326 reference_.ProjectAlongNormal(a.GetGeometry().GetOrigin())) / | |
327 (static_cast<double>(n) - 1.0)); | |
328 } | |
329 else | |
330 { | |
331 thickness = volume.GetSlice(0).GetThickness(); | |
332 } | |
333 | |
334 if (thickness <= 0) | |
335 { | |
336 // The slices should have been sorted with increasing Z | |
337 // (along the normal) by the OrthancSlicesLoader | |
338 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
339 } | |
340 else | |
341 { | |
342 return thickness; | |
343 } | |
344 } | |
345 | |
346 void SetupAxial(const OrthancVolumeImage& volume) | |
347 { | |
348 const Slice& axial = volume.GetSlice(0); | |
349 | |
350 width_ = axial.GetWidth(); | |
351 height_ = axial.GetHeight(); | |
352 depth_ = volume.GetSliceCount(); | |
353 | |
354 pixelSpacingX_ = axial.GetPixelSpacingX(); | |
355 pixelSpacingY_ = axial.GetPixelSpacingY(); | |
356 sliceThickness_ = ComputeAxialThickness(volume); | |
357 | |
358 reference_ = axial.GetGeometry(); | |
359 } | |
360 | |
361 void SetupCoronal(const OrthancVolumeImage& volume) | |
362 { | |
363 const Slice& axial = volume.GetSlice(0); | |
364 double axialThickness = ComputeAxialThickness(volume); | |
365 | |
366 width_ = axial.GetWidth(); | |
367 height_ = volume.GetSliceCount(); | |
368 depth_ = axial.GetHeight(); | |
369 | |
370 pixelSpacingX_ = axial.GetPixelSpacingX(); | |
371 pixelSpacingY_ = axialThickness; | |
372 sliceThickness_ = axial.GetPixelSpacingY(); | |
373 | |
374 Vector origin = axial.GetGeometry().GetOrigin(); | |
375 origin += (static_cast<double>(volume.GetSliceCount() - 1) * | |
376 axialThickness * axial.GetGeometry().GetNormal()); | |
377 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
378 reference_ = CoordinateSystem3D(origin, |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
379 axial.GetGeometry().GetAxisX(), |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
380 -axial.GetGeometry().GetNormal()); |
102 | 381 } |
382 | |
383 void SetupSagittal(const OrthancVolumeImage& volume) | |
384 { | |
385 const Slice& axial = volume.GetSlice(0); | |
386 double axialThickness = ComputeAxialThickness(volume); | |
387 | |
388 width_ = axial.GetHeight(); | |
389 height_ = volume.GetSliceCount(); | |
390 depth_ = axial.GetWidth(); | |
391 | |
392 pixelSpacingX_ = axial.GetPixelSpacingY(); | |
393 pixelSpacingY_ = axialThickness; | |
394 sliceThickness_ = axial.GetPixelSpacingX(); | |
395 | |
396 Vector origin = axial.GetGeometry().GetOrigin(); | |
397 origin += (static_cast<double>(volume.GetSliceCount() - 1) * | |
398 axialThickness * axial.GetGeometry().GetNormal()); | |
399 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
400 reference_ = CoordinateSystem3D(origin, |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
401 axial.GetGeometry().GetAxisY(), |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
402 axial.GetGeometry().GetNormal()); |
102 | 403 } |
404 | |
405 public: | |
406 VolumeImageGeometry(const OrthancVolumeImage& volume, | |
407 VolumeProjection projection) | |
408 { | |
409 if (volume.GetSliceCount() == 0) | |
410 { | |
411 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
412 } | |
413 | |
414 converter_ = volume.GetSlice(0).GetConverter(); | |
415 | |
416 switch (projection) | |
417 { | |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
418 case VolumeProjection_Axial: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
419 SetupAxial(volume); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
420 break; |
102 | 421 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
422 case VolumeProjection_Coronal: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
423 SetupCoronal(volume); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
424 break; |
102 | 425 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
426 case VolumeProjection_Sagittal: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
427 SetupSagittal(volume); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
428 break; |
102 | 429 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
430 default: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
431 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
102 | 432 } |
433 } | |
434 | |
435 size_t GetSliceCount() const | |
436 { | |
437 return depth_; | |
438 } | |
439 | |
440 const Vector& GetNormal() const | |
441 { | |
442 return reference_.GetNormal(); | |
443 } | |
444 | |
445 bool LookupSlice(size_t& index, | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
446 const CoordinateSystem3D& slice) const |
102 | 447 { |
448 bool opposite; | |
449 if (!GeometryToolbox::IsParallelOrOpposite(opposite, | |
450 reference_.GetNormal(), | |
451 slice.GetNormal())) | |
452 { | |
453 return false; | |
454 } | |
455 | |
456 double z = (reference_.ProjectAlongNormal(slice.GetOrigin()) - | |
457 reference_.ProjectAlongNormal(reference_.GetOrigin())) / sliceThickness_; | |
458 | |
459 int s = static_cast<int>(boost::math::iround(z)); | |
460 | |
461 if (s < 0 || | |
462 s >= static_cast<int>(depth_)) | |
463 { | |
464 return false; | |
465 } | |
466 else | |
467 { | |
468 index = static_cast<size_t>(s); | |
469 return true; | |
470 } | |
471 } | |
472 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
473 Slice* GetSlice(size_t slice) const |
102 | 474 { |
216 | 475 if (slice >= depth_) |
102 | 476 { |
477 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
478 } | |
479 else | |
480 { | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
481 CoordinateSystem3D origin(reference_.GetOrigin() + |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
482 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(), |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
483 reference_.GetAxisX(), |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
484 reference_.GetAxisY()); |
102 | 485 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
486 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
487 width_, height_, converter_); |
102 | 488 } |
489 } | |
490 }; | |
491 | |
492 | |
493 | |
398
d257ea56b7be
renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
494 class VolumeImageMPRSlicer : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
495 public IVolumeSlicer, |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
496 public IObserver |
102 | 497 { |
498 private: | |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
499 class RendererFactory : public LayerReadyMessage::IRendererFactory |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
500 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
501 private: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
502 const Orthanc::ImageAccessor& frame_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
503 const Slice& slice_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
504 bool isFullQuality_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
505 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
506 public: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
507 RendererFactory(const Orthanc::ImageAccessor& frame, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
508 const Slice& slice, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
509 bool isFullQuality) : |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
510 frame_(frame), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
511 slice_(slice), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
512 isFullQuality_(isFullQuality) |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
513 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
514 } |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
515 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
516 virtual ILayerRenderer* CreateRenderer() const |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
517 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
518 return FrameRenderer::CreateRenderer(frame_, slice_, isFullQuality_); |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
519 } |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
520 }; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
521 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
522 |
102 | 523 OrthancVolumeImage& volume_; |
524 std::auto_ptr<VolumeImageGeometry> axialGeometry_; | |
525 std::auto_ptr<VolumeImageGeometry> coronalGeometry_; | |
526 std::auto_ptr<VolumeImageGeometry> sagittalGeometry_; | |
527 | |
528 | |
529 bool IsGeometryReady() const | |
530 { | |
531 return axialGeometry_.get() != NULL; | |
532 } | |
533 | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
534 void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message) |
102 | 535 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
536 assert(&message.GetOrigin() == &volume_); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
537 |
396
ed7146fa2c98
rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
390
diff
changeset
|
538 // These 3 values are only used to speed up the IVolumeSlicer |
102 | 539 axialGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Axial)); |
540 coronalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Coronal)); | |
541 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, VolumeProjection_Sagittal)); | |
542 | |
401
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
543 EmitMessage(IVolumeSlicer::GeometryReadyMessage(*this)); |
102 | 544 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
545 |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
546 void OnGeometryError(const ISlicedVolume::GeometryErrorMessage& message) |
102 | 547 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
548 assert(&message.GetOrigin() == &volume_); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
549 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
550 EmitMessage(IVolumeSlicer::GeometryErrorMessage(*this)); |
102 | 551 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
552 |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
553 void OnContentChanged(const ISlicedVolume::ContentChangedMessage& message) |
102 | 554 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
555 assert(&message.GetOrigin() == &volume_); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
556 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
557 EmitMessage(IVolumeSlicer::ContentChangedMessage(*this)); |
102 | 558 } |
559 | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
560 void OnSliceContentChanged(const ISlicedVolume::SliceContentChangedMessage& message) |
102 | 561 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
562 assert(&message.GetOrigin() == &volume_); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
563 |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
564 //IVolumeSlicer::OnSliceContentChange(slice); |
102 | 565 |
566 // TODO Improve this? | |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
567 EmitMessage(IVolumeSlicer::ContentChangedMessage(*this)); |
102 | 568 } |
569 | |
570 const VolumeImageGeometry& GetProjectionGeometry(VolumeProjection projection) | |
571 { | |
572 if (!IsGeometryReady()) | |
573 { | |
574 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
575 } | |
576 | |
577 switch (projection) | |
578 { | |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
579 case VolumeProjection_Axial: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
580 return *axialGeometry_; |
102 | 581 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
582 case VolumeProjection_Sagittal: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
583 return *sagittalGeometry_; |
102 | 584 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
585 case VolumeProjection_Coronal: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
586 return *coronalGeometry_; |
102 | 587 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
588 default: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
589 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
102 | 590 } |
591 } | |
592 | |
593 | |
594 bool DetectProjection(VolumeProjection& projection, | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
104
diff
changeset
|
595 const CoordinateSystem3D& viewportSlice) |
102 | 596 { |
597 bool isOpposite; // Ignored | |
598 | |
599 if (GeometryToolbox::IsParallelOrOpposite(isOpposite, | |
600 viewportSlice.GetNormal(), | |
601 axialGeometry_->GetNormal())) | |
602 { | |
603 projection = VolumeProjection_Axial; | |
604 return true; | |
605 } | |
606 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite, | |
607 viewportSlice.GetNormal(), | |
608 sagittalGeometry_->GetNormal())) | |
609 { | |
610 projection = VolumeProjection_Sagittal; | |
611 return true; | |
612 } | |
613 else if (GeometryToolbox::IsParallelOrOpposite(isOpposite, | |
614 viewportSlice.GetNormal(), | |
615 coronalGeometry_->GetNormal())) | |
616 { | |
617 projection = VolumeProjection_Coronal; | |
618 return true; | |
619 } | |
620 else | |
621 { | |
622 return false; | |
623 } | |
624 } | |
625 | |
626 | |
627 public: | |
398
d257ea56b7be
renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
628 VolumeImageMPRSlicer(MessageBroker& broker, |
d257ea56b7be
renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
629 OrthancVolumeImage& volume) : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
630 IVolumeSlicer(broker), |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
631 IObserver(broker), |
102 | 632 volume_(volume) |
633 { | |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
634 volume_.RegisterObserverCallback( |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
635 new Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryReadyMessage> |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
636 (*this, &VolumeImageMPRSlicer::OnGeometryReady)); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
637 |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
638 volume_.RegisterObserverCallback( |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
639 new Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryErrorMessage> |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
640 (*this, &VolumeImageMPRSlicer::OnGeometryError)); |
102 | 641 |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
642 volume_.RegisterObserverCallback( |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
643 new Callable<VolumeImageMPRSlicer, ISlicedVolume::ContentChangedMessage> |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
644 (*this, &VolumeImageMPRSlicer::OnContentChanged)); |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
645 |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
646 volume_.RegisterObserverCallback( |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
647 new Callable<VolumeImageMPRSlicer, ISlicedVolume::SliceContentChangedMessage> |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
648 (*this, &VolumeImageMPRSlicer::OnSliceContentChanged)); |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
649 } |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
650 |
102 | 651 virtual bool GetExtent(std::vector<Vector>& points, |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
652 const CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE |
102 | 653 { |
654 VolumeProjection projection; | |
655 | |
656 if (!IsGeometryReady() || | |
657 !DetectProjection(projection, viewportSlice)) | |
658 { | |
659 return false; | |
660 } | |
661 else | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
662 { |
102 | 663 // As the slices of the volumic image are arranged in a box, |
664 // we only consider one single reference slice (the one with index 0). | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
665 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0)); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
666 slice->GetExtent(points); |
102 | 667 |
668 return true; | |
669 } | |
670 } | |
671 | |
672 | |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
673 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE |
102 | 674 { |
675 VolumeProjection projection; | |
676 | |
677 if (IsGeometryReady() && | |
678 DetectProjection(projection, viewportSlice)) | |
679 { | |
680 const VolumeImageGeometry& geometry = GetProjectionGeometry(projection); | |
681 | |
682 size_t closest; | |
683 | |
684 if (geometry.LookupSlice(closest, viewportSlice)) | |
685 { | |
686 bool isFullQuality = true; // TODO | |
687 | |
688 std::auto_ptr<Orthanc::Image> frame; | |
689 | |
690 { | |
691 ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, closest); | |
692 | |
693 // TODO Transfer ownership if non-axial, to avoid memcpy | |
694 frame.reset(Orthanc::Image::Clone(reader.GetAccessor())); | |
695 } | |
696 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
697 std::auto_ptr<Slice> slice(geometry.GetSlice(closest)); |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
698 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
699 RendererFactory factory(*frame, *slice, isFullQuality); |
401
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
700 |
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
701 EmitMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); |
102 | 702 return; |
703 } | |
704 } | |
705 | |
706 // Error | |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
120
diff
changeset
|
707 CoordinateSystem3D slice; |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
708 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, slice)); |
102 | 709 } |
710 }; | |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
711 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
712 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
713 class VolumeImageInteractor : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
714 public IWorldSceneInteractor, |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
715 public IObserver |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
716 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
717 private: |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
718 SliceViewerWidget& widget_; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
719 VolumeProjection projection_; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
720 std::auto_ptr<VolumeImageGeometry> slices_; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
721 size_t slice_; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
722 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
723 protected: |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
724 void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
725 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
726 if (slices_.get() == NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
727 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
728 const OrthancVolumeImage& image = |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
729 dynamic_cast<const OrthancVolumeImage&>(message.GetOrigin()); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
730 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
731 slices_.reset(new VolumeImageGeometry(image, projection_)); |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
732 SetSlice(slices_->GetSliceCount() / 2); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
733 |
330 | 734 widget_.FitContent(); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
735 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
736 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
737 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
738 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
739 const ViewportGeometry& view, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
740 MouseButton button, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
741 double x, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
742 double y, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
743 IStatusBar* statusBar) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
744 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
745 return NULL; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
746 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
747 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
748 virtual void MouseOver(CairoContext& context, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
749 WorldSceneWidget& widget, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
750 const ViewportGeometry& view, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
751 double x, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
752 double y, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
753 IStatusBar* statusBar) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
754 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
755 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
756 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
757 virtual void MouseWheel(WorldSceneWidget& widget, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
758 MouseWheelDirection direction, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
759 KeyboardModifiers modifiers, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
760 IStatusBar* statusBar) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
761 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
762 int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1); |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
763 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
764 switch (direction) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
765 { |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
766 case MouseWheelDirection_Up: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
767 OffsetSlice(-scale); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
768 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
769 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
770 case MouseWheelDirection_Down: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
771 OffsetSlice(scale); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
772 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
773 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
774 default: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
775 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
776 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
777 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
778 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
779 virtual void KeyPressed(WorldSceneWidget& widget, |
327 | 780 KeyboardKeys key, |
781 char keyChar, | |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
782 KeyboardModifiers modifiers, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
783 IStatusBar* statusBar) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
784 { |
327 | 785 switch (keyChar) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
786 { |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
787 case 's': |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
788 widget.FitContent(); |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
789 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
790 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
791 default: |
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
792 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
793 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
794 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
795 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
796 public: |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
797 VolumeImageInteractor(MessageBroker& broker, |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
798 OrthancVolumeImage& volume, |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
799 SliceViewerWidget& widget, |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
800 VolumeProjection projection) : |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
801 IObserver(broker), |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
802 widget_(widget), |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
803 projection_(projection) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
804 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
805 widget.SetInteractor(*this); |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
806 |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
807 volume.RegisterObserverCallback( |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
808 new Callable<VolumeImageInteractor, ISlicedVolume::GeometryReadyMessage> |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
809 (*this, &VolumeImageInteractor::OnGeometryReady)); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
810 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
811 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
812 bool IsGeometryReady() const |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
813 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
814 return slices_.get() != NULL; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
815 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
816 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
817 size_t GetSliceCount() const |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
818 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
819 if (slices_.get() == NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
820 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
821 return 0; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
822 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
823 else |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
824 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
825 return slices_->GetSliceCount(); |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
826 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
827 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
828 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
829 void OffsetSlice(int offset) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
830 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
831 if (slices_.get() != NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
832 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
833 int slice = static_cast<int>(slice_) + offset; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
834 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
835 if (slice < 0) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
836 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
837 slice = 0; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
838 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
839 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
840 if (slice >= static_cast<int>(slices_->GetSliceCount())) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
841 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
842 slice = slices_->GetSliceCount() - 1; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
843 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
844 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
845 if (slice != static_cast<int>(slice_)) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
846 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
847 SetSlice(slice); |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
848 } |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
849 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
850 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
851 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
852 void SetSlice(size_t slice) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
853 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
854 if (slices_.get() != NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
855 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
856 slice_ = slice; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
857 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
858 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_)); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
859 widget_.SetSlice(tmp->GetGeometry()); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
860 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
861 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
862 }; |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
863 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
864 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
865 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
866 class ReferenceLineSource : public IVolumeSlicer |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
867 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
868 private: |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
869 class RendererFactory : public LayerReadyMessage::IRendererFactory |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
870 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
871 private: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
872 double x1_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
873 double y1_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
874 double x2_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
875 double y2_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
876 const CoordinateSystem3D& slice_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
877 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
878 public: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
879 RendererFactory(double x1, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
880 double y1, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
881 double x2, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
882 double y2, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
883 const CoordinateSystem3D& slice) : |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
884 x1_(x1), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
885 y1_(y1), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
886 x2_(x2), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
887 y2_(y2), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
888 slice_(slice) |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
889 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
890 } |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
891 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
892 virtual ILayerRenderer* CreateRenderer() const |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
893 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
894 return new LineLayerRenderer(x1_, y1_, x2_, y2_, slice_); |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
895 } |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
896 }; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
897 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
898 SliceViewerWidget& otherPlane_; |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
899 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
900 public: |
390
0cb925325470
renamed SiblingSliceLocation as ReferenceLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
901 ReferenceLineSource(MessageBroker& broker, |
0cb925325470
renamed SiblingSliceLocation as ReferenceLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
902 SliceViewerWidget& otherPlane) : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
903 IVolumeSlicer(broker), |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
904 otherPlane_(otherPlane) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
905 { |
401
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
906 EmitMessage(IVolumeSlicer::GeometryReadyMessage(*this)); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
907 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
908 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
909 virtual bool GetExtent(std::vector<Vector>& points, |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
910 const CoordinateSystem3D& viewportSlice) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
911 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
912 return false; |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
913 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
914 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
915 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
916 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
917 Slice reference(viewportSlice, 0.001); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
918 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
919 Vector p, d; |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
920 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
921 const CoordinateSystem3D& slice = otherPlane_.GetSlice(); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
922 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
923 // Compute the line of intersection between the two slices |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
924 if (!GeometryToolbox::IntersectTwoPlanes(p, d, |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
925 slice.GetOrigin(), slice.GetNormal(), |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
926 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
927 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
928 // The two slice are parallel, don't try and display the intersection |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
929 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
930 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
931 else |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
932 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
933 double x1, y1, x2, y2; |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
934 viewportSlice.ProjectPoint(x1, y1, p); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
935 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
936 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
937 const Extent2D extent = otherPlane_.GetSceneExtent(); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
938 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
939 if (GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
940 x1, y1, x2, y2, |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
941 extent.GetX1(), extent.GetY1(), |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
942 extent.GetX2(), extent.GetY2())) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
943 { |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
944 RendererFactory factory(x1, y1, x2, y2, slice); |
401
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
945 EmitMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
946 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
947 else |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
948 { |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
949 // Error: Parallel slices |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
950 EmitMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
951 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
952 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
953 } |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
954 }; |
102 | 955 } |