annotate Framework/dev.h @ 436:04711a2e12cd am-vsol-upgrade

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