annotate Framework/Radiography/RadiographySceneReader.h @ 1298:8a0a62189f46

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 16:31:30 +0100
parents 1c7ae79c426d
children 257f2c9a02ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
1 /**
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
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
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
6 *
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
11 *
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
16 *
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
19 **/
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
20
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
21
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
22 #pragma once
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
23
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
24 #include "RadiographyScene.h"
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
25 #include "RadiographyAlphaLayer.h"
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
26 #include "RadiographyDicomLayer.h"
481
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 430
diff changeset
27 #include "RadiographyMaskLayer.h"
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
28 #include "RadiographyTextLayer.h"
732
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
29 #include "../Deprecated/Toolbox/OrthancApiClient.h"
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
30
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
31 #include <json/value.h>
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
32 #include <Core/Images/FontRegistry.h>
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
33
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
34 namespace OrthancStone
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
35 {
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: 1190
diff changeset
36 // a layer containing only the geometry of a DICOM layer (bit hacky !)
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: 1190
diff changeset
37 class RadiographyPlaceholderLayer : public RadiographyDicomLayer
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: 1190
diff changeset
38 {
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: 1190
diff changeset
39 public:
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: 1190
diff changeset
40 RadiographyPlaceholderLayer(MessageBroker& broker, const RadiographyScene& scene) :
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: 1190
diff changeset
41 RadiographyDicomLayer(broker, scene)
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: 1190
diff changeset
42 {
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: 1190
diff changeset
43 }
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: 1190
diff changeset
44
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: 1190
diff changeset
45 };
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: 1190
diff changeset
46
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: 1190
diff changeset
47
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
48 // HACK: I had to introduce this builder class in order to be able to recreate a RadiographyScene
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
49 // from a serialized scene that is passed to web-workers.
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
50 // It needs some architecturing...
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
51 class RadiographySceneBuilder : public boost::noncopyable
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
52 {
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
53 protected:
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
54 RadiographyScene& scene_;
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
55 std::unique_ptr<Orthanc::ImageAccessor> dicomImage_;
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
56 std::unique_ptr<Deprecated::DicomFrameConverter> dicomFrameConverter_;
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
57 RadiographyPhotometricDisplayMode preferredPhotometricDisplayMode_;
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
58
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
59 public:
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
60 RadiographySceneBuilder(RadiographyScene& scene) :
1190
f417a0ae282b wip: TextLayer with new fonts
Alain Mazy <alain@mazy.be>
parents: 1022
diff changeset
61 scene_(scene)
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
62 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
63 }
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
64
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
65 void Read(const Json::Value& input);
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
66 void Read(const Json::Value& input,
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
67 Orthanc::ImageAccessor* dicomImage, // takes ownership
714
d2c0e347ddc2 deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 553
diff changeset
68 Deprecated::DicomFrameConverter* dicomFrameConverter, // takes ownership
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 732
diff changeset
69 RadiographyPhotometricDisplayMode preferredPhotometricDisplayMode
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
70 );
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
71
1022
1e80a925323a ReadDicomLayerGeometry
Alain Mazy <alain@mazy.be>
parents: 739
diff changeset
72 static void ReadLayerGeometry(RadiographyLayer::Geometry& geometry, const Json::Value& input);
1e80a925323a ReadDicomLayerGeometry
Alain Mazy <alain@mazy.be>
parents: 739
diff changeset
73 static void ReadDicomLayerGeometry(RadiographyLayer::Geometry& geometry, const Json::Value& input);
1e80a925323a ReadDicomLayerGeometry
Alain Mazy <alain@mazy.be>
parents: 739
diff changeset
74
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
75 protected:
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
76 virtual RadiographyDicomLayer* LoadDicom(const std::string& instanceId, unsigned int frame, RadiographyLayer::Geometry* geometry);
1022
1e80a925323a ReadDicomLayerGeometry
Alain Mazy <alain@mazy.be>
parents: 739
diff changeset
77
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
78 };
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
79
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
80
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
81 class RadiographySceneReader : public RadiographySceneBuilder
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
82 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
83 Deprecated::OrthancApiClient& orthancApiClient_;
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
84
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
85 public:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 714
diff changeset
86 RadiographySceneReader(RadiographyScene& scene, Deprecated::OrthancApiClient& orthancApiClient) :
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
87 RadiographySceneBuilder(scene),
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
88 orthancApiClient_(orthancApiClient)
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
89 {
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
90 }
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
91
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: 1190
diff changeset
92 protected:
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: 1190
diff changeset
93 virtual RadiographyDicomLayer* 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: 1190
diff changeset
94 };
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: 1190
diff changeset
95
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: 1190
diff changeset
96 // reads the whole scene but the DICOM image such that we have the full 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: 1190
diff changeset
97 class RadiographySceneGeometryReader : public RadiographySceneBuilder
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: 1190
diff changeset
98 {
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: 1190
diff changeset
99 unsigned int dicomImageWidth_;
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: 1190
diff changeset
100 unsigned int 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: 1190
diff changeset
101
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: 1190
diff changeset
102 public:
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: 1190
diff changeset
103 RadiographySceneGeometryReader(RadiographyScene& scene, unsigned int dicomImageWidth, unsigned int 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: 1190
diff changeset
104 RadiographySceneBuilder(scene),
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: 1190
diff changeset
105 dicomImageWidth_(dicomImageWidth),
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: 1190
diff changeset
106 dicomImageHeight_(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: 1190
diff changeset
107 {
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: 1190
diff changeset
108 }
553
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
109
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
110 protected:
92305ee35b1c web-worker consequences: give access to lower level data
Alain Mazy <alain@mazy.be>
parents: 481
diff changeset
111 virtual RadiographyDicomLayer* LoadDicom(const std::string& instanceId, unsigned int frame, RadiographyLayer::Geometry* geometry);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
112 };
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents:
diff changeset
113 }