Mercurial > hg > orthanc-stone
annotate Framework/Radiography/RadiographySceneReader.cpp @ 1313:f30905f5d246 broker
Added support for OnGenericSdlEvent to GuiAdapter.
This makes it possible to piggyback app-specific logic
to special events (here, to support the Viewport refresh
events)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Mar 2020 11:12:39 +0100 |
parents | 257f2c9a02ac |
children |
rev | line source |
---|---|
430 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1280
1c7ae79c426d
fix copyright years
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1259
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
430 | 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 #include "RadiographySceneReader.h" | |
23 | |
732
c35e98d22764
move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
714
diff
changeset
|
24 #include "../Deprecated/Toolbox/DicomFrameConverter.h" |
650
200f7e1d57d1
Moved RadiographyDicomLayer::SetDicomFrameConverter to cpp file to prevent
Benjamin Golinvaux <bgo@osimis.io>
parents:
553
diff
changeset
|
25 |
430 | 26 #include <Core/Images/FontRegistry.h> |
27 #include <Core/Images/PngReader.h> | |
28 #include <Core/OrthancException.h> | |
29 #include <Core/Toolbox.h> | |
30 | |
31 namespace OrthancStone | |
32 { | |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
33 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
34 void RadiographySceneBuilder::Read(const Json::Value& input, Orthanc::ImageAccessor* dicomImage /* takes ownership */, |
714
d2c0e347ddc2
deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
658
diff
changeset
|
35 Deprecated::DicomFrameConverter* dicomFrameConverter /* takes ownership */, |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
36 RadiographyPhotometricDisplayMode preferredPhotometricDisplayMode |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
37 ) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
38 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
39 dicomImage_.reset(dicomImage); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
40 dicomFrameConverter_.reset(dicomFrameConverter); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
41 preferredPhotometricDisplayMode_ = preferredPhotometricDisplayMode; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
42 Read(input); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
43 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
44 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
45 RadiographyDicomLayer* RadiographySceneBuilder::LoadDicom(const std::string& instanceId, unsigned int frame, RadiographyLayer::Geometry* geometry) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
46 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
47 return dynamic_cast<RadiographyDicomLayer*>(&(scene_.LoadDicomImage(dicomImage_.release(), instanceId, frame, dicomFrameConverter_.release(), preferredPhotometricDisplayMode_, geometry))); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
48 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
49 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
50 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
51 RadiographyDicomLayer* RadiographySceneReader::LoadDicom(const std::string& instanceId, unsigned int frame, RadiographyLayer::Geometry* geometry) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
52 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
53 return dynamic_cast<RadiographyDicomLayer*>(&(scene_.LoadDicomFrame(orthancApiClient_, instanceId, frame, false, geometry))); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
54 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
55 |
1259
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
56 RadiographyDicomLayer* RadiographySceneGeometryReader::LoadDicom(const std::string& instanceId, unsigned int frame, RadiographyLayer::Geometry* geometry) |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
57 { |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1281
diff
changeset
|
58 std::unique_ptr<RadiographyPlaceholderLayer> layer(new RadiographyPlaceholderLayer(scene_)); |
1259
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
59 layer->SetGeometry(*geometry); |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
60 layer->SetSize(dicomImageWidth_, dicomImageHeight_); |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
61 scene_.RegisterLayer(layer.get()); |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
62 |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
63 return layer.release(); |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
64 } |
69177b10e2b9
various fixes for RadiographyScene: support text layers outside the dicom layer, fix background in this case + extract dicom from rendered scene
Alain Mazy <alain@mazy.be>
parents:
1220
diff
changeset
|
65 |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
66 void RadiographySceneBuilder::Read(const Json::Value& input) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
67 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
68 unsigned int version = input["version"].asUInt(); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
69 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
70 if (version != 1) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
71 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
72 |
772 | 73 if (input.isMember("hasWindowing") && input["hasWindowing"].asBool()) |
74 { | |
75 scene_.SetWindowing(input["windowCenter"].asFloat(), input["windowWidth"].asFloat()); | |
76 } | |
77 | |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
78 RadiographyDicomLayer* dicomLayer = NULL; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
79 for(size_t layerIndex = 0; layerIndex < input["layers"].size(); layerIndex++) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
80 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
81 const Json::Value& jsonLayer = input["layers"][(int)layerIndex]; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
82 RadiographyLayer::Geometry geometry; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
83 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
84 if (jsonLayer["type"].asString() == "dicom") |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
85 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
86 ReadLayerGeometry(geometry, jsonLayer); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
87 dicomLayer = LoadDicom(jsonLayer["instanceId"].asString(), jsonLayer["frame"].asUInt(), &geometry); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
88 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
89 else if (jsonLayer["type"].asString() == "mask") |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
90 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
91 if (dicomLayer == NULL) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
92 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
93 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); // we always assumed the dicom layer was read before the mask |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
94 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
95 ReadLayerGeometry(geometry, jsonLayer); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
96 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
97 float foreground = jsonLayer["foreground"].asFloat(); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
98 std::vector<Orthanc::ImageProcessing::ImagePoint> corners; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
99 for (size_t i = 0; i < jsonLayer["corners"].size(); i++) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
100 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
101 Orthanc::ImageProcessing::ImagePoint corner(jsonLayer["corners"][(int)i]["x"].asInt(), |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
102 jsonLayer["corners"][(int)i]["y"].asInt()); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
103 corners.push_back(corner); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
104 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
105 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
106 scene_.LoadMask(corners, *dicomLayer, foreground, &geometry); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
107 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
108 else if (jsonLayer["type"].asString() == "text") |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
109 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
110 ReadLayerGeometry(geometry, jsonLayer); |
1220
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1190
diff
changeset
|
111 scene_.LoadText(jsonLayer["text"].asString(), jsonLayer["font"].asString(), jsonLayer["fontSize"].asUInt(), static_cast<uint8_t>(jsonLayer["foreground"].asUInt()), &geometry, false); |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
112 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
113 else if (jsonLayer["type"].asString() == "alpha") |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
114 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
115 ReadLayerGeometry(geometry, jsonLayer); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
116 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
117 const std::string& pngContentBase64 = jsonLayer["content"].asString(); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
118 std::string pngContent; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
119 std::string mimeType; |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
120 Orthanc::Toolbox::DecodeDataUriScheme(mimeType, pngContent, pngContentBase64); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
121 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1280
diff
changeset
|
122 std::unique_ptr<Orthanc::ImageAccessor> image; |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
123 if (mimeType == "image/png") |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
124 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
125 image.reset(new Orthanc::PngReader()); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
126 dynamic_cast<Orthanc::PngReader*>(image.get())->ReadFromMemory(pngContent); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
127 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
128 else |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
129 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
130 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
131 RadiographyAlphaLayer& layer = dynamic_cast<RadiographyAlphaLayer&>(scene_.LoadAlphaBitmap(image.release(), &geometry)); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
132 |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
133 if (!jsonLayer["isUsingWindowing"].asBool()) |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
134 { |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
135 layer.SetForegroundValue((float)(jsonLayer["foreground"].asDouble())); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
136 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
137 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
138 else |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
139 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
140 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
141 } |
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
142 |
481
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
437
diff
changeset
|
143 |
159a465e27bd
reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents:
437
diff
changeset
|
144 |
430 | 145 |
1022 | 146 void RadiographySceneBuilder::ReadDicomLayerGeometry(RadiographyLayer::Geometry& geometry, const Json::Value& input) |
147 { | |
148 for(size_t layerIndex = 0; layerIndex < input["layers"].size(); layerIndex++) | |
149 { | |
150 const Json::Value& jsonLayer = input["layers"][(int)layerIndex]; | |
151 if (jsonLayer["type"].asString() == "dicom") | |
152 { | |
153 ReadLayerGeometry(geometry, jsonLayer); | |
154 return; | |
155 } | |
156 } | |
157 } | |
158 | |
553
92305ee35b1c
web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents:
488
diff
changeset
|
159 void RadiographySceneBuilder::ReadLayerGeometry(RadiographyLayer::Geometry& geometry, const Json::Value& jsonLayer) |
430 | 160 { |
161 {// crop | |
162 unsigned int x, y, width, height; | |
163 if (jsonLayer["crop"]["hasCrop"].asBool()) | |
164 { | |
165 x = jsonLayer["crop"]["x"].asUInt(); | |
166 y = jsonLayer["crop"]["y"].asUInt(); | |
167 width = jsonLayer["crop"]["width"].asUInt(); | |
168 height = jsonLayer["crop"]["height"].asUInt(); | |
169 geometry.SetCrop(x, y, width, height); | |
170 } | |
171 } | |
172 | |
173 geometry.SetAngle(jsonLayer["angle"].asDouble()); | |
174 geometry.SetResizeable(jsonLayer["isResizable"].asBool()); | |
175 geometry.SetPan(jsonLayer["pan"]["x"].asDouble(), jsonLayer["pan"]["y"].asDouble()); | |
176 geometry.SetPixelSpacing(jsonLayer["pixelSpacing"]["x"].asDouble(), jsonLayer["pixelSpacing"]["y"].asDouble()); | |
620 | 177 |
178 // these fields were introduced later -> they might not exist | |
629 | 179 if (jsonLayer.isMember("flipVertical")) |
620 | 180 { |
629 | 181 geometry.SetFlipVertical(jsonLayer["flipVertical"].asBool()); |
620 | 182 } |
629 | 183 if (jsonLayer.isMember("flipHorizontal")) |
620 | 184 { |
629 | 185 geometry.SetFlipHorizontal(jsonLayer["flipHorizontal"].asBool()); |
620 | 186 } |
187 | |
430 | 188 } |
189 } |