CPolygonShape.h
Go to the documentation of this file.
1 #ifndef iview_CPolygonShape_included
2 #define iview_CPolygonShape_included
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 
16 namespace iview
17 {
18 
19 
21 {
22 public:
25 
26  CPolygonShape();
27 
32  virtual bool IsFirstVisible() const;
33  virtual void SetFirstVisible(bool state = true);
34 
39  virtual bool IsAlwaysMovable() const;
40 
45  virtual void SetAlwaysMovable(bool state = true);
46 
47  // reimplemented (iview::ITouchable)
48  virtual TouchState IsTouched(istd::CIndex2d position) const;
49 
50  // reimplemented (iview::IVisualizable)
51  virtual void Draw(QPainter& drawContext) const;
52 
53  // reimplemented (imod::IObserver)
54  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
55 
56  // reimplemented (iview::IMouseActionObserver)
57  virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
58  virtual bool OnMouseMove(istd::CIndex2d position);
59 
60  // reimplemented (iview::IDraggable)
61  virtual bool IsDraggable() const;
62 
63 protected:
64  virtual i2d::CVector2d GetSegmentMiddle(int index) const;
65  virtual void DrawCurve(QPainter& drawContext) const;
66  virtual void DrawArea(QPainter& drawContext) const;
67  virtual void DrawSelectionElements(QPainter& drawContext) const;
68 
69  // reimplemented (iview::CRectControlledShapeBase)
70  virtual void EnsureValidNodes() const;
71  virtual bool IsCurveTouched(istd::CIndex2d position) const;
72 
73  // reimplemented (iview::CInteractiveShapeBase)
74  virtual void BeginLogDrag(const i2d::CVector2d& reference);
75  virtual void SetLogDragPosition(const i2d::CVector2d& position);
76 
77  // reimplemented (iview::CShapeBase)
78  virtual i2d::CRect CalcBoundingBox() const;
79 
81  QVector<i2d::CVector2d> m_references;
82 
85  mutable QPolygonF m_screenPoints;
86 
87 private:
88  bool m_isFirstVisible;
89  bool m_isAlwaysDraggable;
90 };
91 
92 
93 inline bool CPolygonShape::IsFirstVisible() const
94 {
95  return m_isFirstVisible;
96 }
97 
98 
99 inline void CPolygonShape::SetFirstVisible(bool state)
100 {
101  m_isFirstVisible = state;
102 }
103 
104 
106 {
107  return m_isAlwaysDraggable;
108 }
109 
110 
111 inline void CPolygonShape::SetAlwaysMovable(bool state)
112 {
113  m_isAlwaysDraggable = state;
114 }
115 
116 
117 } // namespace iview
118 
119 
120 #endif // !iview_CPolygonShape_included
121 
122 
CInteractiveShapeBase ShapeBaseClass
Definition: CPolygonShape.h:24
QVector< i2d::CVector2d > m_references
Definition: CPolygonShape.h:81
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
CRectControlledShapeBase BaseClass
Definition: CPolygonShape.h:23
virtual bool IsDraggable() const
Check if drag is enabled.
virtual void DrawCurve(QPainter &drawContext) const
virtual void SetAlwaysMovable(bool state=true)
Set flag if in all edit modes is this shape draggable.
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
i2d::CVector2d m_castAxis
Definition: CPolygonShape.h:83
virtual void EnsureValidNodes() const
virtual void BeginLogDrag(const i2d::CVector2d &reference)
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask)
This call back function will be called, if an observable object is about to be attached.
virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag)
It is called, when mouse button is pushed down or up on this object.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual void Draw(QPainter &drawContext) const
Draw this shape using draw context.
virtual bool IsAlwaysMovable() const
Check if in all edit modes is this shape draggable.
virtual bool IsFirstVisible() const
Check if first point is always visible as ticker.
Definition: CPolygonShape.h:93
QPolygonF m_screenPoints
Definition: CPolygonShape.h:85
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
virtual i2d::CVector2d GetSegmentMiddle(int index) const
virtual void DrawArea(QPainter &drawContext) const
virtual void SetFirstVisible(bool state=true)
Definition: CPolygonShape.h:99
Common interface for model objects, that supports Model/Observer design pattern.
Definition: IModel.h:23
Set of change flags (its IDs).
Definition: IChangeable.h:30
This class defines an affine 2D-transformation.
Definition: CAffine2d.h:17
virtual void SetLogDragPosition(const i2d::CVector2d &position)
virtual void DrawSelectionElements(QPainter &drawContext) const
virtual bool IsCurveTouched(istd::CIndex2d position) const
i2d::CAffine2d m_castTransform
Definition: CPolygonShape.h:84
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box.

© 2007-2017 Witold Gantzke and Kirill Lepskiy