Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/dev.h @ 874:debb70fa10b5 am-dev
correct handling of deleted observers in OrthancApiClient
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 03 Jul 2019 10:11:22 +0200 |
parents | c0fcb2757b0a |
children | 2d8ab34c8c91 |
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 | |
439 | 5 * Copyright (C) 2017-2019 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" |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
30 #include "Volumes/ISlicedVolume.h" |
102 | 31 #include "Volumes/ImageBuffer3D.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 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
41 namespace Deprecated |
102 | 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, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
46 public OrthancStone::IObserver |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
47 { |
102 | 48 private: |
49 OrthancSlicesLoader loader_; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
50 std::auto_ptr<OrthancStone::ImageBuffer3D> image_; |
102 | 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_; |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
54 |
102 | 55 void ScheduleSliceDownload() |
56 { | |
57 assert(downloadStack_.get() != NULL); | |
58 | |
59 unsigned int slice; | |
60 if (downloadStack_->Pop(slice)) | |
61 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
62 loader_.ScheduleLoadSliceImage(slice, OrthancStone::SliceImageQuality_Jpeg90); |
102 | 63 } |
64 } | |
65 | |
66 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
67 static bool IsCompatible(const Slice& a, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
68 const Slice& b) |
102 | 69 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
70 if (!OrthancStone::GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
71 b.GetGeometry().GetNormal())) |
102 | 72 { |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
73 LOG(ERROR) << "A slice in the volume image is not parallel to the others."; |
102 | 74 return false; |
75 } | |
76 | |
77 if (a.GetConverter().GetExpectedPixelFormat() != b.GetConverter().GetExpectedPixelFormat()) | |
78 { | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
79 LOG(ERROR) << "The pixel format changes across the slices of the volume image."; |
102 | 80 return false; |
81 } | |
82 | |
83 if (a.GetWidth() != b.GetWidth() || | |
84 a.GetHeight() != b.GetHeight()) | |
85 { | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
86 LOG(ERROR) << "The slices dimensions (width/height) are varying throughout the volume image"; |
102 | 87 return false; |
88 } | |
89 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
90 if (!OrthancStone::LinearAlgebra::IsNear(a.GetPixelSpacingX(), b.GetPixelSpacingX()) || |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
91 !OrthancStone::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 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
101 static double GetDistance(const Slice& a, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
102 const Slice& b) |
102 | 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_); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
112 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
113 if (loader_.GetSlicesCount() == 0) |
102 | 114 { |
115 LOG(ERROR) << "Empty volume image"; | |
624 | 116 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
102 | 117 return; |
118 } | |
119 | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
120 for (size_t i = 1; i < loader_.GetSlicesCount(); 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 { |
624 | 124 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
102 | 125 return; |
126 } | |
127 } | |
128 | |
129 double spacingZ; | |
130 | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
131 if (loader_.GetSlicesCount() > 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 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
142 for (size_t i = 1; i < loader_.GetSlicesCount(); i++) |
102 | 143 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
144 if (!OrthancStone::LinearAlgebra::IsNear(spacingZ, GetDistance(loader_.GetSlice(i - 1), loader_.GetSlice(i)), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
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"; | |
624 | 148 BroadcastMessage(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 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
157 << "x" << loader_.GetSlicesCount() << " in " << Orthanc::EnumerationToString(format); |
102 | 158 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
159 image_.reset(new OrthancStone::ImageBuffer3D(format, width, height, static_cast<unsigned int>(loader_.GetSlicesCount()), computeRange_)); |
684
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
160 image_->GetGeometry().SetAxialGeometry(loader_.GetSlice(0).GetGeometry()); |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
diff
changeset
|
161 image_->GetGeometry().SetVoxelDimensions(loader_.GetSlice(0).GetPixelSpacingX(), |
7719eb852dd5
new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
647
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 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
165 downloadStack_.reset(new DownloadStack(static_cast<unsigned int>(loader_.GetSlicesCount()))); |
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
166 pendingSlices_ = loader_.GetSlicesCount(); |
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 | |
624 | 175 BroadcastMessage(ISlicedVolume::GeometryReadyMessage(*this)); |
102 | 176 } |
177 | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
178 |
406
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"; |
624 | 184 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this)); |
406
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 |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
187 |
406
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 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
193 OrthancStone::ImageBuffer3D::SliceWriter writer(*image_, OrthancStone::VolumeProjection_Axial, message.GetSliceIndex()); |
406
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 | |
624 | 197 BroadcastMessage(ISlicedVolume::SliceContentChangedMessage |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
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 { |
624 | 202 BroadcastMessage(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 | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
213 |
406
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: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
224 OrthancVolumeImage(OrthancStone::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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
234 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryReadyMessage> |
406
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
238 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryErrorMessage> |
406
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
242 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageReadyMessage> |
406
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
246 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageErrorMessage> |
406
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 | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
266 virtual size_t GetSlicesCount() const |
102 | 267 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
268 return loader_.GetSlicesCount(); |
102 | 269 } |
270 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
271 virtual const Slice& GetSlice(size_t index) const |
102 | 272 { |
273 return loader_.GetSlice(index); | |
274 } | |
275 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
276 OrthancStone::ImageBuffer3D& GetImage() const |
102 | 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, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
290 const DicomFrameConverter& converter) const |
119
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 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
304 class VolumeImageGeometry |
102 | 305 { |
306 private: | |
307 unsigned int width_; | |
308 unsigned int height_; | |
309 size_t depth_; | |
310 double pixelSpacingX_; | |
311 double pixelSpacingY_; | |
312 double sliceThickness_; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
313 OrthancStone::CoordinateSystem3D reference_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
314 DicomFrameConverter converter_; |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
315 |
102 | 316 double ComputeAxialThickness(const OrthancVolumeImage& volume) const |
317 { | |
318 double thickness; | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
319 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
320 size_t n = volume.GetSlicesCount(); |
102 | 321 if (n > 1) |
322 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
323 const Slice& a = volume.GetSlice(0); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
324 const Slice& b = volume.GetSlice(n - 1); |
102 | 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 } | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
345 |
102 | 346 void SetupAxial(const OrthancVolumeImage& volume) |
347 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
348 const Slice& axial = volume.GetSlice(0); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
349 |
102 | 350 width_ = axial.GetWidth(); |
351 height_ = axial.GetHeight(); | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
352 depth_ = volume.GetSlicesCount(); |
102 | 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 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
363 const Slice& axial = volume.GetSlice(0); |
102 | 364 double axialThickness = ComputeAxialThickness(volume); |
365 | |
366 width_ = axial.GetWidth(); | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
367 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); |
102 | 368 depth_ = axial.GetHeight(); |
369 | |
370 pixelSpacingX_ = axial.GetPixelSpacingX(); | |
371 pixelSpacingY_ = axialThickness; | |
372 sliceThickness_ = axial.GetPixelSpacingY(); | |
373 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
374 OrthancStone::Vector origin = axial.GetGeometry().GetOrigin(); |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
375 origin += (static_cast<double>(volume.GetSlicesCount() - 1) * |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
376 axialThickness * axial.GetGeometry().GetNormal()); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
377 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
378 reference_ = OrthancStone::CoordinateSystem3D(origin, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
379 axial.GetGeometry().GetAxisX(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
380 - axial.GetGeometry().GetNormal()); |
102 | 381 } |
382 | |
383 void SetupSagittal(const OrthancVolumeImage& volume) | |
384 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
385 const Slice& axial = volume.GetSlice(0); |
102 | 386 double axialThickness = ComputeAxialThickness(volume); |
387 | |
388 width_ = axial.GetHeight(); | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
389 height_ = static_cast<unsigned int>(volume.GetSlicesCount()); |
102 | 390 depth_ = axial.GetWidth(); |
391 | |
392 pixelSpacingX_ = axial.GetPixelSpacingY(); | |
393 pixelSpacingY_ = axialThickness; | |
394 sliceThickness_ = axial.GetPixelSpacingX(); | |
395 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
396 OrthancStone::Vector origin = axial.GetGeometry().GetOrigin(); |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
397 origin += (static_cast<double>(volume.GetSlicesCount() - 1) * |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
398 axialThickness * axial.GetGeometry().GetNormal()); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
399 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
400 reference_ = OrthancStone::CoordinateSystem3D(origin, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
401 axial.GetGeometry().GetAxisY(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
402 axial.GetGeometry().GetNormal()); |
102 | 403 } |
404 | |
405 public: | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
406 VolumeImageGeometry(const OrthancVolumeImage& volume, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
407 OrthancStone::VolumeProjection projection) |
102 | 408 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
409 if (volume.GetSlicesCount() == 0) |
102 | 410 { |
411 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
412 } | |
413 | |
414 converter_ = volume.GetSlice(0).GetConverter(); | |
415 | |
416 switch (projection) | |
417 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
418 case OrthancStone::VolumeProjection_Axial: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
419 SetupAxial(volume); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
420 break; |
102 | 421 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
422 case OrthancStone::VolumeProjection_Coronal: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
423 SetupCoronal(volume); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
424 break; |
102 | 425 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
426 case OrthancStone::VolumeProjection_Sagittal: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
427 SetupSagittal(volume); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
428 break; |
102 | 429 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
430 default: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
431 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
102 | 432 } |
433 } | |
434 | |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
435 size_t GetSlicesCount() const |
102 | 436 { |
437 return depth_; | |
438 } | |
439 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
440 const OrthancStone::Vector& GetNormal() const |
102 | 441 { |
442 return reference_.GetNormal(); | |
443 } | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
444 |
102 | 445 bool LookupSlice(size_t& index, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
446 const OrthancStone::CoordinateSystem3D& slice) const |
102 | 447 { |
448 bool opposite; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
449 if (!OrthancStone::GeometryToolbox::IsParallelOrOpposite(opposite, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
450 reference_.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
451 slice.GetNormal())) |
102 | 452 { |
453 return false; | |
454 } | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
455 |
102 | 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 || | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
462 s >= static_cast<int>(depth_)) |
102 | 463 { |
464 return false; | |
465 } | |
466 else | |
467 { | |
468 index = static_cast<size_t>(s); | |
469 return true; | |
470 } | |
471 } | |
472 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
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 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
481 OrthancStone::CoordinateSystem3D origin(reference_.GetOrigin() + |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
482 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
483 reference_.GetAxisX(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
484 reference_.GetAxisY()); |
102 | 485 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
486 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
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, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
496 public OrthancStone::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_; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
503 const Slice& slice_; |
381
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, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
508 const Slice& slice, |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
509 bool isFullQuality) : |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
510 frame_(frame), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
511 slice_(slice), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
512 isFullQuality_(isFullQuality) |
381
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_; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
524 std::auto_ptr<VolumeImageGeometry> axialGeometry_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
525 std::auto_ptr<VolumeImageGeometry> coronalGeometry_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
526 std::auto_ptr<VolumeImageGeometry> sagittalGeometry_; |
102 | 527 |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
528 |
102 | 529 bool IsGeometryReady() const |
530 { | |
531 return axialGeometry_.get() != NULL; | |
532 } | |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
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_); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
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 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
539 axialGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Axial)); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
540 coronalGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Coronal)); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
541 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Sagittal)); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
542 |
624 | 543 BroadcastMessage(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_); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
549 |
624 | 550 BroadcastMessage(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_); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
556 |
624 | 557 BroadcastMessage(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? | |
624 | 567 BroadcastMessage(IVolumeSlicer::ContentChangedMessage(*this)); |
102 | 568 } |
569 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
570 const VolumeImageGeometry& GetProjectionGeometry(OrthancStone::VolumeProjection projection) |
102 | 571 { |
572 if (!IsGeometryReady()) | |
573 { | |
574 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
575 } | |
576 | |
577 switch (projection) | |
578 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
579 case OrthancStone::VolumeProjection_Axial: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
580 return *axialGeometry_; |
102 | 581 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
582 case OrthancStone::VolumeProjection_Sagittal: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
583 return *sagittalGeometry_; |
102 | 584 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
585 case OrthancStone::VolumeProjection_Coronal: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
586 return *coronalGeometry_; |
102 | 587 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
588 default: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
589 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
102 | 590 } |
591 } | |
592 | |
593 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
594 bool DetectProjection(OrthancStone::VolumeProjection& projection, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
595 const OrthancStone::CoordinateSystem3D& viewportSlice) |
102 | 596 { |
597 bool isOpposite; // Ignored | |
598 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
599 if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
600 viewportSlice.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
601 axialGeometry_->GetNormal())) |
102 | 602 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
603 projection = OrthancStone::VolumeProjection_Axial; |
102 | 604 return true; |
605 } | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
606 else if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
607 viewportSlice.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
608 sagittalGeometry_->GetNormal())) |
102 | 609 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
610 projection = OrthancStone::VolumeProjection_Sagittal; |
102 | 611 return true; |
612 } | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
613 else if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
614 viewportSlice.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
615 coronalGeometry_->GetNormal())) |
102 | 616 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
617 projection = OrthancStone::VolumeProjection_Coronal; |
102 | 618 return true; |
619 } | |
620 else | |
621 { | |
622 return false; | |
623 } | |
624 } | |
625 | |
626 | |
627 public: | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
628 VolumeImageMPRSlicer(OrthancStone::MessageBroker& broker, |
398
d257ea56b7be
renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
396
diff
changeset
|
629 OrthancVolumeImage& volume) : |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
630 IVolumeSlicer(broker), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
631 IObserver(broker), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
632 volume_(volume) |
102 | 633 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
634 volume_.RegisterObserverCallback( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
635 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryReadyMessage> |
405
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
639 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryErrorMessage> |
405
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
643 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::ContentChangedMessage> |
405
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( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
647 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::SliceContentChangedMessage> |
405
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 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
651 virtual bool GetExtent(std::vector<OrthancStone::Vector>& points, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
652 const OrthancStone::CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE |
102 | 653 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
654 OrthancStone::VolumeProjection projection; |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
655 |
102 | 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). | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
665 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0)); |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
666 slice->GetExtent(points); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
667 |
102 | 668 return true; |
669 } | |
670 } | |
671 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
672 virtual void ScheduleLayerCreation(const OrthancStone::CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE |
102 | 673 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
674 OrthancStone::VolumeProjection projection; |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
675 |
102 | 676 if (IsGeometryReady() && |
677 DetectProjection(projection, viewportSlice)) | |
678 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
679 const VolumeImageGeometry& geometry = GetProjectionGeometry(projection); |
102 | 680 |
681 size_t closest; | |
682 | |
683 if (geometry.LookupSlice(closest, viewportSlice)) | |
684 { | |
685 bool isFullQuality = true; // TODO | |
686 | |
687 std::auto_ptr<Orthanc::Image> frame; | |
688 | |
689 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
690 OrthancStone::ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, static_cast<unsigned int>(closest)); |
102 | 691 |
692 // TODO Transfer ownership if non-axial, to avoid memcpy | |
693 frame.reset(Orthanc::Image::Clone(reader.GetAccessor())); | |
694 } | |
695 | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
696 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
|
697 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
698 RendererFactory factory(*frame, *slice, isFullQuality); |
401
f1c769b3a5c2
start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
699 |
624 | 700 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry())); |
102 | 701 return; |
702 } | |
703 } | |
704 | |
705 // Error | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
706 OrthancStone::CoordinateSystem3D slice; |
624 | 707 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, slice)); |
102 | 708 } |
709 }; | |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
710 |
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 class VolumeImageInteractor : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
713 public IWorldSceneInteractor, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
714 public OrthancStone::IObserver |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
715 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
716 private: |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
717 SliceViewerWidget& widget_; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
718 OrthancStone::VolumeProjection projection_; |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
719 std::auto_ptr<VolumeImageGeometry> slices_; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
720 size_t slice_; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
721 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
722 protected: |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
723 void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
724 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
725 if (slices_.get() == NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
726 { |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
727 const OrthancVolumeImage& image = |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
728 dynamic_cast<const OrthancVolumeImage&>(message.GetOrigin()); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
729 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
730 slices_.reset(new VolumeImageGeometry(image, projection_)); |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
731 SetSlice(slices_->GetSlicesCount() / 2); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
732 |
330 | 733 widget_.FitContent(); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
734 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
735 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
736 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
737 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
738 const ViewportGeometry& view, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
739 OrthancStone::MouseButton button, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
740 OrthancStone::KeyboardModifiers modifiers, |
549
1d9deb4ee84c
Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents:
547
diff
changeset
|
741 int viewportX, |
1d9deb4ee84c
Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents:
547
diff
changeset
|
742 int viewportY, |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
743 double x, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
744 double y, |
549
1d9deb4ee84c
Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents:
547
diff
changeset
|
745 IStatusBar* statusBar, |
1d9deb4ee84c
Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents:
547
diff
changeset
|
746 const std::vector<Touch>& touches) ORTHANC_OVERRIDE |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
747 { |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
748 return NULL; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
749 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
750 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
751 virtual void MouseOver(OrthancStone::CairoContext& context, |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
752 WorldSceneWidget& widget, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
753 const ViewportGeometry& view, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
754 double x, |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
755 double y, |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
756 IStatusBar* statusBar) ORTHANC_OVERRIDE |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
757 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
758 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
759 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
760 virtual void MouseWheel(WorldSceneWidget& widget, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
761 OrthancStone::MouseWheelDirection direction, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
762 OrthancStone::KeyboardModifiers modifiers, |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
763 IStatusBar* statusBar) ORTHANC_OVERRIDE |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
764 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
765 int scale = (modifiers & OrthancStone::KeyboardModifiers_Control ? 10 : 1); |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
766 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
767 switch (direction) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
768 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
769 case OrthancStone::MouseWheelDirection_Up: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
770 OffsetSlice(-scale); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
771 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
772 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
773 case OrthancStone::MouseWheelDirection_Down: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
774 OffsetSlice(scale); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
775 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
776 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
777 default: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
778 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
779 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
780 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
781 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
782 virtual void KeyPressed(WorldSceneWidget& widget, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
783 OrthancStone::KeyboardKeys key, |
327 | 784 char keyChar, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
785 OrthancStone::KeyboardModifiers modifiers, |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
786 IStatusBar* statusBar) ORTHANC_OVERRIDE |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
787 { |
327 | 788 switch (keyChar) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
789 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
790 case 's': |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
791 widget.FitContent(); |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
792 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
793 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
794 default: |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
795 break; |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
796 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
797 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
798 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
799 public: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
800 VolumeImageInteractor(OrthancStone::MessageBroker& broker, |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
801 OrthancVolumeImage& volume, |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
802 SliceViewerWidget& widget, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
803 OrthancStone::VolumeProjection projection) : |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
804 IObserver(broker), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
805 widget_(widget), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
806 projection_(projection) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
807 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
808 widget.SetInteractor(*this); |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
809 |
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
810 volume.RegisterObserverCallback( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
811 new OrthancStone::Callable<VolumeImageInteractor, ISlicedVolume::GeometryReadyMessage> |
405
3942123602ba
removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
812 (*this, &VolumeImageInteractor::OnGeometryReady)); |
104
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 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
815 bool IsGeometryReady() const |
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 return slices_.get() != NULL; |
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 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
820 size_t GetSlicesCount() const |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
821 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
822 if (slices_.get() == NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
823 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
824 return 0; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
825 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
826 else |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
827 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
828 return slices_->GetSlicesCount(); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
829 } |
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 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
832 void OffsetSlice(int offset) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
833 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
834 if (slices_.get() != NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
835 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
836 int slice = static_cast<int>(slice_) + offset; |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
837 |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
838 if (slice < 0) |
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 slice = 0; |
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 |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
843 if (slice >= static_cast<int>(slices_->GetSlicesCount())) |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
844 { |
647
6af3099ed8da
uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
624
diff
changeset
|
845 slice = static_cast<unsigned int>(slices_->GetSlicesCount()) - 1; |
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 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
848 if (slice != static_cast<int>(slice_)) |
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 SetSlice(slice); |
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 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
853 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
854 |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
855 void SetSlice(size_t slice) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
856 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
857 if (slices_.get() != NULL) |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
858 { |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
859 slice_ = slice; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
860 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
861 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_)); |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
862 widget_.SetSlice(tmp->GetGeometry()); |
104
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
863 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
864 } |
eccd64f8e297
VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
865 }; |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
866 |
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 |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
869 class ReferenceLineSource : public IVolumeSlicer |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
870 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
871 private: |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
872 class RendererFactory : public LayerReadyMessage::IRendererFactory |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
873 { |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
874 private: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
875 double x1_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
876 double y1_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
877 double x2_; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
878 double y2_; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
879 const OrthancStone::CoordinateSystem3D& slice_; |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
880 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
881 public: |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
882 RendererFactory(double x1, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
883 double y1, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
884 double x2, |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
885 double y2, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
886 const OrthancStone::CoordinateSystem3D& slice) : |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
887 x1_(x1), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
888 y1_(y1), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
889 x2_(x2), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
890 y2_(y2), |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
891 slice_(slice) |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
892 { |
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 |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
895 virtual ILayerRenderer* CreateRenderer() const |
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 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
|
898 } |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
899 }; |
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
900 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
381
diff
changeset
|
901 SliceViewerWidget& otherPlane_; |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
902 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
903 public: |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
904 ReferenceLineSource(OrthancStone::MessageBroker& broker, |
390
0cb925325470
renamed SiblingSliceLocation as ReferenceLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
388
diff
changeset
|
905 SliceViewerWidget& otherPlane) : |
402
72355b637945
removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
401
diff
changeset
|
906 IVolumeSlicer(broker), |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
907 otherPlane_(otherPlane) |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
908 { |
624 | 909 BroadcastMessage(IVolumeSlicer::GeometryReadyMessage(*this)); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
910 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
911 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
912 virtual bool GetExtent(std::vector<OrthancStone::Vector>& points, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
913 const OrthancStone::CoordinateSystem3D& viewportSlice) |
112
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 return false; |
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 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
918 virtual void ScheduleLayerCreation(const OrthancStone::CoordinateSystem3D& viewportSlice) |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
919 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
920 Slice reference(viewportSlice, 0.001); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
921 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
922 OrthancStone::Vector p, d; |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
923 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
924 const OrthancStone::CoordinateSystem3D& slice = otherPlane_.GetSlice(); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
925 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
926 // Compute the line of intersection between the two slices |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
927 if (!OrthancStone::GeometryToolbox::IntersectTwoPlanes(p, d, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
928 slice.GetOrigin(), slice.GetNormal(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
929 viewportSlice.GetOrigin(), viewportSlice.GetNormal())) |
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 // The two slice are parallel, don't try and display the intersection |
624 | 932 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
933 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
934 else |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
935 { |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
936 double x1, y1, x2, y2; |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
937 viewportSlice.ProjectPoint(x1, y1, p); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
938 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d); |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
939 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
940 const OrthancStone::Extent2D extent = otherPlane_.GetSceneExtent(); |
547
0f43e479b49c
Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
941 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
942 if (OrthancStone::GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
943 x1, y1, x2, y2, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
944 extent.GetX1(), extent.GetY1(), |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
945 extent.GetX2(), extent.GetY2())) |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
946 { |
381
19bd222283ae
uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
380
diff
changeset
|
947 RendererFactory factory(x1, y1, x2, y2, slice); |
624 | 948 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
949 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
950 else |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
951 { |
380
ba5ad93f935a
ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
378
diff
changeset
|
952 // Error: Parallel slices |
624 | 953 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry())); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
954 } |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
955 } |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
300
diff
changeset
|
956 } |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
957 }; |
102 | 958 } |