annotate Framework/SmartLoader.cpp @ 568:6125640bffd6 cache-in-radiography

Close branch cache-in-radiography.
author Alain Mazy <am@osimis.io>
date Thu, 18 Apr 2019 11:59:09 +0000
parents f87f28624b96
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
260
am@osimis.io
parents:
diff changeset
1 /**
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
am@osimis.io
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
am@osimis.io
parents:
diff changeset
6 *
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
am@osimis.io
parents:
diff changeset
11 *
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
am@osimis.io
parents:
diff changeset
16 *
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
am@osimis.io
parents:
diff changeset
19 **/
am@osimis.io
parents:
diff changeset
20
am@osimis.io
parents:
diff changeset
21
am@osimis.io
parents:
diff changeset
22 #include "SmartLoader.h"
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
23 #include "Layers/DicomSeriesVolumeSlicer.h"
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
24 #include "Messages/MessageForwarder.h"
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
25 #include "Core/Images/Image.h"
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
26 #include "Framework/Widgets/SliceViewerWidget.h"
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
27 #include "Framework/StoneException.h"
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
28 #include "Framework/Layers/FrameRenderer.h"
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
29 #include "Core/Logging.h"
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
30 #include "Radiography/RadiographyScene.h"
260
am@osimis.io
parents:
diff changeset
31
am@osimis.io
parents:
diff changeset
32 namespace OrthancStone
am@osimis.io
parents:
diff changeset
33 {
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
34 enum CachedSliceStatus
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
35 {
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
36 CachedSliceStatus_ScheduledToLoad,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
37 CachedSliceStatus_GeometryLoaded,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
38 CachedSliceStatus_ImageLoaded
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
39 };
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
40
401
f1c769b3a5c2 start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
41 class SmartLoader::CachedSlice : public IVolumeSlicer
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
42 {
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
43 public:
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
44 class RendererFactory : public LayerReadyMessage::IRendererFactory
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
45 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
46 private:
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
47 const CachedSlice& that_;
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
48
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
49 public:
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
50 RendererFactory(const CachedSlice& that) :
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
51 that_(that)
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
52 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
53 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
54
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
55 virtual ILayerRenderer* CreateRenderer() const
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
56 {
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
57 bool isFull = (that_.effectiveQuality_ == SliceImageQuality_FullPng ||
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
58 that_.effectiveQuality_ == SliceImageQuality_FullPam);
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
59
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
60 return FrameRenderer::CreateRenderer(*that_.image_, *that_.slice_, isFull);
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
61 }
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
62 };
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
63
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
64 unsigned int sliceIndex_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
65 std::auto_ptr<Slice> slice_;
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
66 std::auto_ptr<OrthancPlugins::FullOrthancDataset> dicomTags_;
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
67
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
68 boost::shared_ptr<Orthanc::ImageAccessor> image_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
69 SliceImageQuality effectiveQuality_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
70 CachedSliceStatus status_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
71
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
72 public:
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
73 CachedSlice(MessageBroker& broker) :
401
f1c769b3a5c2 start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
74 IVolumeSlicer(broker)
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
75 {
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
76 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
77
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
78 virtual ~CachedSlice()
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
79 {
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
80 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
81
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
82 virtual bool GetExtent(std::vector<Vector>& points,
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
83 const CoordinateSystem3D& viewportSlice)
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
84 {
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
85 // TODO: viewportSlice is not used !!!!
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
86 slice_->GetExtent(points);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
87 return true;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
88 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
89
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
90 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice)
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
91 {
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
92 // TODO: viewportSlice is not used !!!!
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
93
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
94 // it has already been loaded -> trigger the "layer ready" message immediately otherwise, do nothing now. The LayerReady will be triggered
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
95 // once the VolumeSlicer is ready
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
96 if (status_ == CachedSliceStatus_ImageLoaded)
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
97 {
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
98 LOG(WARNING) << "ScheduleLayerCreation for CachedSlice (image is loaded): " << slice_->GetOrthancInstanceId();
381
19bd222283ae uncoupling LayerReadyMessage from the creation of the renderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 380
diff changeset
99
401
f1c769b3a5c2 start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
100 RendererFactory factory(*this);
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
101 EmitMessage(IVolumeSlicer::FrameReadyMessage(*this, image_));
401
f1c769b3a5c2 start getting rid of VolumeSlicerBase
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 396
diff changeset
102 EmitMessage(IVolumeSlicer::LayerReadyMessage(*this, factory, slice_->GetGeometry()));
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
103 }
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
104 else
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
105 {
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
106 LOG(WARNING) << "ScheduleLayerCreation for CachedSlice (image is not loaded yet): " << slice_->GetOrthancInstanceId();
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
107 }
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
108 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
109
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
110 CachedSlice* Clone() const
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
111 {
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
112 CachedSlice* output = new CachedSlice(GetBroker());
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
113 output->sliceIndex_ = sliceIndex_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
114 output->slice_.reset(slice_->Clone());
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
115 output->image_ = image_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
116 output->effectiveQuality_ = effectiveQuality_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
117 output->status_ = status_;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
118
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
119 return output;
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
120 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
121
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
122 };
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
123
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
124
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
125 SmartLoader::SmartLoader(MessageBroker& broker,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
126 OrthancApiClient& orthancApiClient) :
260
am@osimis.io
parents:
diff changeset
127 IObservable(broker),
am@osimis.io
parents:
diff changeset
128 IObserver(broker),
am@osimis.io
parents:
diff changeset
129 imageQuality_(SliceImageQuality_FullPam),
317
b66d13708f40 cleanup
am@osimis.io
parents: 300
diff changeset
130 orthancApiClient_(orthancApiClient)
267
89d02de83c03 added declaretion of messages handled/emitted
am@osimis.io
parents: 266
diff changeset
131 {
260
am@osimis.io
parents:
diff changeset
132 }
am@osimis.io
parents:
diff changeset
133
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
134 void SmartLoader::SetFrameInRadiographyScene(RadiographyScene& scene, const std::string& instanceId, unsigned int frame)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
135 {
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
136 // create the frame loader
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
137 std::auto_ptr<IVolumeSlicer> layerSource(GetFrameLoader(instanceId, frame));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
138 IVolumeSlicer* layerSource2 = layerSource.get();
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
139
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
140 // make sure that the widget registers the events before we trigger them (once we start loading the frame)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
141 scene.SetFrame(layerSource.release());
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
142
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
143 // start loading
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
144 LoadFrame(layerSource2, instanceId, frame);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
145 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
146
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
147
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
148 IVolumeSlicer* SmartLoader::GetFrameLoader(const std::string &instanceId, unsigned int frame)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
149 {
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
150 std::auto_ptr<IVolumeSlicer> layerSource;
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
151 std::string sliceKeyId = instanceId + ":" + boost::lexical_cast<std::string>(frame);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
152
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
153
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
154 if (cachedSlices_.find(sliceKeyId) != cachedSlices_.end()) // && cachedSlices_[sliceKeyId]->status_ == CachedSliceStatus_Loaded)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
155 { // if the image is cached, return a clone of the cached image
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
156 layerSource.reset(cachedSlices_[sliceKeyId]->Clone());
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
157 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
158 else
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
159 { // return a standard frame loader
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
160 layerSource.reset(new DicomSeriesVolumeSlicer(IObserver::GetBroker(), orthancApiClient_));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
161 dynamic_cast<DicomSeriesVolumeSlicer*>(layerSource.get())->SetImageQuality(imageQuality_);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
162 layerSource->RegisterObserverCallback(new Callable<SmartLoader, IVolumeSlicer::TagsReadyMessage>(*this, &SmartLoader::OnLayerTagsReady));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
163 layerSource->RegisterObserverCallback(new Callable<SmartLoader, DicomSeriesVolumeSlicer::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
164 layerSource->RegisterObserverCallback(new Callable<SmartLoader, IVolumeSlicer::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
165 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
166
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
167 return layerSource.release();
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
168 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
169
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
170 void SmartLoader::LoadFrame(IVolumeSlicer *frameLoader, const std::string &instanceId, unsigned int frame)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
171 {
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
172 SmartLoader::CachedSlice* cachedSlice = dynamic_cast<SmartLoader::CachedSlice*>(frameLoader);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
173
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
174 if (cachedSlice != NULL)
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
175 {
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
176 EmitMessage(IVolumeSlicer::GeometryReadyMessage(*cachedSlice));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
177 EmitMessage(IVolumeSlicer::TagsReadyMessage(*cachedSlice, *(cachedSlice->dicomTags_.get())));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
178 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
179 else
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
180 {
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
181 DicomSeriesVolumeSlicer* volumeLoader = dynamic_cast<DicomSeriesVolumeSlicer*>(frameLoader);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
182 volumeLoader->LoadFrame(instanceId, frame);
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
183 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
184
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
185 }
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
186
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
187 void SmartLoader::SetFrameInWidget(SliceViewerWidget& sliceViewer,
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
188 size_t layerIndex,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
189 const std::string& instanceId,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
190 unsigned int frame)
260
am@osimis.io
parents:
diff changeset
191 {
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
192 // create the frame loader
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
193 std::auto_ptr<IVolumeSlicer> layerSource(GetFrameLoader(instanceId, frame));
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
194 IVolumeSlicer* layerSource2 = layerSource.get();
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
195
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
196 // make sure that the widget registers the events before we trigger them (once we start loading the frame)
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
197 if (sliceViewer.GetLayerCount() == layerIndex)
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
198 {
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
199 sliceViewer.AddLayer(layerSource.release());
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
200 }
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
201 else if (sliceViewer.GetLayerCount() > layerIndex)
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
202 {
388
20f149669c1f renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 381
diff changeset
203 sliceViewer.ReplaceLayer(layerIndex, layerSource.release());
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
204 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
205 else
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
206 {
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
207 throw StoneException(ErrorCode_CanOnlyAddOneLayerAtATime);
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
208 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
209
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
210 // start loading
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
211 LoadFrame(layerSource2, instanceId, frame);
260
am@osimis.io
parents:
diff changeset
212 }
am@osimis.io
parents:
diff changeset
213
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
214 void SmartLoader::PreloadSlice(const std::string instanceId,
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
215 unsigned int frame)
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
216 {
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
217 // TODO: reactivate -> need to be able to ScheduleLayerLoading in IVolumeSlicer without calling ScheduleLayerCreation
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
218 return;
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
219 // TODO: check if it is already in the cache
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
220
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
221
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
222
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
223 // create the slice in the cache with "empty" data
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
224 boost::shared_ptr<CachedSlice> cachedSlice(new CachedSlice(IObserver::GetBroker()));
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
225 cachedSlice->slice_.reset(new Slice(instanceId, frame));
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
226 cachedSlice->status_ = CachedSliceStatus_ScheduledToLoad;
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
227 std::string sliceKeyId = instanceId + ":" + boost::lexical_cast<std::string>(frame);
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
228
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
229 LOG(WARNING) << "Will preload: " << sliceKeyId;
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
230
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
231 cachedSlices_[sliceKeyId] = boost::shared_ptr<CachedSlice>(cachedSlice);
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
232
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
233 std::auto_ptr<IVolumeSlicer> layerSource(new DicomSeriesVolumeSlicer(IObserver::GetBroker(), orthancApiClient_));
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
234
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
235 dynamic_cast<DicomSeriesVolumeSlicer*>(layerSource.get())->SetImageQuality(imageQuality_);
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
236 layerSource->RegisterObserverCallback(new Callable<SmartLoader, IVolumeSlicer::TagsReadyMessage>(*this, &SmartLoader::OnLayerTagsReady));
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
237 layerSource->RegisterObserverCallback(new Callable<SmartLoader, DicomSeriesVolumeSlicer::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady));
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
238 layerSource->RegisterObserverCallback(new Callable<SmartLoader, IVolumeSlicer::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady));
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
239 dynamic_cast<DicomSeriesVolumeSlicer*>(layerSource.get())->LoadFrame(instanceId, frame);
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
240
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
241 // keep a ref to the VolumeSlicer until the slice is fully loaded and saved to cache
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
242 preloadingInstances_[sliceKeyId] = boost::shared_ptr<IVolumeSlicer>(layerSource.release());
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents: 268
diff changeset
243 }
260
am@osimis.io
parents:
diff changeset
244
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
245
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
246 // void PreloadStudy(const std::string studyId)
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
247 // {
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
248 // /* TODO */
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
249 // }
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
250
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
251 // void PreloadSeries(const std::string seriesId)
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
252 // {
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
253 // /* TODO */
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
254 // }
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
255
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
256
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
257 void SmartLoader::OnLayerTagsReady(const IVolumeSlicer::TagsReadyMessage& message)
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
258 {
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
259 const DicomSeriesVolumeSlicer& source =
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
260 dynamic_cast<const DicomSeriesVolumeSlicer&>(message.GetOrigin());
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
261
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
262 // save/replace the slice in cache
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
263 const Slice& slice = source.GetSlice(0); // TODO handle GetSliceCount()
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
264 std::string sliceKeyId = (slice.GetOrthancInstanceId() + ":" +
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
265 boost::lexical_cast<std::string>(slice.GetFrame()));
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
266
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
267 LOG(WARNING) << "Geometry ready: " << sliceKeyId;
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
268
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
269 boost::shared_ptr<CachedSlice> cachedSlice(new CachedSlice(IObserver::GetBroker()));
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
270 cachedSlice->slice_.reset(slice.Clone());
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
271 cachedSlice->effectiveQuality_ = source.GetImageQuality();
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
272 cachedSlice->status_ = CachedSliceStatus_GeometryLoaded;
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
273 cachedSlice->dicomTags_.reset(message.GetDicomTags().Clone());
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
274
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
275 cachedSlices_[sliceKeyId] = boost::shared_ptr<CachedSlice>(cachedSlice);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
276
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
277 // re-emit original Layer message to observers
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
278 // EmitMessage(message);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
279 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
280
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
281
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
282 void SmartLoader::OnFrameReady(const DicomSeriesVolumeSlicer::FrameReadyMessage& message)
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
283 {
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
284 // save/replace the slice in cache
395
5f13809f3f76 rename ILayerSource::ImageReadyMessage to OrthancFrameLayerSource::FrameReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
285 const Slice& slice = message.GetSlice();
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
286 std::string sliceKeyId = (slice.GetOrthancInstanceId() + ":" +
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
287 boost::lexical_cast<std::string>(slice.GetFrame()));
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
288
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
289 LOG(WARNING) << "Image ready: " << sliceKeyId;
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
290
393
e7a494bdd956 removed Messages/MessageType.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 388
diff changeset
291 boost::shared_ptr<CachedSlice> cachedSlice(new CachedSlice(IObserver::GetBroker()));
395
5f13809f3f76 rename ILayerSource::ImageReadyMessage to OrthancFrameLayerSource::FrameReadyMessage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 393
diff changeset
292 cachedSlice->image_.reset(Orthanc::Image::Clone(message.GetFrame()));
378
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
293 cachedSlice->effectiveQuality_ = message.GetImageQuality();
814fa32e2fcc refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 377
diff changeset
294 cachedSlice->slice_.reset(message.GetSlice().Clone());
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
295 cachedSlice->status_ = CachedSliceStatus_ImageLoaded;
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
296
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
297 cachedSlices_[sliceKeyId] = cachedSlice;
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
298
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
299 // re-emit original Layer message to observers
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
300 // EmitMessage(IVolumeSlicer::FrameReadyMessage(*(cachedSlice.get()), cachedSlice->image_));
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
301 }
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
302
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
303
396
ed7146fa2c98 rename ILayerSource as IVolumeSlicer, and OrthancFrameLayerSource as as DicomSeriesVolumeSlicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 395
diff changeset
304 void SmartLoader::OnLayerReady(const IVolumeSlicer::LayerReadyMessage& message)
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
305 {
406
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
306 const DicomSeriesVolumeSlicer& source =
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
307 dynamic_cast<const DicomSeriesVolumeSlicer&>(message.GetOrigin());
5d359b115b29 use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
308
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
309 const Slice& slice = source.GetSlice(0); // TODO handle GetSliceCount() ?
334
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
310 std::string sliceKeyId = (slice.GetOrthancInstanceId() + ":" +
c34784e5f299 compatibility fixes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 330
diff changeset
311 boost::lexical_cast<std::string>(slice.GetFrame()));
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
312
330
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
313 LOG(WARNING) << "Layer ready: " << sliceKeyId;
7a364e44fbb4 renamed SetDefaultView in FitContent
am@osimis.io
parents: 322
diff changeset
314
322
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
315 // remove the slice from the preloading slices now that it has been fully loaded and it is referenced in the cache
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
316 if (preloadingInstances_.find(sliceKeyId) != preloadingInstances_.end())
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
317 {
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
318 preloadingInstances_.erase(sliceKeyId);
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
319 }
a902a07769d4 wip: preload slice
am@osimis.io
parents: 318
diff changeset
320
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
321 // re-emit original Layer message to observers
421
f87f28624b96 tentative to make SmartLoader and RadiographyScene work together (not really working)
am@osimis.io
parents: 406
diff changeset
322 // EmitMessage(message);
318
3a4ca166fafa ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents: 317
diff changeset
323 }
260
am@osimis.io
parents:
diff changeset
324 }