ACF $AcfVersion:0$
CPolygonShape.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// Qt includes
6#include <QtCore/QVector>
7#include <QtGui/QPolygon>
8
9// ACF includes
10#include <i2d/CVector2d.h>
11
12
14
15
16namespace iview
17{
18
19
21{
22public:
25
26 virtual bool IsAreaTouchAllowed() const { return m_areaTouchAllowed; }
27 virtual void SetAreaTouchAllowed(bool state = true) { m_areaTouchAllowed = state; }
28
29 virtual bool IsEditableNodes() const { return m_editableNodes; }
30 virtual void SetEditableNodes(bool state = true) { m_editableNodes = state; }
31
36 virtual bool IsFirstVisible() const;
37 virtual void SetFirstVisible(bool state = true);
38
43 virtual bool IsAlwaysMovable() const;
44
49 virtual void SetAlwaysMovable(bool state = true);
50
51 // reimplemented (iview::IShape)
52 virtual bool IsInside(const istd::CIndex2d& screenPosition) const override;
53
54 // reimplemented (iview::ITouchable)
55 virtual TouchState IsTouched(istd::CIndex2d position) const override;
56 virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const override;
57
58 // reimplemented (iview::IVisualizable)
59 virtual void Draw(QPainter& drawContext) const override;
60
61 // reimplemented (imod::IObserver)
62 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
63
64 // reimplemented (iview::IMouseActionObserver)
65 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override;
66 virtual bool OnMouseMove(istd::CIndex2d position) override;
67
68 // reimplemented (iview::IDraggable)
69 virtual bool IsDraggable() const override;
70
71protected:
74
75 virtual i2d::CVector2d GetSegmentMiddle(int index) const;
76 virtual void DrawCurve(QPainter& drawContext) const;
77 virtual void DrawArea(QPainter& drawContext) const;
78 virtual void DrawSelectionElements(QPainter& drawContext) const;
79
80 // TODO...
81 virtual bool IsAreaTouched(istd::CIndex2d position) const;
82
83 // reimplemented (iview::CRectControlledShapeBase)
84 virtual void EnsureValidNodes() const override;
85 virtual bool IsCurveTouched(istd::CIndex2d position) const override;
86
87 // reimplemented (iview::CInteractiveShapeBase)
88 virtual void BeginLogDrag(const i2d::CVector2d& reference) override;
89 virtual void SetLogDragPosition(const i2d::CVector2d& position) override;
90
91 // reimplemented (iview::CShapeBase)
92 virtual i2d::CRect CalcBoundingBox() const override;
93
94protected:
96 QVector<i2d::CVector2d> m_references;
97
100 mutable QPolygonF m_screenPoints;
101
102private:
103 bool m_isFirstVisible = false;
104 bool m_isAlwaysDraggable = false;
105 bool m_areaTouchAllowed = false;
106 bool m_editableNodes = true;
107};
108
109
111{
112 return m_isFirstVisible;
113}
114
115
116inline void CPolygonShape::SetFirstVisible(bool state)
117{
118 m_isFirstVisible = state;
119}
120
121
123{
124 return m_isAlwaysDraggable;
125}
126
127
128inline void CPolygonShape::SetAlwaysMovable(bool state)
129{
130 m_isAlwaysDraggable = state;
131}
132
133
134} // namespace iview
135
136
137
138
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
i2d::CAffine2d m_castTransform
virtual bool IsEditableNodes() const
virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const override
Get description to shape at specified position.
virtual void Draw(QPainter &drawContext) const override
Draw this shape using draw context.
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 SetLogDragPosition(const i2d::CVector2d &position) override
virtual void BeginLogDrag(const i2d::CVector2d &reference) override
virtual void SetEditableNodes(bool state=true)
virtual i2d::CRect CalcBoundingBox() const override
Calculate bounding box.
CInteractiveShapeBase ShapeBaseClass
virtual bool IsFirstVisible() const
Check if first point is always visible as ticker.
virtual bool IsAreaTouchAllowed() const
static const istd::IChangeable::ChangeSet & GetMoveAllChangeSet()
virtual bool IsAreaTouched(istd::CIndex2d position) const
virtual void EnsureValidNodes() const override
virtual i2d::CVector2d GetSegmentMiddle(int index) const
virtual bool IsDraggable() const override
Check if drag is enabled.
virtual void DrawArea(QPainter &drawContext) const
virtual void SetAlwaysMovable(bool state=true)
Set flag if in all edit modes is this shape draggable.
virtual TouchState IsTouched(istd::CIndex2d position) const override
Check, if any shape is touched.
virtual void SetFirstVisible(bool state=true)
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 bool IsAlwaysMovable() const
Check if in all edit modes is this shape draggable.
virtual bool IsCurveTouched(istd::CIndex2d position) const override
virtual void DrawCurve(QPainter &drawContext) const
i2d::CVector2d m_castAxis
virtual void DrawSelectionElements(QPainter &drawContext) const
virtual bool OnMouseMove(istd::CIndex2d position) override
It is called, when mouse is moved.
virtual void SetAreaTouchAllowed(bool state=true)
virtual bool IsInside(const istd::CIndex2d &screenPosition) const override
static const istd::IChangeable::ChangeSet & GetMoveChangeSet()
CRectControlledShapeBase BaseClass
QVector< i2d::CVector2d > m_references
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:25
In this library is defined 2D view concept and standard visualisation objects.