comparison Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h @ 1821:36430d73e36c

introducing measure units in AnnotationsSceneLayer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 26 May 2021 14:02:12 +0200
parents 462d7a0e064e
children 0489fe25ce48
comparison
equal deleted inserted replaced
1820:5baaad557d58 1821:36430d73e36c
99 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); 99 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
100 lock->GetCompositor().FitContent(lock->GetController().GetScene()); 100 lock->GetCompositor().FitContent(lock->GetController().GetScene());
101 lock->Invalidate(); 101 lock->Invalidate();
102 } 102 }
103 103
104 OrthancStone::Units GetUnits() const
105 {
106 return units_;
107 }
108
104 private: 109 private:
105 ILoadersContext& context_; 110 ILoadersContext& context_;
106 boost::shared_ptr<IViewport> viewport_; 111 boost::shared_ptr<IViewport> viewport_;
107 boost::shared_ptr<DicomResourcesLoader> dicomLoader_; 112 boost::shared_ptr<DicomResourcesLoader> dicomLoader_;
108 boost::shared_ptr<SeriesFramesLoader> framesLoader_; 113 boost::shared_ptr<SeriesFramesLoader> framesLoader_;
114 OrthancStone::Units units_;
109 115
110 SdlSimpleViewerApplication(ILoadersContext& context, 116 SdlSimpleViewerApplication(ILoadersContext& context,
111 boost::shared_ptr<IViewport> viewport) : 117 boost::shared_ptr<IViewport> viewport) :
112 context_(context), 118 context_(context),
113 viewport_(viewport) 119 viewport_(viewport),
120 units_(OrthancStone::Units_Pixels)
114 { 121 {
115 } 122 }
116 123
117 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message) 124 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message)
118 { 125 {
139 if (message.GetResources()->GetSize() != 1) 146 if (message.GetResources()->GetSize() != 1)
140 { 147 {
141 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 148 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
142 } 149 }
143 150
151 OrthancStone::DicomInstanceParameters parameters(message.GetResources()->GetResource(0));
152 if (parameters.HasPixelSpacing())
153 {
154 /**
155 * TODO - Ultrasound (US) images store an equivalent to
156 * "PixelSpacing" in the "SequenceOfUltrasoundRegions"
157 * (0018,6011) sequence, cf. tags "PhysicalDeltaX" (0018,602c)
158 * and "PhysicalDeltaY" (0018,602e) => This would require
159 * storing the full JSON into the "LoadedDicomResources" class
160 * or to use DCMTK
161 **/
162
163 LOG(INFO) << "Using millimeters units, as the DICOM instance contains the PixelSpacing tag";
164 units_ = OrthancStone::Units_Millimeters;
165 }
166 else
167 {
168 LOG(INFO) << "Using pixels units, as the DICOM instance does *not* contain the PixelSpacing tag";
169 }
170
144 //message.GetResources()->GetResource(0).Print(stdout); 171 //message.GetResources()->GetResource(0).Print(stdout);
145 172
146 { 173 {
147 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); 174 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock());
148 SeriesFramesLoader::Factory f(*message.GetResources()); 175 SeriesFramesLoader::Factory f(*message.GetResources());