CParallelogramShape.h
Go to the documentation of this file.
1 #ifndef iview_CParallelogramShape_included
2 #define iview_CParallelogramShape_included
3 
4 
5 // ACF includes
6 #include <i2d/CParallelogram.h>
7 #include <i2d/CVector2d.h>
9 
10 
11 namespace iview
12 {
13 
14 
16 {
17 public:
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();
66 
67  // reimplemented (iview::IInteractiveShape)
68  virtual TouchState IsTouched(istd::CIndex2d position) const;
69 
70  // reimplemented (iview::IShape)
71  virtual void Draw(QPainter& drawContext) const;
72 
73  // reimplemented (imod::IObserver)
74  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
75 
76  // reimplemented (iview::IMouseActionObserver)
77  virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
78  virtual bool OnMouseMove(istd::CIndex2d position);
79 
80 protected:
81  enum EditNode
82  {
83  EN_NONE = -1,
84  EN_NODE11 = 0,
85  EN_NODE12 = 1,
86  EN_NODE22 = 2,
87  EN_NODE21 = 3,
89  };
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;
108 
109  // reimplemented (iview::CInteractiveShapeBase)
110  virtual void BeginLogDrag(const i2d::CVector2d& reference);
111  virtual void SetLogDragPosition(const i2d::CVector2d& position);
112 
113 private:
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 
195 inline void CParallelogramShape::SetAxesEqual(bool state)
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 #endif // !iview_CParallelogramShape_included
231 
232 
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.
CInteractiveShapeBase BaseClass
virtual void SetAxesEqual(bool state=true)
virtual void BeginLogDrag(const i2d::CVector2d &reference)
virtual void SetAxesOrthogonal(bool state=true)
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
virtual void SetLogDragPosition(const i2d::CVector2d &position)
virtual void DrawFigure(QPainter &drawContext) const
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box.
virtual void SetEditableHeight(bool state=true)
virtual void DrawTickers(QPainter &drawContext) const
virtual void InvalidateBoundingBox()
Invalidate bounding box.
virtual bool IsProportionalScaled() const
Check, if both axis will be scaled proportional.
virtual void EnsureValidNodes() const
virtual bool IsCurveTouched(istd::CIndex2d position) const
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.
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
virtual void SetEditableWidth(bool state=true)
virtual bool AreAxesEqual() const
Check, if it is forced to keep length of both axes equal.
virtual void SetEditableRotation(bool state=true)
virtual bool IsEditableAngle()
Check, if internal angle is editable.
virtual bool IsEditableWidth()
Check, if width is editable.
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
virtual bool IsEditableHeight()
Check, if size is editable.
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
const i2d::CVector2d * GetNodes() const
void CalcNodes(const i2d::CAffine2d &parallTransform) const
virtual void Draw(QPainter &drawContext) const
Draw this shape using draw context.
virtual void SetProportionalScaled(bool state=true)
virtual bool AreAxesOrthogonal() const
Check, if it is forced to keep both axes orthogonal.
virtual bool IsTickerTouched(istd::CIndex2d position) const
virtual bool IsEditableRotation()
Check, if rotation is editable.
virtual void SetEditableAngle(bool state=true)

© 2007-2017 Witold Gantzke and Kirill Lepskiy