annotate Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h @ 1602:b2941196cabf

SortedFrames::LookupFrame()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Oct 2020 16:35:45 +0100
parents 4fb8fdf03314
children 9ac2a65d4172
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
2 * Stone of Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
4 * Department, University Hospital of Liege, Belgium
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
6 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
7 * This program is free software: you can redistribute it and/or
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
10 * the License, or (at your option) any later version.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
11 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
12 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
15 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1560
diff changeset
16 *
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
19 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
21
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #pragma once
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23
1542
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
24 #include "../../../../OrthancStone/Sources/Loaders/DicomResourcesLoader.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
25 #include "../../../../OrthancStone/Sources/Loaders/ILoadersContext.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
26 #include "../../../../OrthancStone/Sources/Loaders/SeriesFramesLoader.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
27 #include "../../../../OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.h"
1560
b4ccd4963d37 fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1542
diff changeset
28 #include "../../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h"
b4ccd4963d37 fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1542
diff changeset
29 #include "../../../../OrthancStone/Sources/Viewport/IViewport.h"
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
31 #include <Compatibility.h> // For std::unique_ptr<>
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
32
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 #include <boost/make_shared.hpp>
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 using OrthancStone::ILoadersContext;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 using OrthancStone::ObserverBase;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 using OrthancStone::IViewport;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 using OrthancStone::DicomResourcesLoader;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 using OrthancStone::SeriesFramesLoader;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 using OrthancStone::TextureBaseSceneLayer;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 using OrthancStone::DicomSource;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 using OrthancStone::SeriesThumbnailsLoader;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 using OrthancStone::LoadedDicomResources;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 using OrthancStone::SeriesThumbnailType;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 using OrthancStone::OracleScheduler;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 using OrthancStone::OrthancRestApiCommand;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 using OrthancStone::OracleScheduler;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 using OrthancStone::OracleScheduler;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 using OrthancStone::OracleScheduler;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 class SdlSimpleViewerApplication : public ObserverBase<SdlSimpleViewerApplication>
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 public:
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 static boost::shared_ptr<SdlSimpleViewerApplication> Create(ILoadersContext& context, boost::shared_ptr<IViewport> viewport)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 boost::shared_ptr<SdlSimpleViewerApplication> application(new SdlSimpleViewerApplication(context, viewport));
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
62 std::unique_ptr<ILoadersContext::ILock> lock(context.Lock());
1472
474360793956 DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1457
diff changeset
63 application->dicomLoader_ = DicomResourcesLoader::Create(*lock);
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 application->Register<DicomResourcesLoader::SuccessMessage>(*application->dicomLoader_, &SdlSimpleViewerApplication::Handle);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 return application;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 void LoadOrthancFrame(const DicomSource& source, const std::string& instanceId, unsigned int frame)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
73 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 dicomLoader_->ScheduleLoadOrthancResource(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID),
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 0, source, Orthanc::ResourceType_Instance, instanceId,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 new Orthanc::SingleValueObject<unsigned int>(frame));
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 #if 0
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 void LoadDicomWebFrame(const DicomSource& source,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 const std::string& studyInstanceUid,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 const std::string& seriesInstanceUid,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 const std::string& sopInstanceUid,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 unsigned int frame)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
87 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 // We first must load the "/metadata" to know the number of frames
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 dicomLoader_->ScheduleGetDicomWeb(
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), 0, source,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 "/studies/" + studyInstanceUid + "/series/" + seriesInstanceUid + "/instances/" + sopInstanceUid + "/metadata",
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 new Orthanc::SingleValueObject<unsigned int>(frame));
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 #endif
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 void FitContent()
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
99 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 lock->GetCompositor().FitContent(lock->GetController().GetScene());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 lock->Invalidate();
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 private:
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 ILoadersContext& context_;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 boost::shared_ptr<IViewport> viewport_;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 boost::shared_ptr<DicomResourcesLoader> dicomLoader_;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 boost::shared_ptr<SeriesFramesLoader> framesLoader_;
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 SdlSimpleViewerApplication(ILoadersContext& context,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 boost::shared_ptr<IViewport> viewport) :
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 context_(context),
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 viewport_(viewport)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119 LOG(INFO) << "Frame decoded! "
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 << message.GetImage().GetWidth() << "x" << message.GetImage().GetHeight()
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 << " " << Orthanc::EnumerationToString(message.GetImage().GetFormat());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
123 std::unique_ptr<TextureBaseSceneLayer> layer(
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 message.GetInstanceParameters().CreateTexture(message.GetImage()));
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 layer->SetLinearInterpolation(true);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
128 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 lock->GetController().GetScene().SetLayer(0, layer.release());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 lock->GetCompositor().FitContent(lock->GetController().GetScene());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 lock->Invalidate();
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 void Handle(const DicomResourcesLoader::SuccessMessage& message)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 if (message.GetResources()->GetSize() != 1)
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 {
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 //message.GetResources()->GetResource(0).Print(stdout);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 {
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1472
diff changeset
145 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
1358
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 SeriesFramesLoader::Factory f(*message.GetResources());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>(
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
149 f.Create(*lock));
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
151 Register<SeriesFramesLoader::FrameLoadedMessage>(
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 *framesLoader_, &SdlSimpleViewerApplication::Handle);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 assert(message.HasUserPayload());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
155
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 const Orthanc::SingleValueObject<unsigned int>& payload =
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
157 dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>(
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 message.GetUserPayload());
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 LOG(INFO) << "Loading pixel data of frame: " << payload.GetValue();
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 framesLoader_->ScheduleLoadFrame(
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162 0, message.GetDicomSource(), payload.GetValue(),
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
163 message.GetDicomSource().GetQualityCount() - 1 /* download best quality available */,
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
164 NULL);
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
165 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
166 }
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
167
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
168 };
4287eaabe490 Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169