annotate Framework/Deprecated/dev.h @ 1096:97cbb2c31a65 broker

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Oct 2019 09:38:17 +0200
parents c0fcb2757b0a
children 2d8ab34c8c91
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
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 406
diff changeset
5 * Copyright (C) 2017-2019 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"
736
c0fcb2757b0a enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
30 #include "Volumes/ISlicedVolume.h"
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include "Volumes/ImageBuffer3D.h"
402
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
32 #include "Widgets/SliceViewerWidget.h"
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
41 namespace Deprecated
102
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,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
46 public OrthancStone::IObserver
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
47 {
102
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_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
50 std::auto_ptr<OrthancStone::ImageBuffer3D> image_;
102
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_;
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
54
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
62 loader_.ScheduleLoadSliceImage(slice, OrthancStone::SliceImageQuality_Jpeg90);
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
67 static bool IsCompatible(const Slice& a,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
68 const Slice& b)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
70 if (!OrthancStone::GeometryToolbox::IsParallel(a.GetGeometry().GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
71 b.GetGeometry().GetNormal()))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
73 LOG(ERROR) << "A slice in the volume image is not parallel to the others.";
102
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 {
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
79 LOG(ERROR) << "The pixel format changes across the slices of the volume image.";
102
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 {
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
86 LOG(ERROR) << "The slices dimensions (width/height) are varying throughout the volume image";
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
90 if (!OrthancStone::LinearAlgebra::IsNear(a.GetPixelSpacingX(), b.GetPixelSpacingX()) ||
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
91 !OrthancStone::LinearAlgebra::IsNear(a.GetPixelSpacingY(), b.GetPixelSpacingY()))
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
101 static double GetDistance(const Slice& a,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
102 const Slice& b)
102
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_);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
112
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
113 if (loader_.GetSlicesCount() == 0)
102
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";
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
116 BroadcastMessage(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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
120 for (size_t i = 1; i < loader_.GetSlicesCount(); i++)
102
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 {
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
124 BroadcastMessage(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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
131 if (loader_.GetSlicesCount() > 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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
142 for (size_t i = 1; i < loader_.GetSlicesCount(); i++)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
144 if (!OrthancStone::LinearAlgebra::IsNear(spacingZ, GetDistance(loader_.GetSlice(i - 1), loader_.GetSlice(i)),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
145 0.001 /* this is expressed in mm */))
102
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";
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
148 BroadcastMessage(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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
157 << "x" << loader_.GetSlicesCount() << " in " << Orthanc::EnumerationToString(format);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
159 image_.reset(new OrthancStone::ImageBuffer3D(format, width, height, static_cast<unsigned int>(loader_.GetSlicesCount()), computeRange_));
684
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
160 image_->GetGeometry().SetAxialGeometry(loader_.GetSlice(0).GetGeometry());
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
161 image_->GetGeometry().SetVoxelDimensions(loader_.GetSlice(0).GetPixelSpacingX(),
7719eb852dd5 new class: VolumeImageGeometry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 647
diff changeset
162 loader_.GetSlice(0).GetPixelSpacingY(), spacingZ);
102
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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
165 downloadStack_.reset(new DownloadStack(static_cast<unsigned int>(loader_.GetSlicesCount())));
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
166 pendingSlices_ = loader_.GetSlicesCount();
102
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
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
175 BroadcastMessage(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
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
178
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
179 void OnSliceGeometryError(const OrthancSlicesLoader::SliceGeometryErrorMessage& message)
102
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";
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
184 BroadcastMessage(ISlicedVolume::GeometryErrorMessage(*this));
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
185 }
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
186
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
187
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
188 void OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message)
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
189 {
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
190 assert(&message.GetOrigin() == &loader_);
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
191
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
193 OrthancStone::ImageBuffer3D::SliceWriter writer(*image_, OrthancStone::VolumeProjection_Axial, message.GetSliceIndex());
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
194 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), message.GetImage());
102
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
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
197 BroadcastMessage(ISlicedVolume::SliceContentChangedMessage
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
198 (*this, message.GetSliceIndex(), message.GetSlice()));
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
199
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
200 if (pendingSlices_ == 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
201 {
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
202 BroadcastMessage(ISlicedVolume::VolumeReadyMessage(*this));
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
203 pendingSlices_ = 0;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
204 }
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
205 else if (pendingSlices_ > 1)
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
206 {
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
207 pendingSlices_ -= 1;
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
208 }
102
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
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
213
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
214 void OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message)
102
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:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
224 OrthancVolumeImage(OrthancStone::MessageBroker& broker,
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
225 OrthancApiClient& orthanc,
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
226 bool computeRange) :
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
227 ISlicedVolume(broker),
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
228 IObserver(broker),
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 252
diff changeset
229 loader_(broker, orthanc),
136
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
230 computeRange_(computeRange),
a06ad9d7406e ISlicedVolume::NotifyVolumeReady
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 135
diff changeset
231 pendingSlices_(0)
102
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(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
234 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryReadyMessage>
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
235 (*this, &OrthancVolumeImage::OnSliceGeometryReady));
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
236
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
237 loader_.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
238 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceGeometryErrorMessage>
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
239 (*this, &OrthancVolumeImage::OnSliceGeometryError));
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
240
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
241 loader_.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
242 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageReadyMessage>
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
243 (*this, &OrthancVolumeImage::OnSliceImageReady));
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
244
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
245 loader_.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
246 new OrthancStone::Callable<OrthancVolumeImage, OrthancSlicesLoader::SliceImageErrorMessage>
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 405
diff changeset
247 (*this, &OrthancVolumeImage::OnSliceImageError));
102
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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
266 virtual size_t GetSlicesCount() const
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 {
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
268 return loader_.GetSlicesCount();
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
271 virtual const Slice& GetSlice(size_t index) const
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
276 OrthancStone::ImageBuffer3D& GetImage() const
102
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,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
290 const DicomFrameConverter& converter) const
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
291 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
292 if (image_.get() == NULL)
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
293 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
294 return false;
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
295 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
296 else
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
297 {
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
298 return image_->FitWindowingToRange(style, converter);
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
299 }
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
300 }
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
304 class VolumeImageGeometry
102
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_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
313 OrthancStone::CoordinateSystem3D reference_;
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
314 DicomFrameConverter converter_;
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
315
102
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;
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
319
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
320 size_t n = volume.GetSlicesCount();
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
323 const Slice& a = volume.GetSlice(0);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
324 const Slice& b = volume.GetSlice(n - 1);
102
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 }
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
345
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
348 const Slice& axial = volume.GetSlice(0);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
349
102
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();
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
352 depth_ = volume.GetSlicesCount();
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
363 const Slice& axial = volume.GetSlice(0);
102
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();
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
367 height_ = static_cast<unsigned int>(volume.GetSlicesCount());
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
374 OrthancStone::Vector origin = axial.GetGeometry().GetOrigin();
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
375 origin += (static_cast<double>(volume.GetSlicesCount() - 1) *
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
376 axialThickness * axial.GetGeometry().GetNormal());
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
377
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
378 reference_ = OrthancStone::CoordinateSystem3D(origin,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
379 axial.GetGeometry().GetAxisX(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
380 - axial.GetGeometry().GetNormal());
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
385 const Slice& axial = volume.GetSlice(0);
102
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();
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
389 height_ = static_cast<unsigned int>(volume.GetSlicesCount());
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
396 OrthancStone::Vector origin = axial.GetGeometry().GetOrigin();
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
397 origin += (static_cast<double>(volume.GetSlicesCount() - 1) *
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
398 axialThickness * axial.GetGeometry().GetNormal());
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
399
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
400 reference_ = OrthancStone::CoordinateSystem3D(origin,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
401 axial.GetGeometry().GetAxisY(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
402 axial.GetGeometry().GetNormal());
102
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:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
406 VolumeImageGeometry(const OrthancVolumeImage& volume,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
407 OrthancStone::VolumeProjection projection)
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
409 if (volume.GetSlicesCount() == 0)
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
418 case OrthancStone::VolumeProjection_Axial:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
419 SetupAxial(volume);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
420 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
422 case OrthancStone::VolumeProjection_Coronal:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
423 SetupCoronal(volume);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
424 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
426 case OrthancStone::VolumeProjection_Sagittal:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
427 SetupSagittal(volume);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
428 break;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
430 default:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
431 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
102
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
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
435 size_t GetSlicesCount() const
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
440 const OrthancStone::Vector& GetNormal() const
102
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 }
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
444
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 bool LookupSlice(size_t& index,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
446 const OrthancStone::CoordinateSystem3D& slice) const
102
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;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
449 if (!OrthancStone::GeometryToolbox::IsParallelOrOpposite(opposite,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
450 reference_.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
451 slice.GetNormal()))
102
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 }
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
455
102
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 ||
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
462 s >= static_cast<int>(depth_))
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
473 Slice* GetSlice(size_t slice) const
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
481 OrthancStone::CoordinateSystem3D origin(reference_.GetOrigin() +
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
482 static_cast<double>(slice) * sliceThickness_ * reference_.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
483 reference_.GetAxisX(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
484 reference_.GetAxisY());
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
486 return new Slice(origin, pixelSpacingX_, pixelSpacingY_, sliceThickness_,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
487 width_, height_, converter_);
102
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,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
496 public OrthancStone::IObserver
102
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_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
503 const Slice& slice_;
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
504 bool isFullQuality_;
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
505
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
506 public:
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
507 RendererFactory(const Orthanc::ImageAccessor& frame,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
508 const Slice& slice,
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
509 bool isFullQuality) :
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
510 frame_(frame),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
511 slice_(slice),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
512 isFullQuality_(isFullQuality)
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
513 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
514 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
515
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
516 virtual ILayerRenderer* CreateRenderer() const
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
517 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
518 return FrameRenderer::CreateRenderer(frame_, slice_, isFullQuality_);
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
519 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
520 };
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
521
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
522
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 OrthancVolumeImage& volume_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
524 std::auto_ptr<VolumeImageGeometry> axialGeometry_;
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
525 std::auto_ptr<VolumeImageGeometry> coronalGeometry_;
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
526 std::auto_ptr<VolumeImageGeometry> sagittalGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
528
102
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 }
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
533
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
534 void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message)
102
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_);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
537
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 390
diff changeset
538 // These 3 values are only used to speed up the IVolumeSlicer
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
539 axialGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Axial));
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
540 coronalGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Coronal));
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
541 sagittalGeometry_.reset(new VolumeImageGeometry(volume_, OrthancStone::VolumeProjection_Sagittal));
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
542
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
543 BroadcastMessage(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_);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
549
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
550 BroadcastMessage(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_);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
556
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
557 BroadcastMessage(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?
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
567 BroadcastMessage(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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
570 const VolumeImageGeometry& GetProjectionGeometry(OrthancStone::VolumeProjection projection)
102
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 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
579 case OrthancStone::VolumeProjection_Axial:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
580 return *axialGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
582 case OrthancStone::VolumeProjection_Sagittal:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
583 return *sagittalGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
585 case OrthancStone::VolumeProjection_Coronal:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
586 return *coronalGeometry_;
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
588 default:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
589 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
594 bool DetectProjection(OrthancStone::VolumeProjection& projection,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
595 const OrthancStone::CoordinateSystem3D& viewportSlice)
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
599 if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
600 viewportSlice.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
601 axialGeometry_->GetNormal()))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
603 projection = OrthancStone::VolumeProjection_Axial;
102
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 }
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
606 else if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
607 viewportSlice.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
608 sagittalGeometry_->GetNormal()))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
610 projection = OrthancStone::VolumeProjection_Sagittal;
102
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 }
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
613 else if (OrthancStone::GeometryToolbox::IsParallelOrOpposite(isOpposite,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
614 viewportSlice.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
615 coronalGeometry_->GetNormal()))
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
617 projection = OrthancStone::VolumeProjection_Coronal;
102
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:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
628 VolumeImageMPRSlicer(OrthancStone::MessageBroker& broker,
398
d257ea56b7be renamed DicomStructureSetRendererFactory as DicomStructureSetSlicer, VolumeImageSource as VolumeImageMPRSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
629 OrthancVolumeImage& volume) :
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
630 IVolumeSlicer(broker),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
631 IObserver(broker),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
632 volume_(volume)
102
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(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
635 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryReadyMessage>
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
636 (*this, &VolumeImageMPRSlicer::OnGeometryReady));
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
637
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
638 volume_.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
639 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::GeometryErrorMessage>
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
640 (*this, &VolumeImageMPRSlicer::OnGeometryError));
102
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(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
643 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::ContentChangedMessage>
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
644 (*this, &VolumeImageMPRSlicer::OnContentChanged));
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
645
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
646 volume_.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
647 new OrthancStone::Callable<VolumeImageMPRSlicer, ISlicedVolume::SliceContentChangedMessage>
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
648 (*this, &VolumeImageMPRSlicer::OnSliceContentChanged));
402
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
649 }
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
650
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
651 virtual bool GetExtent(std::vector<OrthancStone::Vector>& points,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
652 const OrthancStone::CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
654 OrthancStone::VolumeProjection projection;
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
655
102
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).
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
665 std::auto_ptr<Slice> slice(GetProjectionGeometry(projection).GetSlice(0));
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
666 slice->GetExtent(points);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
667
102
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
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
672 virtual void ScheduleLayerCreation(const OrthancStone::CoordinateSystem3D& viewportSlice) ORTHANC_OVERRIDE
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
674 OrthancStone::VolumeProjection projection;
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
675
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 if (IsGeometryReady() &&
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 DetectProjection(projection, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
679 const VolumeImageGeometry& geometry = GetProjectionGeometry(projection);
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 size_t closest;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 if (geometry.LookupSlice(closest, viewportSlice))
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 {
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 bool isFullQuality = true; // TODO
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 std::auto_ptr<Orthanc::Image> frame;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
690 OrthancStone::ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, static_cast<unsigned int>(closest));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 // TODO Transfer ownership if non-axial, to avoid memcpy
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 frame.reset(Orthanc::Image::Clone(reader.GetAccessor()));
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
696 std::auto_ptr<Slice> slice(geometry.GetSlice(closest));
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
697
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
698 RendererFactory factory(*frame, *slice, isFullQuality);
401
f1c769b3a5c2 start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 399
diff changeset
699
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
700 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice->GetGeometry()));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 return;
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 }
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 // Error
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
706 OrthancStone::CoordinateSystem3D slice;
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
707 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, slice));
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 }
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 };
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
710
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
711
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
712 class VolumeImageInteractor :
402
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
713 public IWorldSceneInteractor,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
714 public OrthancStone::IObserver
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
715 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
716 private:
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
717 SliceViewerWidget& widget_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
718 OrthancStone::VolumeProjection projection_;
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
719 std::auto_ptr<VolumeImageGeometry> slices_;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
720 size_t slice_;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
721
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
722 protected:
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
723 void OnGeometryReady(const ISlicedVolume::GeometryReadyMessage& message)
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
724 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
725 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
726 {
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
727 const OrthancVolumeImage& image =
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
728 dynamic_cast<const OrthancVolumeImage&>(message.GetOrigin());
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
729
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
730 slices_.reset(new VolumeImageGeometry(image, projection_));
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
731 SetSlice(slices_->GetSlicesCount() / 2);
120
063f7f3d9f14 fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 119
diff changeset
732
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 327
diff changeset
733 widget_.FitContent();
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
734 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
735 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
736
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
737 virtual IWorldSceneMouseTracker* CreateMouseTracker(WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
738 const ViewportGeometry& view,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
739 OrthancStone::MouseButton button,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
740 OrthancStone::KeyboardModifiers modifiers,
549
1d9deb4ee84c Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents: 547
diff changeset
741 int viewportX,
1d9deb4ee84c Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents: 547
diff changeset
742 int viewportY,
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
743 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
744 double y,
549
1d9deb4ee84c Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents: 547
diff changeset
745 IStatusBar* statusBar,
1d9deb4ee84c Added RTSTRUCT demo viewer based on captain + fix in dev.h (wrong override signature)
Benjamin Golinvaux <bgo@osimis.io>
parents: 547
diff changeset
746 const std::vector<Touch>& touches) ORTHANC_OVERRIDE
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
747 {
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
748 return NULL;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
749 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
750
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
751 virtual void MouseOver(OrthancStone::CairoContext& context,
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
752 WorldSceneWidget& widget,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
753 const ViewportGeometry& view,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
754 double x,
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
755 double y,
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
756 IStatusBar* statusBar) ORTHANC_OVERRIDE
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
757 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
758 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
759
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
760 virtual void MouseWheel(WorldSceneWidget& widget,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
761 OrthancStone::MouseWheelDirection direction,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
762 OrthancStone::KeyboardModifiers modifiers,
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
763 IStatusBar* statusBar) ORTHANC_OVERRIDE
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
764 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
765 int scale = (modifiers & OrthancStone::KeyboardModifiers_Control ? 10 : 1);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
766
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
767 switch (direction)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
768 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
769 case OrthancStone::MouseWheelDirection_Up:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
770 OffsetSlice(-scale);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
771 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
772
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
773 case OrthancStone::MouseWheelDirection_Down:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
774 OffsetSlice(scale);
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
775 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
776
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
777 default:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
778 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
779 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
780 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
781
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
782 virtual void KeyPressed(WorldSceneWidget& widget,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
783 OrthancStone::KeyboardKeys key,
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 318
diff changeset
784 char keyChar,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
785 OrthancStone::KeyboardModifiers modifiers,
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
786 IStatusBar* statusBar) ORTHANC_OVERRIDE
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
787 {
327
8716176ff7f0 added support for arrow keys
am@osimis.io
parents: 318
diff changeset
788 switch (keyChar)
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
789 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
790 case 's':
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
791 widget.FitContent();
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
792 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
793
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
794 default:
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
795 break;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
796 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
797 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
798
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
799 public:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
800 VolumeImageInteractor(OrthancStone::MessageBroker& broker,
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
801 OrthancVolumeImage& volume,
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
802 SliceViewerWidget& widget,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
803 OrthancStone::VolumeProjection projection) :
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
804 IObserver(broker),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
805 widget_(widget),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
806 projection_(projection)
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
807 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
808 widget.SetInteractor(*this);
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
809
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
810 volume.RegisterObserverCallback(
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
811 new OrthancStone::Callable<VolumeImageInteractor, ISlicedVolume::GeometryReadyMessage>
405
3942123602ba removing ObserversRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 402
diff changeset
812 (*this, &VolumeImageInteractor::OnGeometryReady));
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
813 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
814
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
815 bool IsGeometryReady() const
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
816 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
817 return slices_.get() != NULL;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
818 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
819
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
820 size_t GetSlicesCount() const
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
821 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
822 if (slices_.get() == NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
823 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
824 return 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
825 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
826 else
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
827 {
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
828 return slices_->GetSlicesCount();
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
829 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
830 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
831
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
832 void OffsetSlice(int offset)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
833 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
834 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
835 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
836 int slice = static_cast<int>(slice_) + offset;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
837
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
838 if (slice < 0)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
839 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
840 slice = 0;
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
841 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
842
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
843 if (slice >= static_cast<int>(slices_->GetSlicesCount()))
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
844 {
647
6af3099ed8da uncoupling OrthancStone::SlicesSorter from OrthancStone::Slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 624
diff changeset
845 slice = static_cast<unsigned int>(slices_->GetSlicesCount()) - 1;
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
846 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
847
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
848 if (slice != static_cast<int>(slice_))
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
849 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
850 SetSlice(slice);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
851 }
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
852 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
853 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
854
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
855 void SetSlice(size_t slice)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
856 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
857 if (slices_.get() != NULL)
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
858 {
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
859 slice_ = slice;
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
860
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
861 std::auto_ptr<Slice> tmp(slices_->GetSlice(slice_));
119
ba83e38cf3ff rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 117
diff changeset
862 widget_.SetSlice(tmp->GetGeometry());
104
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
863 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
864 }
eccd64f8e297 VolumeImageInteractor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 102
diff changeset
865 };
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
866
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
867
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
868
402
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
869 class ReferenceLineSource : public IVolumeSlicer
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
870 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
871 private:
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
872 class RendererFactory : public LayerReadyMessage::IRendererFactory
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
873 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
874 private:
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
875 double x1_;
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
876 double y1_;
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
877 double x2_;
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
878 double y2_;
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
879 const OrthancStone::CoordinateSystem3D& slice_;
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
880
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
881 public:
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
882 RendererFactory(double x1,
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
883 double y1,
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
884 double x2,
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
885 double y2,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
886 const OrthancStone::CoordinateSystem3D& slice) :
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
887 x1_(x1),
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
888 y1_(y1),
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
889 x2_(x2),
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
890 y2_(y2),
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
891 slice_(slice)
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
892 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
893 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
894
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
895 virtual ILayerRenderer* CreateRenderer() const
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
896 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
897 return new LineLayerRenderer(x1_, y1_, x2_, y2_, slice_);
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
898 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
899 };
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
900
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
901 SliceViewerWidget& otherPlane_;
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
902
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
903 public:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
904 ReferenceLineSource(OrthancStone::MessageBroker& broker,
390
0cb925325470 renamed SiblingSliceLocation as ReferenceLine
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
905 SliceViewerWidget& otherPlane) :
402
72355b637945 removed VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
906 IVolumeSlicer(broker),
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
907 otherPlane_(otherPlane)
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
908 {
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
909 BroadcastMessage(IVolumeSlicer::GeometryReadyMessage(*this));
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
910 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
911
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
912 virtual bool GetExtent(std::vector<OrthancStone::Vector>& points,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
913 const OrthancStone::CoordinateSystem3D& viewportSlice)
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
914 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
915 return false;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
916 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
917
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
918 virtual void ScheduleLayerCreation(const OrthancStone::CoordinateSystem3D& viewportSlice)
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
919 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
920 Slice reference(viewportSlice, 0.001);
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
921
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
922 OrthancStone::Vector p, d;
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
923
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
924 const OrthancStone::CoordinateSystem3D& slice = otherPlane_.GetSlice();
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
925
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
926 // Compute the line of intersection between the two slices
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
927 if (!OrthancStone::GeometryToolbox::IntersectTwoPlanes(p, d,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
928 slice.GetOrigin(), slice.GetNormal(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
929 viewportSlice.GetOrigin(), viewportSlice.GetNormal()))
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
930 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
931 // The two slice are parallel, don't try and display the intersection
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
932 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry()));
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
933 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
934 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
935 {
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
936 double x1, y1, x2, y2;
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
937 viewportSlice.ProjectPoint(x1, y1, p);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
938 viewportSlice.ProjectPoint(x2, y2, p + 1000.0 * d);
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
939
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
940 const OrthancStone::Extent2D extent = otherPlane_.GetSceneExtent();
547
0f43e479b49c Removed old rtstruct demo (correct one on its way) + Many warning fixes (mostly 64-bit ?) + reformat + small fixes + indent (breaking long lines)
Benjamin Golinvaux <bgo@osimis.io>
parents: 439
diff changeset
941
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
942 if (OrthancStone::GeometryToolbox::ClipLineToRectangle(x1, y1, x2, y2,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
943 x1, y1, x2, y2,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
944 extent.GetX1(), extent.GetY1(),
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
945 extent.GetX2(), extent.GetY2()))
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
946 {
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
947 RendererFactory factory(x1, y1, x2, y2, slice);
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
948 BroadcastMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, reference.GetGeometry()));
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
949 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
950 else
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
951 {
380
ba5ad93f935a ILayerSource::LayerErrorMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
952 // Error: Parallel slices
624
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
953 BroadcastMessage(IVolumeSlicer::LayerErrorMessage(*this, reference.GetGeometry()));
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
954 }
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
955 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 300
diff changeset
956 }
112
948f86e61e83 start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 110
diff changeset
957 };
102
fcec0ab44054 display volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 }