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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
409
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../StoneEnumerations.h"
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include "LinearAlgebra.h"
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1279
diff changeset
29 #include <Images/ImageAccessor.h>
409
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class AffineTransform2D
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 private:
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 Matrix matrix_;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 // The matrix must be 3x3, without perspective effects
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1554
diff changeset
42 explicit AffineTransform2D(const Matrix& m);
409
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 AffineTransform2D(const AffineTransform2D& other) :
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 matrix_(other.matrix_)
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 const Matrix& GetHomogeneousMatrix() const
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 return matrix_;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 void Apply(double& x /* inout */,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 double& y /* inout */) const;
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 void Apply(Orthanc::ImageAccessor& target,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 const Orthanc::ImageAccessor& source,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 ImageInterpolation interpolation,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 static AffineTransform2D Invert(const AffineTransform2D& a);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 static AffineTransform2D Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const AffineTransform2D& b);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 static AffineTransform2D Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 const AffineTransform2D& b,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 const AffineTransform2D& c);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 static AffineTransform2D Combine(const AffineTransform2D& a,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 const AffineTransform2D& b,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const AffineTransform2D& c,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 const AffineTransform2D& d);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 static AffineTransform2D CreateOffset(double dx,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 double dy);
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 static AffineTransform2D CreateScaling(double sx,
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 };
99c9b3238008 AffineTransform2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }