Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/AffineTransform2D.h @ 2012:637d6373127a
width of the vertical slider has doubled to ease user interactions
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Dec 2022 18:49:06 +0100 |
parents | e8b9a2ba1df1 |
children | 07964689cb0b |
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 | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
409 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
409 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
409 | 17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
409 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "../StoneEnumerations.h" | |
27 #include "LinearAlgebra.h" | |
28 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
29 #include <Images/ImageAccessor.h> |
409 | 30 |
31 namespace OrthancStone | |
32 { | |
33 class AffineTransform2D | |
34 { | |
35 private: | |
36 Matrix matrix_; | |
37 | |
38 public: | |
1989
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
39 AffineTransform2D(); // Create the identity transform |
409 | 40 |
41 // The matrix must be 3x3, without perspective effects | |
1571 | 42 explicit AffineTransform2D(const Matrix& m); |
409 | 43 |
44 AffineTransform2D(const AffineTransform2D& other) : | |
45 matrix_(other.matrix_) | |
46 { | |
47 } | |
48 | |
49 const Matrix& GetHomogeneousMatrix() const | |
50 { | |
51 return matrix_; | |
52 } | |
53 | |
54 void Apply(double& x /* inout */, | |
55 double& y /* inout */) const; | |
56 | |
57 void Apply(Orthanc::ImageAccessor& target, | |
58 const Orthanc::ImageAccessor& source, | |
59 ImageInterpolation interpolation, | |
60 bool clear) const; | |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
61 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
62 void ConvertToOpenGLMatrix(float target[16], |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
63 unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
64 unsigned int canvasHeight) const; |
575
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
65 |
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
66 double ComputeZoom() const; |
409 | 67 |
68 static AffineTransform2D Invert(const AffineTransform2D& a); | |
69 | |
70 static AffineTransform2D Combine(const AffineTransform2D& a, | |
71 const AffineTransform2D& b); | |
72 | |
73 static AffineTransform2D Combine(const AffineTransform2D& a, | |
74 const AffineTransform2D& b, | |
75 const AffineTransform2D& c); | |
76 | |
77 static AffineTransform2D Combine(const AffineTransform2D& a, | |
78 const AffineTransform2D& b, | |
79 const AffineTransform2D& c, | |
80 const AffineTransform2D& d); | |
81 | |
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
|
82 // 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
|
83 // `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
|
84 static AffineTransform2D Combine(const AffineTransform2D& a, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
85 const AffineTransform2D& b, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
86 const AffineTransform2D& c, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
87 const AffineTransform2D& d, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
88 const AffineTransform2D& e); |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
89 |
409 | 90 static AffineTransform2D CreateOffset(double dx, |
91 double dy); | |
92 | |
93 static AffineTransform2D CreateScaling(double sx, | |
94 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
|
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:
1209
diff
changeset
|
96 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
|
97 |
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 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
|
99 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
|
100 double cy); // rotation center |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
101 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
102 static AffineTransform2D CreateOpenGLClipspace(unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
103 unsigned int canvasHeight); |
1554
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 static AffineTransform2D CreateFlip(bool flipX, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
106 bool flipY, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
107 unsigned int width, |
6d14ed6163b1
flip x/y in Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
108 unsigned int height); |
1989
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
109 |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
110 static AffineTransform2D CreateFlipX(); |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
111 |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
112 static AffineTransform2D CreateFlipY(); |
409 | 113 }; |
114 } |