Mercurial > hg > orthanc-stone
annotate Framework/Layers/SingleFrameRendererFactory.cpp @ 585:b9ce24c606ae
TextSceneLayer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Apr 2019 17:57:58 +0200 |
parents | b70e9be013e4 |
children | 4f2416d519b4 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 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 | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "SingleFrameRendererFactory.h" | |
23 | |
24 #include "FrameRenderer.h" | |
35 | 25 #include "../Toolbox/MessagingToolbox.h" |
0 | 26 #include "../Toolbox/DicomFrameConverter.h" |
27 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
28 #include <OrthancException.h> |
113
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
29 #include <Plugins/Samples/Common/FullOrthancDataset.h> |
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
30 #include <Plugins/Samples/Common/DicomDatasetReader.h> |
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
31 |
0 | 32 namespace OrthancStone |
33 { | |
31
9aace933cb64
sharing code with the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
34 SingleFrameRendererFactory::SingleFrameRendererFactory(OrthancPlugins::IOrthancConnection& orthanc, |
0 | 35 const std::string& instanceId, |
36 unsigned int frame) : | |
37 orthanc_(orthanc), | |
38 instance_(instanceId), | |
39 frame_(frame) | |
40 { | |
32 | 41 dicom_.reset(new OrthancPlugins::FullOrthancDataset(orthanc, "/instances/" + instanceId + "/tags")); |
0 | 42 |
32 | 43 DicomFrameConverter converter; |
44 converter.ReadParameters(*dicom_); | |
45 format_ = converter.GetExpectedPixelFormat(); | |
0 | 46 } |
47 | |
48 | |
49 bool SingleFrameRendererFactory::GetExtent(double& x1, | |
50 double& y1, | |
51 double& x2, | |
52 double& y2, | |
53 const SliceGeometry& viewportSlice) | |
54 { | |
55 // Assume that PixelSpacingX == PixelSpacingY == 1 | |
56 | |
32 | 57 OrthancPlugins::DicomDatasetReader reader(*dicom_); |
58 | |
59 unsigned int width, height; | |
60 | |
61 if (!reader.GetUnsignedIntegerValue(width, OrthancPlugins::DICOM_TAG_COLUMNS) || | |
62 !reader.GetUnsignedIntegerValue(height, OrthancPlugins::DICOM_TAG_ROWS)) | |
63 { | |
64 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
65 } | |
0 | 66 |
67 x1 = 0; | |
68 y1 = 0; | |
69 x2 = static_cast<double>(width); | |
70 y2 = static_cast<double>(height); | |
71 | |
72 return true; | |
73 } | |
74 | |
75 | |
76 ILayerRenderer* SingleFrameRendererFactory::CreateLayerRenderer(const SliceGeometry& viewportSlice) | |
77 { | |
32 | 78 SliceGeometry frameSlice(*dicom_); |
0 | 79 return FrameRenderer::CreateRenderer(MessagingToolbox::DecodeFrame(orthanc_, instance_, frame_, format_), |
77 | 80 frameSlice, *dicom_, 1, 1, true); |
0 | 81 } |
82 | |
83 | |
84 ISliceableVolume& SingleFrameRendererFactory::GetSourceVolume() const | |
85 { | |
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
87 } | |
88 } |