Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/AffineTransform2D.h @ 1807:634ff8993f6a
Stone Web viewer: Patient birth date is now displayed in the overlays
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 May 2021 17:17:56 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
409 | 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:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
409 | 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:
1571
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
409 | 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:
1571
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:
1571
diff
changeset
|
15 * Lesser General Public License for more details. |
409 | 16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
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:
1571
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:
1571
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
409 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../StoneEnumerations.h" | |
26 #include "LinearAlgebra.h" | |
27 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
28 #include <Images/ImageAccessor.h> |
409 | 29 |
30 namespace OrthancStone | |
31 { | |
32 class AffineTransform2D | |
33 { | |
34 private: | |
35 Matrix matrix_; | |
36 | |
37 public: | |
38 AffineTransform2D(); | |
39 | |
40 // The matrix must be 3x3, without perspective effects | |
1571 | 41 explicit AffineTransform2D(const Matrix& m); |
409 | 42 |
43 AffineTransform2D(const AffineTransform2D& other) : | |
44 matrix_(other.matrix_) | |
45 { | |
46 } | |
47 | |
48 const Matrix& GetHomogeneousMatrix() const | |
49 { | |
50 return matrix_; | |
51 } | |
52 | |
53 void Apply(double& x /* inout */, | |
54 double& y /* inout */) const; | |
55 | |
56 void Apply(Orthanc::ImageAccessor& target, | |
57 const Orthanc::ImageAccessor& source, | |
58 ImageInterpolation interpolation, | |
59 bool clear) const; | |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
60 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
61 void ConvertToOpenGLMatrix(float target[16], |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
62 unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
63 unsigned int canvasHeight) const; |
575
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
64 |
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
65 double ComputeZoom() const; |
409 | 66 |
67 static AffineTransform2D Invert(const AffineTransform2D& a); | |
68 | |
69 static AffineTransform2D Combine(const AffineTransform2D& a, | |
70 const AffineTransform2D& b); | |
71 | |
72 static AffineTransform2D Combine(const AffineTransform2D& a, | |
73 const AffineTransform2D& b, | |
74 const AffineTransform2D& c); | |
75 | |
76 static AffineTransform2D Combine(const AffineTransform2D& a, | |
77 const AffineTransform2D& b, | |
78 const AffineTransform2D& c, | |
79 const AffineTransform2D& d); | |
80 | |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1038
diff
changeset
|
81 // transformations are applied right to left: |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1038
diff
changeset
|
82 // `e` is the first transformation applied and `a` is the last one |
1025
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
83 static AffineTransform2D Combine(const AffineTransform2D& a, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
84 const AffineTransform2D& b, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
85 const AffineTransform2D& c, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
86 const AffineTransform2D& d, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
87 const AffineTransform2D& e); |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
88 |
409 | 89 static AffineTransform2D CreateOffset(double dx, |
90 double dy); | |
91 | |
92 static AffineTransform2D CreateScaling(double sx, | |
93 double sy); | |
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:
1209
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:
1209
diff
changeset
|
95 static AffineTransform2D CreateRotation(double angle); // CW rotation in radians |
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:
1209
diff
changeset
|
96 |
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:
1209
diff
changeset
|
97 static AffineTransform2D CreateRotation(double angle, // CW rotation in radians |
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:
1209
diff
changeset
|
98 double cx, // rotation center |
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:
1209
diff
changeset
|
99 double cy); // rotation center |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
100 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
101 static AffineTransform2D CreateOpenGLClipspace(unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
102 unsigned int canvasHeight); |
1554
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
103 |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
104 static AffineTransform2D CreateFlip(bool flipX, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
105 bool flipY, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
106 unsigned int width, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
107 unsigned int height); |
409 | 108 }; |
109 } |