Mercurial > hg > orthanc-stone
annotate Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h @ 1891:3716d72161d2
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Jan 2022 12:32:15 +0100 |
parents | 7053b8a0aaec |
children | 898774b4e02d |
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 | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1457 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1560
diff
changeset
|
17 * |
1457 | 18 * You should have received a copy of the GNU Affero General Public License |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 #pragma once |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
1542 | 25 #include "../../../../OrthancStone/Sources/Loaders/DicomResourcesLoader.h" |
26 #include "../../../../OrthancStone/Sources/Loaders/ILoadersContext.h" | |
27 #include "../../../../OrthancStone/Sources/Loaders/SeriesFramesLoader.h" | |
28 #include "../../../../OrthancStone/Sources/Loaders/SeriesThumbnailsLoader.h" | |
1560
b4ccd4963d37
fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
29 #include "../../../../OrthancStone/Sources/Scene2DViewport/ViewportController.h" |
b4ccd4963d37
fix sdl and wasm samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1542
diff
changeset
|
30 #include "../../../../OrthancStone/Sources/Viewport/IViewport.h" |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
32 #include <Compatibility.h> // For std::unique_ptr<> |
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
33 |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 #include <boost/make_shared.hpp> |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 using OrthancStone::ILoadersContext; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 using OrthancStone::ObserverBase; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 using OrthancStone::IViewport; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 using OrthancStone::DicomResourcesLoader; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 using OrthancStone::SeriesFramesLoader; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 using OrthancStone::TextureBaseSceneLayer; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 using OrthancStone::DicomSource; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 using OrthancStone::SeriesThumbnailsLoader; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 using OrthancStone::LoadedDicomResources; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 using OrthancStone::SeriesThumbnailType; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 using OrthancStone::OracleScheduler; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 using OrthancStone::OrthancRestApiCommand; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 using OrthancStone::OracleScheduler; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 using OrthancStone::OracleScheduler; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 using OrthancStone::OracleScheduler; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 class SdlSimpleViewerApplication : public ObserverBase<SdlSimpleViewerApplication> |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 public: |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 static boost::shared_ptr<SdlSimpleViewerApplication> Create(ILoadersContext& context, boost::shared_ptr<IViewport> viewport) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 boost::shared_ptr<SdlSimpleViewerApplication> application(new SdlSimpleViewerApplication(context, viewport)); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
63 std::unique_ptr<ILoadersContext::ILock> lock(context.Lock()); |
1472
474360793956
DicomResourcesLoader::Create()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
64 application->dicomLoader_ = DicomResourcesLoader::Create(*lock); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 application->Register<DicomResourcesLoader::SuccessMessage>(*application->dicomLoader_, &SdlSimpleViewerApplication::Handle); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 return application; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 void LoadOrthancFrame(const DicomSource& source, const std::string& instanceId, unsigned int frame) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
74 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 dicomLoader_->ScheduleLoadOrthancResource(boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 0, source, Orthanc::ResourceType_Instance, instanceId, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 new Orthanc::SingleValueObject<unsigned int>(frame)); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 #if 0 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 void LoadDicomWebFrame(const DicomSource& source, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 const std::string& studyInstanceUid, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 const std::string& seriesInstanceUid, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 const std::string& sopInstanceUid, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 unsigned int frame) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
88 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 // We first must load the "/metadata" to know the number of frames |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 dicomLoader_->ScheduleGetDicomWeb( |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 boost::make_shared<LoadedDicomResources>(Orthanc::DICOM_TAG_SOP_INSTANCE_UID), 0, source, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 "/studies/" + studyInstanceUid + "/series/" + seriesInstanceUid + "/instances/" + sopInstanceUid + "/metadata", |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 new Orthanc::SingleValueObject<unsigned int>(frame)); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 #endif |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 void FitContent() |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
100 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 lock->Invalidate(); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
105 OrthancStone::Units GetUnits() const |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
106 { |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
107 return units_; |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
108 } |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
109 |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 private: |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 ILoadersContext& context_; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
112 boost::shared_ptr<IViewport> viewport_; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 boost::shared_ptr<DicomResourcesLoader> dicomLoader_; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 boost::shared_ptr<SeriesFramesLoader> framesLoader_; |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
115 OrthancStone::Units units_; |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 SdlSimpleViewerApplication(ILoadersContext& context, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 boost::shared_ptr<IViewport> viewport) : |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 context_(context), |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
120 viewport_(viewport), |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
121 units_(OrthancStone::Units_Pixels) |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 void Handle(const SeriesFramesLoader::FrameLoadedMessage& message) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 LOG(INFO) << "Frame decoded! " |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 << message.GetImage().GetWidth() << "x" << message.GetImage().GetHeight() |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 << " " << Orthanc::EnumerationToString(message.GetImage().GetFormat()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
131 std::unique_ptr<TextureBaseSceneLayer> layer( |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 message.GetInstanceParameters().CreateTexture(message.GetImage())); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 layer->SetLinearInterpolation(true); |
1789
462d7a0e064e
added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
134 layer->SetPixelSpacing(message.GetInstanceParameters().GetPixelSpacingX(), |
462d7a0e064e
added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
135 message.GetInstanceParameters().GetPixelSpacingY()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
138 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 lock->GetController().GetScene().SetLayer(0, layer.release()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 lock->Invalidate(); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 void Handle(const DicomResourcesLoader::SuccessMessage& message) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 if (message.GetResources()->GetSize() != 1) |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 { |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
152 OrthancStone::DicomInstanceParameters parameters(message.GetResources()->GetResource(0)); |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
153 if (parameters.HasPixelSpacing()) |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
154 { |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
155 /** |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
156 * TODO - Ultrasound (US) images store an equivalent to |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
157 * "PixelSpacing" in the "SequenceOfUltrasoundRegions" |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
158 * (0018,6011) sequence, cf. tags "PhysicalDeltaX" (0018,602c) |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
159 * and "PhysicalDeltaY" (0018,602e) => This would require |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1821
diff
changeset
|
160 * parsing "message.GetResources()->GetSourceJson(0)" |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1821
diff
changeset
|
161 * => cf. "DicomInstanceParameters::EnrichUsingDicomWeb()" |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
162 **/ |
1822
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1821
diff
changeset
|
163 |
0489fe25ce48
support of pixel spacing in ultrasound images from tag SequenceOfUltrasoundRegions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1821
diff
changeset
|
164 // std::cout << message.GetResources()->GetSourceJson(0).toStyledString(); |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
165 |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
166 LOG(INFO) << "Using millimeters units, as the DICOM instance contains the PixelSpacing tag"; |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
167 units_ = OrthancStone::Units_Millimeters; |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
168 } |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
169 else |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
170 { |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
171 LOG(INFO) << "Using pixels units, as the DICOM instance does *not* contain the PixelSpacing tag"; |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
172 } |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1789
diff
changeset
|
173 |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
174 //message.GetResources()->GetResource(0).Print(stdout); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
175 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
176 { |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1472
diff
changeset
|
177 std::unique_ptr<ILoadersContext::ILock> lock(context_.Lock()); |
1358
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
178 SeriesFramesLoader::Factory f(*message.GetResources()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
179 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
180 framesLoader_ = boost::dynamic_pointer_cast<SeriesFramesLoader>( |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
181 f.Create(*lock)); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
182 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
183 Register<SeriesFramesLoader::FrameLoadedMessage>( |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
184 *framesLoader_, &SdlSimpleViewerApplication::Handle); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
185 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
186 assert(message.HasUserPayload()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
187 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 const Orthanc::SingleValueObject<unsigned int>& payload = |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
189 dynamic_cast<const Orthanc::SingleValueObject<unsigned int>&>( |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
190 message.GetUserPayload()); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 LOG(INFO) << "Loading pixel data of frame: " << payload.GetValue(); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
193 framesLoader_->ScheduleLoadFrame( |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 0, message.GetDicomSource(), payload.GetValue(), |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
195 message.GetDicomSource().GetQualityCount() - 1 /* download best quality available */, |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 NULL); |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
197 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
198 } |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
199 |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
200 }; |
4287eaabe490
Sdl simple viewer application
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
201 |