Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/AffineTransform2D.h @ 1534:0443d04416d9
don't discard the windowing altered by mouse
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 21:48:43 +0200 |
parents | 244ad1e4e76a |
children | 6d14ed6163b1 |
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 | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1259
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
409 | 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 #pragma once | |
23 | |
24 #include "../StoneEnumerations.h" | |
25 #include "LinearAlgebra.h" | |
26 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
27 #include <Images/ImageAccessor.h> |
409 | 28 |
29 namespace OrthancStone | |
30 { | |
31 class AffineTransform2D | |
32 { | |
33 private: | |
34 Matrix matrix_; | |
35 | |
36 public: | |
37 AffineTransform2D(); | |
38 | |
39 // The matrix must be 3x3, without perspective effects | |
40 AffineTransform2D(const Matrix& m); | |
41 | |
42 AffineTransform2D(const AffineTransform2D& other) : | |
43 matrix_(other.matrix_) | |
44 { | |
45 } | |
46 | |
47 const Matrix& GetHomogeneousMatrix() const | |
48 { | |
49 return matrix_; | |
50 } | |
51 | |
52 void Apply(double& x /* inout */, | |
53 double& y /* inout */) const; | |
54 | |
55 void Apply(Orthanc::ImageAccessor& target, | |
56 const Orthanc::ImageAccessor& source, | |
57 ImageInterpolation interpolation, | |
58 bool clear) const; | |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
59 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
60 void ConvertToOpenGLMatrix(float target[16], |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
61 unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
62 unsigned int canvasHeight) const; |
575
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
63 |
919226caca82
AffineTransform2D::ComputeZoom()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
574
diff
changeset
|
64 double ComputeZoom() const; |
409 | 65 |
66 static AffineTransform2D Invert(const AffineTransform2D& a); | |
67 | |
68 static AffineTransform2D Combine(const AffineTransform2D& a, | |
69 const AffineTransform2D& b); | |
70 | |
71 static AffineTransform2D Combine(const AffineTransform2D& a, | |
72 const AffineTransform2D& b, | |
73 const AffineTransform2D& c); | |
74 | |
75 static AffineTransform2D Combine(const AffineTransform2D& a, | |
76 const AffineTransform2D& b, | |
77 const AffineTransform2D& c, | |
78 const AffineTransform2D& d); | |
79 | |
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
|
80 // 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
|
81 // `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
|
82 static AffineTransform2D Combine(const AffineTransform2D& a, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
83 const AffineTransform2D& b, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
84 const AffineTransform2D& c, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
85 const AffineTransform2D& d, |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
86 const AffineTransform2D& e); |
7912de3a15e0
AffineTransform2D::Combine with 5 args
Alain Mazy <alain@mazy.be>
parents:
575
diff
changeset
|
87 |
409 | 88 static AffineTransform2D CreateOffset(double dx, |
89 double dy); | |
90 | |
91 static AffineTransform2D CreateScaling(double sx, | |
92 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
|
93 |
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 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
|
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 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
|
98 double cy); // rotation center |
574
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
99 |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
100 static AffineTransform2D CreateOpenGLClipspace(unsigned int canvasWidth, |
911297a277c4
AffineTransform2D::ConvertToOpenGLMatrix()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
101 unsigned int canvasHeight); |
409 | 102 }; |
103 } |