ACF $AcfVersion:0$
CParallelogramShape.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// ACF includes
7#include <i2d/CVector2d.h>
9
10
11namespace iview
12{
13
14
16{
17public:
19
21
25 virtual bool IsEditableRotation();
26 virtual void SetEditableRotation(bool state = true);
27
31 virtual bool IsEditableWidth();
32 virtual void SetEditableWidth(bool state = true);
33
37 virtual bool IsEditableHeight();
38 virtual void SetEditableHeight(bool state = true);
39
43 virtual bool IsEditableAngle();
44 virtual void SetEditableAngle(bool state = true);
45
49 virtual bool IsProportionalScaled() const;
50 virtual void SetProportionalScaled(bool state = true);
51
55 virtual bool AreAxesEqual() const;
56 virtual void SetAxesEqual(bool state = true);
57
61 virtual bool AreAxesOrthogonal() const;
62 virtual void SetAxesOrthogonal(bool state = true);
63
64 // reimplemented (iview::CInteractiveShapeBase)
65 virtual void InvalidateBoundingBox() override;
66
67 // reimplemented (iview::IInteractiveShape)
68 virtual TouchState IsTouched(istd::CIndex2d position) const override;
69
70 // reimplemented (iview::IShape)
71 virtual void Draw(QPainter& drawContext) const override;
72
73 // reimplemented (imod::IObserver)
74 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
75
76 // reimplemented (iview::IMouseActionObserver)
77 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override;
78 virtual bool OnMouseMove(istd::CIndex2d position) override;
79
80protected:
90
93
94 void CalcNodes(const i2d::CAffine2d& parallTransform) const;
95 void ResetNodes() const;
96 bool AreNodesValid() const;
97 const i2d::CVector2d* GetNodes() const;
98
99 virtual void EnsureValidNodes() const;
100
101 virtual bool IsTickerTouched(istd::CIndex2d position) const;
102 virtual bool IsCurveTouched(istd::CIndex2d position) const;
103 virtual void DrawTickers(QPainter& drawContext) const;
104 virtual void DrawFigure(QPainter& drawContext) const;
105
106 // reimplemented (iview::CShapeBase)
107 virtual i2d::CRect CalcBoundingBox() const override;
108
109 // reimplemented (iview::CInteractiveShapeBase)
110 virtual void BeginLogDrag(const i2d::CVector2d& reference) override;
111 virtual void SetLogDragPosition(const i2d::CVector2d& position) override;
112
113private:
114 bool m_isEditableRotation;
115 bool m_isEditableWidth;
116 bool m_isEditableHeight;
117 bool m_isEditableAngle;
118 bool m_isProportionalScaled;
119 bool m_areAxesEqual;
120 bool m_areAxesOrthogonal;
121
122 mutable i2d::CVector2d m_nodes[EN_LAST + 1];
123 mutable bool m_areNodesValid;
124};
125
126
127// inline methods
128
130{
131 return m_isEditableRotation;
132}
133
134
136{
137 m_isEditableRotation = state;
138}
139
140
142{
143 return m_isEditableWidth;
144}
145
146
148{
149 m_isEditableWidth = state;
150}
151
152
154{
155 return m_isEditableHeight;
156}
157
158
160{
161 m_isEditableHeight = state;
162}
163
164
166{
167 return m_isEditableAngle;
168}
169
170
172{
173 m_isEditableAngle = state;
174}
175
176
178{
179 return m_isProportionalScaled;
180}
181
182
184{
185 m_isProportionalScaled = state;
186}
187
188
190{
191 return m_areAxesEqual;
192}
193
194
196{
197 m_areAxesEqual = state;
198}
199
200
202{
203 return m_areAxesOrthogonal;
204}
205
206
208{
209 m_areAxesOrthogonal = state;
210}
211
212
213// protected methods
214
216{
217 return m_areNodesValid;
218}
219
220
222{
223 return m_nodes;
224}
225
226
227} // namespace iview
228
229
230
231
This class defines an affine 2D-transformation.
Definition CAffine2d.h:18
Simple rectangle with integer bounds.
Definition CRect.h:22
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
Set of change flags (its IDs).
Definition IChangeable.h:36
virtual bool IsProportionalScaled() const
Check, if both axis will be scaled proportional.
virtual bool IsTickerTouched(istd::CIndex2d position) const
virtual bool AreAxesEqual() const
Check, if it is forced to keep length of both axes equal.
virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override
It is called, when mouse button is pushed down or up on this object.
virtual void SetEditableWidth(bool state=true)
virtual bool IsEditableRotation()
Check, if rotation is editable.
virtual bool AreAxesOrthogonal() const
Check, if it is forced to keep both axes orthogonal.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
Callback invoked when an observable model is about to be attached to this observer.
virtual void Draw(QPainter &drawContext) const override
Draw this shape using draw context.
const i2d::CVector2d * GetNodes() const
virtual void SetProportionalScaled(bool state=true)
virtual bool OnMouseMove(istd::CIndex2d position) override
It is called, when mouse is moved.
virtual void InvalidateBoundingBox() override
Invalidate bounding box.
virtual void SetEditableAngle(bool state=true)
virtual TouchState IsTouched(istd::CIndex2d position) const override
Check, if any shape is touched.
virtual bool IsCurveTouched(istd::CIndex2d position) const
virtual void SetAxesOrthogonal(bool state=true)
void CalcNodes(const i2d::CAffine2d &parallTransform) const
virtual void SetLogDragPosition(const i2d::CVector2d &position) override
CInteractiveShapeBase BaseClass
virtual void BeginLogDrag(const i2d::CVector2d &reference) override
virtual void EnsureValidNodes() const
virtual void SetAxesEqual(bool state=true)
virtual i2d::CRect CalcBoundingBox() const override
Calculate bounding box.
virtual void SetEditableHeight(bool state=true)
virtual bool IsEditableWidth()
Check, if width is editable.
virtual void DrawTickers(QPainter &drawContext) const
virtual bool IsEditableAngle()
Check, if internal angle is editable.
virtual bool IsEditableHeight()
Check, if size is editable.
virtual void SetEditableRotation(bool state=true)
virtual void DrawFigure(QPainter &drawContext) const
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:25
In this library is defined 2D view concept and standard visualisation objects.