ACF $AcfVersion:0$
CScreenTransform.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5#include <i2d/CAffine2d.h>
6
7
8namespace iview
9{
10
11
13{
14public:
16
22
26 CScreenTransform(const CScreenTransform& transform);
27
31 CScreenTransform(const i2d::CAffine2d& transform);
32
37
41 istd::CIndex2d GetScreenPosition(const i2d::CVector2d& position) const;
42
46 const i2d::CAffine2d& GetInverted() const;
47
48 // reimplemented (i2d::CAffine2d)
49 void Reset();
50 void Reset(const i2d::CVector2d& position);
51 void Reset(const i2d::CVector2d& position, double angle, double scale = 1.0);
52 void Reset(const i2d::CVector2d& position, double angle, const i2d::CVector2d& scale);
54 void GetApply(const i2d::CAffine2d& transform, CScreenTransform& result) const;
55 void Apply(const i2d::CAffine2d& transform);
56 void ApplyLeft(const i2d::CAffine2d& transform);
57 i2d::CAffine2d& operator=(const i2d::CAffine2d& transform);
58
59protected:
60 void CalculateInvert();
61
62private:
63 i2d::CAffine2d m_invert;
64};
65
66
70
71
73 : i2d::CAffine2d(transform),
74 m_invert(transform.m_invert)
75{
76}
77
78
80 : i2d::CAffine2d(transform)
81{
83}
84
85
87{
88 i2d::CVector2d result;
89 i2d::CVector2d pos(position.GetX(), position.GetY());
90
91 m_invert.GetApply(pos, result);
92
93 return result;
94}
95
96
98{
99 i2d::CVector2d result;
100 GetApply(position, result);
101
102 return istd::CIndex2d(int(result.GetX()), int(result.GetY()));
103}
104
105
106// reimplemented (i2d::CAffine2d)
107
109{
111
113}
114
115
116inline void CScreenTransform::Reset(const i2d::CVector2d& position)
117{
118 BaseClass::Reset(position);
119
121}
122
123
124inline void CScreenTransform::Reset(const i2d::CVector2d& position, double angle, double scale)
125{
126 BaseClass::Reset(position, angle, scale);
127
129}
130
131
132inline void CScreenTransform::Reset(const i2d::CVector2d& position, double angle, const i2d::CVector2d& scale)
133{
134 BaseClass::Reset(position, angle, scale);
135
137}
138
139
140inline void CScreenTransform::Apply(const i2d::CAffine2d& transform)
141{
142 BaseClass::Apply(transform);
143
145}
146
147
149{
150 BaseClass::operator=(transform);
151
153
154 return *this;
155}
156
157
159{
160 BaseClass::GetInverted(m_invert);
161}
162
163
165{
166 return m_invert;
167}
168
169
170} // namespace iview
171
172
173
174
This class defines an affine 2D-transformation.
Definition CAffine2d.h:18
CAffine2d & operator=(const CAffine2d &transform)
void Reset()
Set to identity transformation.
CVector2d GetApply(const CVector2d &position) const
Calculate transformed position.
Definition CAffine2d.h:268
void Apply(const CAffine2d &transform)
Combine this transformation with another transformation.
CAffine2d GetInverted() const
Get inverted transformation.
Definition CAffine2d.h:329
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
double GetY() const
Get Y position of this vector.
Definition CVector2d.h:184
double GetX() const
Get X position of this vector.
Definition CVector2d.h:172
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
int GetX() const
Definition CIndex2d.h:96
int GetY() const
Definition CIndex2d.h:108
CScreenTransform()
Default constructor.
i2d::CVector2d GetClientPosition(istd::CIndex2d position) const
Return position of point in logical coordinates.
i2d::CAffine2d & operator=(const i2d::CAffine2d &transform)
void Apply(const i2d::CAffine2d &transform)
void GetApply(const i2d::CAffine2d &transform, CScreenTransform &result) const
istd::CIndex2d GetScreenPosition(const i2d::CVector2d &position) const
Return position of point in screen coordinates.
void ApplyLeft(const i2d::CAffine2d &transform)
const i2d::CAffine2d & GetInverted() const
Return reference to invert transformation.
Contains the 2D objects.
Definition CAffine2d.h:11
In this library is defined 2D view concept and standard visualisation objects.