Mercurial > hg > orthanc-stone
annotate Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h @ 1457:15173a383a00
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Jun 2020 21:12:02 +0200 |
parents | c0e4eb14c912 |
children | 474360793956 |
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 | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #pragma once |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
1457 | 24 #include "../../../Framework/Loaders/DicomResourcesLoader.h" |
25 #include "../../../Framework/Loaders/ILoadersContext.h" | |
26 #include "../../../Framework/Loaders/SeriesFramesLoader.h" | |
27 #include "../../../Framework/Loaders/SeriesThumbnailsLoader.h" | |
28 #include "../../../Framework/Viewport/IViewport.h" | |
1354
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 #include <boost/make_shared.hpp> |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 namespace OrthancStone |
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 class Application : public ObserverBase<Application> |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 private: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 ILoadersContext& context_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 boost::shared_ptr<IViewport> viewport_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 boost::shared_ptr<DicomResourcesLoader> dicomLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 boost::shared_ptr<SeriesFramesLoader> framesLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 Application(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 boost::shared_ptr<IViewport> viewport) : |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 context_(context), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 viewport_(viewport) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message) |
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 LOG(INFO) << "Frame decoded! " |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 << message.GetImage().GetWidth() << "x" << message.GetImage().GetHeight() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 << " " << Orthanc::EnumerationToString(message.GetImage().GetFormat()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 std::auto_ptr<TextureBaseSceneLayer> layer( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 message.GetInstanceParameters().CreateTexture(message.GetImage())); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 layer->SetLinearInterpolation(true); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 std::auto_ptr<IViewport::ILock> lock(viewport_->Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 lock->GetController().GetScene().SetLayer(0, layer.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 lock->Invalidate(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 void Handle(const DicomResourcesLoader::SuccessMessage& message) |
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 if (message.GetResources()->GetSize() != 1) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 } |
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 //message.GetResources()->GetResource(0).Print(stdout); |
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 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 SeriesFramesLoader::Factory f(*message.GetResources()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>(f.Create(*lock)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 Register<SeriesFramesLoader::FrameLoadedMessage>(*framesLoader_, &Application::Handle); |
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 assert(message.HasUserPayload()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 const Orthanc::SingleValueObject<unsigned int>& payload = |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>(message.GetUserPayload()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 LOG(INFO) << "Loading pixel data of frame: " << payload.GetValue(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 framesLoader_->ScheduleLoadFrame( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 0, message.GetDicomSource(), payload.GetValue(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 message.GetDicomSource().GetQualityCount() - 1 /* download best quality available */, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 NULL); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 static boost::shared_ptr<Application> Create(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 boost::shared_ptr<IViewport> viewport) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 boost::shared_ptr<Application> application(new Application(context, viewport)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 |
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 std::auto_ptr<ILoadersContext::ILock> lock(context.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 DicomResourcesLoader::Factory f; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 application->dicomLoader_ = boost::dynamic_pointer_cast<DicomResourcesLoader>(f.Create(*lock)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 application->Register<DicomResourcesLoader::SuccessMessage>(*application->dicomLoader_, &Application::Handle); |
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 return application; |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 void LoadOrthancFrame(const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 const std::string& instanceId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 unsigned int frame) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 dicomLoader_->ScheduleLoadOrthancResource( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 0, source, Orthanc::ResourceType_Instance, instanceId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 new Orthanc::SingleValueObject<unsigned int>(frame)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 void LoadDicomWebFrame(const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 const std::string& seriesInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 const std::string& sopInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 unsigned int frame) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 // 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
|
134 dicomLoader_->ScheduleGetDicomWeb( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 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
|
136 "/studies/" + studyInstanceUid + "/series/" + seriesInstanceUid + "/instances/" + sopInstanceUid + "/metadata", |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 new Orthanc::SingleValueObject<unsigned int>(frame)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 void FitContent() |
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 std::auto_ptr<IViewport::ILock> lock(viewport_->Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 lock->Invalidate(); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 }; |
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 class IWebViewerLoadersObserver : public boost::noncopyable |
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 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
153 virtual ~IWebViewerLoadersObserver() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 } |
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 virtual void SignalSeriesUpdated(LoadedDicomResources& series) = 0; |
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 SignalThumbnailLoaded(const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
160 const std::string& seriesInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
161 SeriesThumbnailType type) = 0; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
163 |
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 class WebViewerLoaders : public ObserverBase<WebViewerLoaders> |
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 private: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
168 static const int PRIORITY_ADD_RESOURCES = 0; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
169 static const int PRIORITY_THUMBNAILS = OracleScheduler::PRIORITY_LOW + 100; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
170 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
171 enum Type |
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 Type_Orthanc = 1, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 Type_DicomWeb = 2 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
177 ILoadersContext& context_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 std::auto_ptr<IWebViewerLoadersObserver> observer_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 bool loadThumbnails_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 DicomSource source_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 std::set<std::string> scheduledSeries_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 std::set<std::string> scheduledThumbnails_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 std::set<std::string> scheduledStudies_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 boost::shared_ptr<LoadedDicomResources> loadedSeries_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 boost::shared_ptr<LoadedDicomResources> loadedStudies_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 boost::shared_ptr<DicomResourcesLoader> resourcesLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 boost::shared_ptr<SeriesThumbnailsLoader> thumbnailsLoader_; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 WebViewerLoaders(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 IWebViewerLoadersObserver* observer) : |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 context_(context), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 observer_(observer), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 loadThumbnails_(false) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 loadedSeries_ = boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 loadedStudies_ = boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 } |
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 static Orthanc::IDynamicObject* CreatePayload(Type type) |
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 return new Orthanc::SingleValueObject<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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
204 void HandleThumbnail(const SeriesThumbnailsLoader::ThumbnailLoadedMessage& message) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 if (observer_.get() != NULL) |
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 observer_->SignalThumbnailLoaded(message.GetStudyInstanceUid(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 message.GetSeriesInstanceUid(), |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 message.GetType()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 } |
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 void HandleLoadedResources(const DicomResourcesLoader::SuccessMessage& message) |
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 LoadedDicomResources series(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID); |
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 switch (dynamic_cast<const Orthanc::SingleValueObject<Type>&>(message.GetUserPayload()).GetValue()) |
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 case Type_DicomWeb: |
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 for (size_t i = 0; i < loadedSeries_->GetSize(); i++) |
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 std::string study; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 if (loadedSeries_->GetResource(i).LookupStringValue( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 study, Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, false) && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 loadedStudies_->HasResource(study)) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 Orthanc::DicomMap m; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 m.Assign(loadedSeries_->GetResource(i)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 loadedStudies_->MergeResource(m, study); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 series.AddResource(m); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 } |
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 break; |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 case Type_Orthanc: |
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 for (size_t i = 0; i < message.GetResources()->GetSize(); i++) |
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 series.AddResource(message.GetResources()->GetResource(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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
246 break; |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 default: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
251 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 if (loadThumbnails_ && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
254 (!source_.IsDicomWeb() || |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
255 source_.HasDicomWebRendered())) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 for (size_t i = 0; i < series.GetSize(); i++) |
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 std::string patientId, studyInstanceUid, seriesInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 scheduledThumbnails_.find(seriesInstanceUid) == scheduledThumbnails_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
265 scheduledThumbnails_.insert(seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
266 thumbnailsLoader_->ScheduleLoadThumbnail(source_, patientId, studyInstanceUid, seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
268 } |
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 if (observer_.get() != NULL && |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
272 series.GetSize() > 0) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
274 observer_->SignalSeriesUpdated(series); |
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 } |
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 void HandleOrthancRestApi(const OrthancRestApiCommand::SuccessMessage& message) |
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 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
281 message.ParseJsonBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
283 if (body.type() != Json::arrayValue) |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
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 else |
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 for (Json::Value::ArrayIndex i = 0; i < body.size(); i++) |
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 if (body[i].type() == Json::stringValue) |
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 AddOrthancSeries(body[i].asString()); |
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 else |
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 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); |
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 } |
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 public: |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 static boost::shared_ptr<WebViewerLoaders> Create(ILoadersContext& context, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 const DicomSource& source, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
306 bool loadThumbnails, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
307 IWebViewerLoadersObserver* observer) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 boost::shared_ptr<WebViewerLoaders> application(new WebViewerLoaders(context, observer)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 application->source_ = source; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 application->loadThumbnails_ = loadThumbnails; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
312 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 std::auto_ptr<ILoadersContext::ILock> lock(context.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 DicomResourcesLoader::Factory f; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 application->resourcesLoader_ = boost::dynamic_pointer_cast<DicomResourcesLoader>(f.Create(*lock)); |
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 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
322 SeriesThumbnailsLoader::Factory f; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
323 f.SetPriority(PRIORITY_THUMBNAILS); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 application->thumbnailsLoader_ = boost::dynamic_pointer_cast<SeriesThumbnailsLoader>(f.Create(*lock)); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 application->Register<OrthancRestApiCommand::SuccessMessage>( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
328 lock->GetOracleObservable(), &WebViewerLoaders::HandleOrthancRestApi); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
330 application->Register<DicomResourcesLoader::SuccessMessage>( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 *application->resourcesLoader_, &WebViewerLoaders::HandleLoadedResources); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 application->Register<SeriesThumbnailsLoader::ThumbnailLoadedMessage>( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 *application->thumbnailsLoader_, &WebViewerLoaders::HandleThumbnail); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 lock->AddLoader(application); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 return application; |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 void AddDicomAllSeries() |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
343 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
345 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
347 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
348 resourcesLoader_->ScheduleGetDicomWeb(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
349 "/series", CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
350 resourcesLoader_->ScheduleGetDicomWeb(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
351 "/studies", CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
352 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
353 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
354 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
355 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
356 command->SetMethod(Orthanc::HttpMethod_Get); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
357 command->SetUri("/series"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
358 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
359 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
360 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
361 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
362 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
366 void AddDicomStudy(const std::string& studyInstanceUid) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
367 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
368 // Avoid adding twice the same study |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
369 if (scheduledStudies_.find(studyInstanceUid) == scheduledStudies_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
370 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
371 scheduledStudies_.insert(studyInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
372 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
373 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
374 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
375 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
376 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
377 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
378 std::set<Orthanc::DicomTag> tags; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
379 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
380 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
381 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
382 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
383 resourcesLoader_->ScheduleQido(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
384 Orthanc::ResourceType_Study, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
385 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
386 resourcesLoader_->ScheduleQido(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
387 Orthanc::ResourceType_Series, filter, tags, CreatePayload(Type_DicomWeb)); |
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 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
390 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
391 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
392 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
393 command->SetMethod(Orthanc::HttpMethod_Post); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
394 command->SetUri("/tools/find"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
395 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
396 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
397 body["Level"] = "Series"; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
398 body["Query"] = Json::objectValue; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
399 body["Query"]["StudyInstanceUID"] = studyInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
400 command->SetBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
401 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
402 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
403 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
404 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
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 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
407 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
408 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
409 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
414 void AddDicomSeries(const std::string& studyInstanceUid, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
415 const std::string& seriesInstanceUid) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
416 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
417 std::set<Orthanc::DicomTag> tags; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
418 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
419 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
420 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
421 if (scheduledStudies_.find(studyInstanceUid) == scheduledStudies_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
422 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
423 scheduledStudies_.insert(studyInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
424 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
425 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
426 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
427 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
428 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
429 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
430 resourcesLoader_->ScheduleQido(loadedStudies_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
431 Orthanc::ResourceType_Study, filter, tags, CreatePayload(Type_DicomWeb)); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
435 if (scheduledSeries_.find(seriesInstanceUid) == scheduledSeries_.end()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
436 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
437 scheduledSeries_.insert(seriesInstanceUid); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
438 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
439 if (source_.IsDicomWeb()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
440 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
441 Orthanc::DicomMap filter; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
442 filter.SetValue(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
443 filter.SetValue(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID, seriesInstanceUid, false); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
444 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
445 resourcesLoader_->ScheduleQido(loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
446 Orthanc::ResourceType_Series, filter, tags, CreatePayload(Type_DicomWeb)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
447 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
448 else if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
449 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
450 std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
451 command->SetMethod(Orthanc::HttpMethod_Post); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
452 command->SetUri("/tools/find"); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
453 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
454 Json::Value body; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
455 body["Level"] = "Series"; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
456 body["Query"] = Json::objectValue; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
457 body["Query"]["StudyInstanceUID"] = studyInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
458 body["Query"]["SeriesInstanceUID"] = seriesInstanceUid; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
459 command->SetBody(body); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
460 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
461 lock->Schedule(GetSharedObserver(), PRIORITY_ADD_RESOURCES, command.release()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
462 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
463 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
464 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
465 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
470 void AddOrthancStudy(const std::string& orthancId) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
471 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
472 if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
473 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
474 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
475 resourcesLoader_->ScheduleLoadOrthancResources( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
476 loadedSeries_, PRIORITY_ADD_RESOURCES, source_, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
477 Orthanc::ResourceType_Study, orthancId, Orthanc::ResourceType_Series, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
478 CreatePayload(Type_Orthanc)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
479 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
480 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
481 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
482 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
483 "Only applicable to Orthanc DICOM sources"); |
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 |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
487 void AddOrthancSeries(const std::string& orthancId) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
488 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
489 if (source_.IsOrthanc()) |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
490 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
491 std::auto_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
492 resourcesLoader_->ScheduleLoadOrthancResource( |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
493 loadedSeries_, PRIORITY_ADD_RESOURCES, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
494 source_, Orthanc::ResourceType_Series, orthancId, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
495 CreatePayload(Type_Orthanc)); |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
496 } |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
497 else |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
498 { |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
499 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadParameterType, |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
500 "Only applicable to Orthanc DICOM sources"); |
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 }; |
c0e4eb14c912
SingleFrameViewer WASM working OK
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
504 } |