Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Deprecated/Layers/SingleFrameRendererFactory.cpp @ 1556:8898f8f755c8
typo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Aug 2020 11:58:47 +0200 |
parents | 244ad1e4e76a |
children |
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 | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
5 * Copyright (C) 2017-2020 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> |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
29 #include <FullOrthancDataset.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
30 #include <DicomDatasetReader.h> |
113
2eca030792aa
using the Orthanc Framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
31 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
32 namespace Deprecated |
0 | 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 } |