Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.h @ 1777:d9c5474c5588
fix build of Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 07:35:13 +0200 |
parents | fca942f4b4a7 |
children | 6e8105942146 |
rev | line source |
---|---|
590 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1610
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
590 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
590 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
590 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "ISceneLayer.h" | |
26 #include "../Toolbox/AffineTransform2D.h" | |
1769 | 27 #include "../Toolbox/CoordinateSystem3D.h" |
590 | 28 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1298
diff
changeset
|
29 #include <Compatibility.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1298
diff
changeset
|
30 #include <Images/ImageAccessor.h> |
590 | 31 |
32 namespace OrthancStone | |
33 { | |
34 class TextureBaseSceneLayer : public ISceneLayer | |
35 { | |
36 private: | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
37 std::unique_ptr<Orthanc::ImageAccessor> texture_; |
590 | 38 double originX_; |
39 double originY_; | |
40 double pixelSpacingX_; | |
41 double pixelSpacingY_; | |
42 double angle_; | |
43 bool isLinearInterpolation_; | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
44 bool flipX_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
45 bool flipY_; |
590 | 46 uint64_t revision_; |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
47 std::unique_ptr<AffineTransform2D> transform_; // Manually-specified transformation |
590 | 48 |
49 protected: | |
50 void SetTexture(Orthanc::ImageAccessor* texture); | |
51 | |
52 void IncrementRevision() | |
53 { | |
54 revision_++; | |
55 } | |
56 | |
57 void CopyParameters(const TextureBaseSceneLayer& other); | |
58 | |
59 public: | |
60 TextureBaseSceneLayer(); | |
61 | |
62 // Center of the top-left pixel | |
63 void SetOrigin(double x, | |
64 double y); | |
65 | |
66 void SetPixelSpacing(double sx, | |
67 double sy); | |
68 | |
69 // In radians | |
70 void SetAngle(double angle); | |
71 | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
72 void SetFlipX(bool flip); |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
73 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
74 void SetFlipY(bool flip); |
590 | 75 |
76 double GetOriginX() const | |
77 { | |
78 return originX_; | |
79 } | |
80 | |
81 double GetOriginY() const | |
82 { | |
83 return originY_; | |
84 } | |
85 | |
86 double GetPixelSpacingX() const | |
87 { | |
88 return pixelSpacingX_; | |
89 } | |
90 | |
91 double GetPixelSpacingY() const | |
92 { | |
93 return pixelSpacingY_; | |
94 } | |
95 | |
96 double GetAngle() const | |
97 { | |
98 return angle_; | |
99 } | |
100 | |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
101 bool IsFlipX() const |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
102 { |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
103 return flipX_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
104 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
105 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
106 bool IsFlipY() const |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
107 { |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
108 return flipY_; |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
109 } |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
110 |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
111 bool IsLinearInterpolation() const |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
112 { |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
113 return isLinearInterpolation_; |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
114 } |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
115 |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
116 void SetLinearInterpolation(bool isLinearInterpolation); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
117 |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
118 bool HasTexture() const |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
119 { |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
120 return (texture_.get() != NULL); |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
121 } |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
122 |
590 | 123 const Orthanc::ImageAccessor& GetTexture() const; |
124 | |
1768
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
125 void SetTransform(const AffineTransform2D& transform); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
126 |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
127 void ClearTransform(); |
226718777702
fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
128 |
1775
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
129 /** |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
130 * Initialize a transform that maps a texture slice in 3D, to a |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
131 * cutting plane (the cutting plane should be parallel to the 3D |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
132 * slice). The "pixelOffsetX/Y" must take pixel spacing into |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
133 * account. This method automatically converts from voxel centers |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
134 * (3D) to pixel corners (2D). |
fca942f4b4a7
fix conversion from voxel centers to texture borders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1769
diff
changeset
|
135 **/ |
1769 | 136 void SetCuttingPlaneTransform(const CoordinateSystem3D& cuttingPlane, |
137 const Vector& origin, // coordinates of the center of the voxel | |
138 const Vector& pixelOffsetX, // 3D offset from (0,0) voxel to (1,0) voxel | |
139 const Vector& pixelOffsetY); // 3D offset from (0,0) voxel to (0,1) voxel | |
140 | |
590 | 141 AffineTransform2D GetTransform() const; |
142 | |
1610
b7630b1a0253
ISceneLayer::GetBoundingBox() returns void
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
143 virtual void GetBoundingBox(Extent2D& target) const ORTHANC_OVERRIDE; |
590 | 144 |
1571 | 145 virtual uint64_t GetRevision() const ORTHANC_OVERRIDE |
590 | 146 { |
147 return revision_; | |
148 } | |
149 }; | |
150 } |