Mercurial > hg > orthanc-stone
annotate Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h @ 2074:e160c324c32a
added DefineSourceBasenameForTarget is SDL samples
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Jul 2023 22:06:49 +0200 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
rev | line source |
---|---|
1457 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1457 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
17 * |
1457 | 18 * You should have received a copy of the GNU Affero General Public License |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #pragma once |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
1543 | 25 #include "../../../../OrthancStone/Sources/Loaders/DicomResourcesLoader.h" |
26 #include "../../../../OrthancStone/Sources/Loaders/ILoadersContext.h" | |
27 #include "../../../../OrthancStone/Sources/Loaders/SeriesFramesLoader.h" | |
28 #include "../../../../OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.h" | |
1560
b4ccd4963d37
fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
29 #include "../../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
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:
1474
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:
1474
diff
changeset
|
32 |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 #include <boost/make_shared.hpp> |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 namespace OrthancStone |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 class Application : public ObserverBase<Application> |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 private: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 ILoadersContext& context_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 boost::shared_ptr<IViewport> viewport_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 boost::shared_ptr<DicomResourcesLoader> dicomLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 boost::shared_ptr<SeriesFramesLoader> framesLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 Application(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 boost::shared_ptr<IViewport> viewport) : |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 context_(context), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 viewport_(viewport) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 LOG(INFO) << "Frame decoded! " |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 << message.GetImage().GetWidth() << "x" << message.GetImage().GetHeight() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 << " " << Orthanc::EnumerationToString(message.GetImage().GetFormat()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
59 std::unique_ptr<TextureBaseSceneLayer> layer( |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 message.GetInstanceParameters().CreateTexture(message.GetImage())); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 layer->SetLinearInterpolation(true); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
64 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 lock->GetController().GetScene().SetLayer(0, layer.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 lock->Invalidate(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 void Handle(const DicomResourcesLoader::SuccessMessage& message) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 if (message.GetResources()->GetSize() != 1) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 //message.GetResources()->GetResource(0).Print(stdout); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
81 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 SeriesFramesLoader::Factory f(*message.GetResources()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>(f.Create(*lock)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 Register<SeriesFramesLoader::FrameLoadedMessage>(*framesLoader_, &Application::Handle); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 assert(message.HasUserPayload()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 const Orthanc::SingleValueObject<unsigned int>& payload = |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>(message.GetUserPayload()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 LOG(INFO) << "Loading pixel data of frame: " << payload.GetValue(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 framesLoader_->ScheduleLoadFrame( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 0, message.GetDicomSource(), payload.GetValue(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 message.GetDicomSource().GetQualityCount() - 1 /* download best quality available */, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 NULL); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 static boost::shared_ptr<Application> Create(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 boost::shared_ptr<IViewport> viewport) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 boost::shared_ptr<Application> application(new Application(context, viewport)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
106 std::unique_ptr<ILoadersContext::ILock> lock(context.Lock()); |
1472
474360793956
DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
107 application->dicomLoader_ = DicomResourcesLoader::Create(*lock); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 application->Register<DicomResourcesLoader::SuccessMessage>(*application->dicomLoader_, &Application::Handle); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 return application; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 void LoadOrthancFrame(const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 const std::string& instanceId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 unsigned int frame) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
119 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 dicomLoader_->ScheduleLoadOrthancResource( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 0, source, Orthanc::ResourceType_Instance, instanceId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 new Orthanc::SingleValueObject<unsigned int>(frame)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 void LoadDicomWebFrame(const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 const std::string& seriesInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 const std::string& sopInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 unsigned int frame) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
133 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 // We first must load the "/metadata" to know the number of frames |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 dicomLoader_->ScheduleGetDicomWeb( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), 0, source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 "/studies/" + studyInstanceUid + "/series/" + seriesInstanceUid + "/instances/" + sopInstanceUid + "/metadata", |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 new Orthanc::SingleValueObject<unsigned int>(frame)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 void FitContent() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
144 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 lock->Invalidate(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 class IWebViewerLoadersObserver : public boost::noncopyable |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 virtual ~IWebViewerLoadersObserver() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
159 virtual void SignalSeriesUpdated(LoadedDicomResources& series) = 0; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 virtual void SignalThumbnailLoaded(const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 const std::string& seriesInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 SeriesThumbnailType type) = 0; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
164 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
165 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
166 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 class WebViewerLoaders : public ObserverBase<WebViewerLoaders> |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 private: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 static const int PRIORITY_ADD_RESOURCES = 0; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 static const int PRIORITY_THUMBNAILS = OracleScheduler::PRIORITY_LOW + 100; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
172 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
173 enum Type |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 Type_Orthanc = 1, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 Type_DicomWeb = 2 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 ILoadersContext& context_; |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
180 std::unique_ptr<IWebViewerLoadersObserver> observer_; |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 bool loadThumbnails_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 DicomSource source_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 std::set<std::string> scheduledSeries_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 std::set<std::string> scheduledThumbnails_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 std::set<std::string> scheduledStudies_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 boost::shared_ptr<LoadedDicomResources> loadedSeries_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 boost::shared_ptr<LoadedDicomResources> loadedStudies_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 boost::shared_ptr<DicomResourcesLoader> resourcesLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 boost::shared_ptr<SeriesThumbnailsLoader> thumbnailsLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 WebViewerLoaders(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 IWebViewerLoadersObserver* observer) : |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 context_(context), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 observer_(observer), |
1573 | 195 loadThumbnails_(false), |
196 loadedSeries_(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID)), | |
197 loadedStudies_(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)) | |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 static Orthanc::IDynamicObject* CreatePayload(Type type) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
202 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 return new Orthanc::SingleValueObject<Type>(type); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
206 void HandleThumbnail(const SeriesThumbnailsLoader::SuccessMessage& message) |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 if (observer_.get() != NULL) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 observer_->SignalThumbnailLoaded(message.GetStudyInstanceUid(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 message.GetSeriesInstanceUid(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 message.GetType()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 void HandleLoadedResources(const DicomResourcesLoader::SuccessMessage& message) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 LoadedDicomResources series(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
219 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 switch (dynamic_cast<const Orthanc::SingleValueObject<Type>&>(message.GetUserPayload()).GetValue()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
222 case Type_DicomWeb: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
223 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 for (size_t i = 0; i < loadedSeries_->GetSize(); i++) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 std::string study; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 if (loadedSeries_->GetResource(i).LookupStringValue( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 study, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 loadedStudies_->HasResource(study)) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 Orthanc::DicomMap m; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 m.Assign(loadedSeries_->GetResource(i)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 loadedStudies_->MergeResource(m, study); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 series.AddResource(m); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 break; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 case Type_Orthanc: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 for (size_t i = 0; i < message.GetResources()->GetSize(); i++) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
245 series.AddResource(message.GetResources()->GetResource(i)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 break; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 default: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 if (loadThumbnails_ && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 (!source_.IsDicomWeb() || |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 source_.HasDicomWebRendered())) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
258 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
259 for (size_t i = 0; i < series.GetSize(); i++) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
261 std::string patientId, studyInstanceUid, seriesInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 if (series.GetResource(i).LookupStringValue(patientId, Orthanc::DICOM_TAG_PATIENT_ID, false) && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
263 series.GetResource(i).LookupStringValue(studyInstanceUid, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 series.GetResource(i).LookupStringValue(seriesInstanceUid, Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, false) && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 scheduledThumbnails_.find(seriesInstanceUid) == scheduledThumbnails_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 scheduledThumbnails_.insert(seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 thumbnailsLoader_->ScheduleLoadThumbnail(source_, patientId, studyInstanceUid, seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
269 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
271 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 if (observer_.get() != NULL && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 series.GetSize() > 0) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
275 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 observer_->SignalSeriesUpdated(series); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
277 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
278 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
280 void HandleOrthancRestApi(const OrthancRestApiCommand::SuccessMessage& message) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 message.ParseJsonBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
285 if (body.type() != Json::arrayValue) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
287 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
289 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 for (Json::Value::ArrayIndex i = 0; i < body.size(); i++) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
293 if (body[i].type() == Json::stringValue) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
295 AddOrthancSeries(body[i].asString()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
296 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
297 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
298 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
299 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
301 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
302 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 static boost::shared_ptr<WebViewerLoaders> Create(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 bool loadThumbnails, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 IWebViewerLoadersObserver* observer) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 boost::shared_ptr<WebViewerLoaders> application(new WebViewerLoaders(context, observer)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 application->source_ = source; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 application->loadThumbnails_ = loadThumbnails; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
316 std::unique_ptr<ILoadersContext::ILock> lock(context.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 |
1472
474360793956
DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
318 application->resourcesLoader_ = DicomResourcesLoader::Create(*lock); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 SeriesThumbnailsLoader::Factory f; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
322 f.SetPriority(PRIORITY_THUMBNAILS); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
323 application->thumbnailsLoader_ = boost::dynamic_pointer_cast<SeriesThumbnailsLoader>(f.Create(*lock)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
325 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
326 application->Register<OrthancRestApiCommand::SuccessMessage>( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 lock->GetOracleObservable(), &WebViewerLoaders::HandleOrthancRestApi); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
328 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 application->Register<DicomResourcesLoader::SuccessMessage>( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
330 *application->resourcesLoader_, &WebViewerLoaders::HandleLoadedResources); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 |
1474
d1dde1f86d4a
fix build of wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
332 application->Register<SeriesThumbnailsLoader::SuccessMessage>( |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 *application->thumbnailsLoader_, &WebViewerLoaders::HandleThumbnail); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 lock->AddLoader(application); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
337 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
338 return application; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 void AddDicomAllSeries() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
343 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
347 resourcesLoader_->ScheduleGetDicomWeb(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 "/series", CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 resourcesLoader_->ScheduleGetDicomWeb(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 "/studies", CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
351 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
354 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 command->SetMethod(Orthanc::HttpMethod_Get); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 command->SetUri("/series"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
363 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
364 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
365 void AddDicomStudy(const std::string& studyInstanceUid) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 // Avoid adding twice the same study |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 if (scheduledStudies_.find(studyInstanceUid) == scheduledStudies_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 scheduledStudies_.insert(studyInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
374 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
375 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
376 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
377 std::set<Orthanc::DicomTag> tags; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
379 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
380 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
382 resourcesLoader_->ScheduleQido(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
383 Orthanc::ResourceType_Study, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
384 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
385 resourcesLoader_->ScheduleQido(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
386 Orthanc::ResourceType_Series, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
388 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
389 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
391 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 command->SetMethod(Orthanc::HttpMethod_Post); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 command->SetUri("/tools/find"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 body["Level"] = "Series"; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 body["Query"] = Json::objectValue; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 body["Query"]["StudyInstanceUID"] = studyInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 command->SetBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
402 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
405 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
406 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
407 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
408 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
409 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
410 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
411 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
412 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
413 void AddDicomSeries(const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
414 const std::string& seriesInstanceUid) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
415 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
416 std::set<Orthanc::DicomTag> tags; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
417 |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
418 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
419 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
420 if (scheduledStudies_.find(studyInstanceUid) == scheduledStudies_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
421 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
422 scheduledStudies_.insert(studyInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
423 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
424 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
425 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
426 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
427 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
428 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
429 resourcesLoader_->ScheduleQido(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
430 Orthanc::ResourceType_Study, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
432 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
433 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
434 if (scheduledSeries_.find(seriesInstanceUid) == scheduledSeries_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 scheduledSeries_.insert(seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 filter.SetValue(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, seriesInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 resourcesLoader_->ScheduleQido(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
445 Orthanc::ResourceType_Series, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
446 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
449 std::unique_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 command->SetMethod(Orthanc::HttpMethod_Post); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 command->SetUri("/tools/find"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 body["Level"] = "Series"; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 body["Query"] = Json::objectValue; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 body["Query"]["StudyInstanceUID"] = studyInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
457 body["Query"]["SeriesInstanceUID"] = seriesInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 command->SetBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
462 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
466 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
467 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
468 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
469 void AddOrthancStudy(const std::string& orthancId) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
473 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 resourcesLoader_->ScheduleLoadOrthancResources( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 Orthanc::ResourceType_Study, orthancId, Orthanc::ResourceType_Series, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 CreatePayload(Type_Orthanc)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
480 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
481 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
482 "Only applicable to Orthanc DICOM sources"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
483 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
484 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
485 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
486 void AddOrthancSeries(const std::string& orthancId) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1474
diff
changeset
|
490 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 resourcesLoader_->ScheduleLoadOrthancResource( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 loadedSeries_, PRIORITY_ADD_RESOURCES, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 source_, Orthanc::ResourceType_Series, orthancId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 CreatePayload(Type_Orthanc)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
495 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
496 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
498 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
499 "Only applicable to Orthanc DICOM sources"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
500 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
501 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
502 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
503 } |