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