annotate Framework/SmartLoader.cpp @ 317:b66d13708f40 am-2

cleanup
author am@osimis.io
date Fri, 05 Oct 2018 11:57:36 +0200
parents b4abaeb783b1
children 3a4ca166fafa
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"
am@osimis.io
parents:
diff changeset
23 #include "Layers/OrthancFrameLayerSource.h"
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
24 #include "Messages/MessageForwarder.h"
260
am@osimis.io
parents:
diff changeset
25
am@osimis.io
parents:
diff changeset
26 namespace OrthancStone
am@osimis.io
parents:
diff changeset
27 {
317
b66d13708f40 cleanup
am@osimis.io
parents: 300
diff changeset
28 SmartLoader::SmartLoader(MessageBroker& broker, OrthancApiClient& orthancApiClient) :
260
am@osimis.io
parents:
diff changeset
29 IObservable(broker),
am@osimis.io
parents:
diff changeset
30 IObserver(broker),
am@osimis.io
parents:
diff changeset
31 imageQuality_(SliceImageQuality_FullPam),
317
b66d13708f40 cleanup
am@osimis.io
parents: 300
diff changeset
32 orthancApiClient_(orthancApiClient)
267
89d02de83c03 added declaretion of messages handled/emitted
am@osimis.io
parents: 266
diff changeset
33 {
260
am@osimis.io
parents:
diff changeset
34 }
am@osimis.io
parents:
diff changeset
35
am@osimis.io
parents:
diff changeset
36 ILayerSource* SmartLoader::GetFrame(const std::string& instanceId, unsigned int frame)
am@osimis.io
parents:
diff changeset
37 {
262
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
38 // TODO: check if this frame has already been loaded or is already being loaded.
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
39 // - if already loaded: create a "clone" that will emit the GeometryReady/ImageReady messages "immediately"
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
40 // (it can not be immediate because Observers needs to register first and this is done after this method returns)
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
41 // - if currently loading, we need to return an object that will observe the existing LayerSource and forward
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
42 // the messages to its observables
77fdab5b5d6e cleanup + todos
am@osimis.io
parents: 260
diff changeset
43 // in both cases, we must be carefull about objects lifecycle !!!
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
44 std::auto_ptr<OrthancFrameLayerSource> layerSource (new OrthancFrameLayerSource(IObserver::broker_, orthancApiClient_));
260
am@osimis.io
parents:
diff changeset
45 layerSource->SetImageQuality(imageQuality_);
300
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
46 layerSource->RegisterObserverCallback(new MessageForwarder<ILayerSource::GeometryReadyMessage>(IObserver::broker_, *this));
b4abaeb783b1 messaging refactoring almost complete: works fine in native
am@osimis.io
parents: 299
diff changeset
47 layerSource->RegisterObserverCallback(new MessageForwarder<ILayerSource::LayerReadyMessage>(IObserver::broker_, *this));
260
am@osimis.io
parents:
diff changeset
48 layerSource->LoadFrame(instanceId, frame);
am@osimis.io
parents:
diff changeset
49
am@osimis.io
parents:
diff changeset
50 return layerSource.release();
am@osimis.io
parents:
diff changeset
51 }
am@osimis.io
parents:
diff changeset
52
270
2d64f4d39610 backup (work in progress)
am@osimis.io
parents: 268
diff changeset
53 void SmartLoader::LoadStudyList()
2d64f4d39610 backup (work in progress)
am@osimis.io
parents: 268
diff changeset
54 {
2d64f4d39610 backup (work in progress)
am@osimis.io
parents: 268
diff changeset
55 // orthancApiClient_.ScheduleGetJsonRequest("/studies");
2d64f4d39610 backup (work in progress)
am@osimis.io
parents: 268
diff changeset
56 }
260
am@osimis.io
parents:
diff changeset
57
266
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
58 void PreloadStudy(const std::string studyId)
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
59 {
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
60 /* TODO */
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
61 }
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
62
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
63 void PreloadSeries(const std::string seriesId)
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
64 {
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
65 /* TODO */
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
66 }
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
67
c9cf95b49a86 removed OrthancSlicesLoader::ISliceLoaderObserver; now using standard messages instead
am@osimis.io
parents: 262
diff changeset
68
260
am@osimis.io
parents:
diff changeset
69 }