comparison Framework/Loaders/DicomVolumeLoader.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 0ca50d275b9a
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 #include "../Volumes/DicomVolumeImage.h"
25 #include "SeriesFramesLoader.h"
26 #include "SeriesMetadataLoader.h"
27
28 namespace OrthancStone
29 {
30 class DicomVolumeLoader :
31 public ObserverBase<DicomVolumeLoader>,
32 public IObservable
33 {
34 private:
35 boost::shared_ptr<SeriesFramesLoader> framesLoader_;
36 boost::shared_ptr<DicomVolumeImage> volume_;
37 bool isValid_;
38 bool started_;
39 size_t remaining_;
40
41 DicomVolumeLoader(boost::shared_ptr<SeriesFramesLoader>& framesLoader,
42 bool computeRange);
43
44 void Handle(const OrthancStone::SeriesFramesLoader::FrameLoadedMessage& message);
45
46 public:
47 class VolumeReadyMessage : public OriginMessage<DicomVolumeLoader>
48 {
49 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
50
51 public:
52 VolumeReadyMessage(const DicomVolumeLoader& loader) :
53 OriginMessage(loader)
54 {
55 }
56
57 const DicomVolumeImage& GetVolume() const
58 {
59 assert(GetOrigin().GetVolume());
60 return *GetOrigin().GetVolume();
61 }
62 };
63
64
65 class VolumeUpdatedMessage : public OriginMessage<DicomVolumeLoader>
66 {
67 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
68
69 private:
70 unsigned int axial_;
71
72 public:
73 VolumeUpdatedMessage(const DicomVolumeLoader& loader,
74 unsigned int axial) :
75 OriginMessage(loader),
76 axial_(axial)
77 {
78 }
79
80 unsigned int GetAxialIndex() const
81 {
82 return axial_;
83 }
84
85 const DicomVolumeImage& GetVolume() const
86 {
87 assert(GetOrigin().GetVolume());
88 return *GetOrigin().GetVolume();
89 }
90 };
91
92
93 class Factory : public ILoaderFactory
94 {
95 private:
96 SeriesFramesLoader::Factory framesFactory_;
97 bool computeRange_;
98
99 public:
100 Factory(LoadedDicomResources& instances);
101
102 Factory(const SeriesMetadataLoader::SeriesLoadedMessage& metadata);
103
104 void SetComputeRange(bool computeRange)
105 {
106 computeRange_ = computeRange;
107 }
108
109 void SetDicomDir(const std::string& dicomDirPath,
110 boost::shared_ptr<LoadedDicomResources> dicomDir)
111 {
112 framesFactory_.SetDicomDir(dicomDirPath, dicomDir);
113 }
114
115 virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& context) ORTHANC_OVERRIDE;
116 };
117
118 bool IsValid() const
119 {
120 return isValid_;
121 }
122
123 bool IsFullyLoaded() const
124 {
125 return remaining_ == 0;
126 }
127
128 boost::shared_ptr<DicomVolumeImage> GetVolume() const
129 {
130 return volume_;
131 }
132
133 const SeriesOrderedFrames& GetOrderedFrames() const
134 {
135 return framesLoader_->GetOrderedFrames();
136 }
137
138 void Start(int priority,
139 const DicomSource& source);
140 };
141 }