Mercurial > hg > orthanc-stone
comparison Framework/Loaders/SeriesFramesLoader.h @ 1228:c471a0aa137b broker
adding the next generation of loaders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Dec 2019 13:58:37 +0100 |
parents | |
children | b9b5d4378874 |
comparison
equal
deleted
inserted
replaced
1227:a1c0c9c9f9af | 1228:c471a0aa137b |
---|---|
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-2019 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 | |
22 #pragma once | |
23 | |
24 #if !defined(ORTHANC_ENABLE_DCMTK) | |
25 # error The macro ORTHANC_ENABLE_DCMTK must be defined | |
26 #endif | |
27 | |
28 #include "OracleScheduler.h" | |
29 #include "DicomSource.h" | |
30 #include "SeriesOrderedFrames.h" | |
31 #include "ILoaderFactory.h" | |
32 | |
33 namespace OrthancStone | |
34 { | |
35 class SeriesFramesLoader : | |
36 public ObserverBase<SeriesFramesLoader>, | |
37 public IObservable | |
38 { | |
39 private: | |
40 class Payload; | |
41 | |
42 ILoadersContext& context_; | |
43 SeriesOrderedFrames frames_; | |
44 std::string dicomDirPath_; | |
45 boost::shared_ptr<LoadedDicomResources> dicomDir_; | |
46 | |
47 SeriesFramesLoader(ILoadersContext& context, | |
48 LoadedDicomResources& instances, | |
49 const std::string& dicomDirPath, | |
50 boost::shared_ptr<LoadedDicomResources> dicomDir); | |
51 | |
52 void EmitMessage(const Payload& payload, | |
53 const Orthanc::ImageAccessor& image); | |
54 | |
55 #if ORTHANC_ENABLE_DCMTK == 1 | |
56 void HandleDicom(const Payload& payload, | |
57 Orthanc::ParsedDicomFile& dicom); | |
58 #endif | |
59 | |
60 void HandleDicomWebRendered(const Payload& payload, | |
61 const std::string& body, | |
62 const std::map<std::string, std::string>& headers); | |
63 | |
64 #if ORTHANC_ENABLE_DCMTK == 1 | |
65 void Handle(const ParseDicomSuccessMessage& message); | |
66 #endif | |
67 | |
68 void Handle(const GetOrthancImageCommand::SuccessMessage& message); | |
69 | |
70 void Handle(const GetOrthancWebViewerJpegCommand::SuccessMessage& message); | |
71 | |
72 void Handle(const OrthancRestApiCommand::SuccessMessage& message); | |
73 | |
74 void Handle(const HttpCommand::SuccessMessage& message); | |
75 | |
76 void GetPreviewWindowing(float& center, | |
77 float& width, | |
78 size_t index) const; | |
79 | |
80 public: | |
81 class FrameLoadedMessage : public OriginMessage<SeriesFramesLoader> | |
82 { | |
83 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__); | |
84 | |
85 private: | |
86 size_t frameIndex_; | |
87 unsigned int quality_; | |
88 const Orthanc::ImageAccessor& image_; | |
89 const Orthanc::DicomMap& instance_; | |
90 const DicomInstanceParameters& parameters_; | |
91 Orthanc::IDynamicObject* userPayload_; // Ownership is maintained by the caller | |
92 | |
93 public: | |
94 FrameLoadedMessage(const SeriesFramesLoader& loader, | |
95 size_t frameIndex, | |
96 unsigned int quality, | |
97 const Orthanc::ImageAccessor& image, | |
98 const Orthanc::DicomMap& instance, | |
99 const DicomInstanceParameters& parameters, | |
100 Orthanc::IDynamicObject* userPayload) : | |
101 OriginMessage(loader), | |
102 frameIndex_(frameIndex), | |
103 quality_(quality), | |
104 image_(image), | |
105 instance_(instance), | |
106 parameters_(parameters), | |
107 userPayload_(userPayload) | |
108 { | |
109 } | |
110 | |
111 size_t GetFrameIndex() const | |
112 { | |
113 return frameIndex_; | |
114 } | |
115 | |
116 unsigned int GetQuality() const | |
117 { | |
118 return quality_; | |
119 } | |
120 | |
121 const Orthanc::ImageAccessor& GetImage() const | |
122 { | |
123 return image_; | |
124 } | |
125 | |
126 const Orthanc::DicomMap& GetInstance() const | |
127 { | |
128 return instance_; | |
129 } | |
130 | |
131 const DicomInstanceParameters& GetInstanceParameters() const | |
132 { | |
133 return parameters_; | |
134 } | |
135 | |
136 bool HasUserPayload() const | |
137 { | |
138 return userPayload_ != NULL; | |
139 } | |
140 | |
141 Orthanc::IDynamicObject& GetUserPayload() const; | |
142 }; | |
143 | |
144 | |
145 class Factory : public ILoaderFactory | |
146 { | |
147 private: | |
148 LoadedDicomResources& instances_; | |
149 std::string dicomDirPath_; | |
150 boost::shared_ptr<LoadedDicomResources> dicomDir_; | |
151 | |
152 public: | |
153 // No "const" because "LoadedDicomResources::GetResource()" will call "Flatten()" | |
154 Factory(LoadedDicomResources& instances) : | |
155 instances_(instances) | |
156 { | |
157 } | |
158 | |
159 void SetDicomDir(const std::string& dicomDirPath, | |
160 boost::shared_ptr<LoadedDicomResources> dicomDir); | |
161 | |
162 virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& context); | |
163 }; | |
164 | |
165 const SeriesOrderedFrames& GetOrderedFrames() const | |
166 { | |
167 return frames_; | |
168 } | |
169 | |
170 void ScheduleLoadFrame(int priority, | |
171 const DicomSource& source, | |
172 size_t index, | |
173 unsigned int quality, | |
174 Orthanc::IDynamicObject* userPayload /* transfer ownership */); | |
175 }; | |
176 } |