CScreenTransform.h
Go to the documentation of this file.
1 #ifndef iview_CScreenTransform_included
2 #define iview_CScreenTransform_included
3 
4 
5 #include <i2d/CAffine2d.h>
6 
7 
8 namespace iview
9 {
10 
11 
13 {
14 public:
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);
53  using BaseClass::GetApply;
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 
59 protected:
60  void CalculateInvert();
61 
62 private:
63  i2d::CAffine2d m_invert;
64 };
65 
66 
68 {
69 }
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 
112  CalculateInvert();
113 }
114 
115 
116 inline void CScreenTransform::Reset(const i2d::CVector2d& position)
117 {
118  BaseClass::Reset(position);
119 
120  CalculateInvert();
121 }
122 
123 
124 inline void CScreenTransform::Reset(const i2d::CVector2d& position, double angle, double scale)
125 {
126  BaseClass::Reset(position, angle, scale);
127 
128  CalculateInvert();
129 }
130 
131 
132 inline void CScreenTransform::Reset(const i2d::CVector2d& position, double angle, const i2d::CVector2d& scale)
133 {
134  BaseClass::Reset(position, angle, scale);
135 
136  CalculateInvert();
137 }
138 
139 
140 inline void CScreenTransform::Apply(const i2d::CAffine2d& transform)
141 {
142  BaseClass::Apply(transform);
143 
144  CalculateInvert();
145 }
146 
147 
149 {
150  BaseClass::operator=(transform);
151 
152  CalculateInvert();
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 #endif // !iview_CScreenTransform_included
174 
175 
i2d::CAffine2d & operator=(const i2d::CAffine2d &transform)
CAffine2d GetInverted() const
Get inverted transformation.
Definition: CAffine2d.h:318
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
double GetY() const
Get Y position of this vector.
Definition: CVector2d.h:184
void Apply(const CAffine2d &transform)
Combine this transformation with another transformation.
CAffine2d & operator=(const CAffine2d &transform)
int GetX() const
Definition: CIndex2d.h:96
const i2d::CAffine2d & GetInverted() const
Return reference to invert transformation.
void Apply(const i2d::CAffine2d &transform)
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
istd::CIndex2d GetScreenPosition(const i2d::CVector2d &position) const
Return position of point in screen coordinates.
void ApplyLeft(const i2d::CAffine2d &transform)
int GetY() const
Definition: CIndex2d.h:108
void GetApply(const i2d::CAffine2d &transform, CScreenTransform &result) const
CScreenTransform()
Default constructor.
CVector2d GetApply(const CVector2d &position) const
Calculate transformed position.
Definition: CAffine2d.h:257
This class defines an affine 2D-transformation.
Definition: CAffine2d.h:17
i2d::CVector2d GetClientPosition(istd::CIndex2d position) const
Return position of point in logical coordinates.
double GetX() const
Get X position of this vector.
Definition: CVector2d.h:172
void Reset()
Set to identity transformation.

© 2007-2017 Witold Gantzke and Kirill Lepskiy