CRectControlledShapeBase.h
Go to the documentation of this file.
1 #ifndef iview_CRectControlledShapeBase_included
2 #define iview_CRectControlledShapeBase_included
3 
4 
5 // ACF includes
7 
8 
9 namespace iview
10 {
11 
12 
14 {
15 public:
18 
20 
24  virtual bool IsEditableRotation();
25  virtual void SetEditableRotation(bool state = true);
26 
30  virtual bool IsEditableWidth();
31  virtual void SetEditableWidth(bool state = true);
32 
36  virtual bool IsEditableHeight();
37  virtual void SetEditableHeight(bool state = true);
38 
42  virtual bool IsProportionalScaled() const;
43  virtual void SetProportionalScaled(bool state = true);
44 
45  // reimplemented (iview::CInteractiveShapeBase)
46  virtual void InvalidateBoundingBox();
47 
48  // reimplemented (iview::IInteractiveShape)
49  virtual TouchState IsTouched(istd::CIndex2d position) const;
50 
51  // reimplemented (iview::IShape)
52  virtual void Draw(QPainter& drawContext) const;
53 
54  // reimplemented (iview::IMouseActionObserver)
55  virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
56 
57 protected:
58  enum EditNode
59  {
60  EN_NODE1 = 0,
72  };
73 
74  enum MouseMode
75  {
87  };
88 
89  void CalcNodes(const i2d::CAffine2d& parallTransform) const;
90  void ResetNodes() const;
91  bool AreNodesValid() const;
92 
94 
95  virtual bool IsTickerTouched(istd::CIndex2d position) const;
96  virtual void DrawTickers(QPainter& drawContext) const;
97  virtual void DrawFigure(QPainter& drawContext) const;
98 
99  bool IsParallTouched(
100  const i2d::CAffine2d& parallTransform,
101  istd::CIndex2d position) const;
103  const i2d::CVector2d& center,
104  const i2d::CVector2d& isPos,
105  const i2d::CVector2d& shouldPos);
107  const i2d::CVector2d& center,
108  const i2d::CVector2d& isPos,
109  const i2d::CVector2d& shouldPos);
111  const i2d::CVector2d& center,
112  const i2d::CVector2d& isPos,
113  const i2d::CVector2d& shouldPos);
114 
115  // reimplemented (iview::CInteractiveShapeBase)
116  virtual void BeginLogDrag(const i2d::CVector2d& reference);
117  virtual void SetLogDragPosition(const i2d::CVector2d& position);
118 
119  // reimplemented (iview::CShapeBase)
120  virtual i2d::CRect CalcBoundingBox() const;
121 
122  // abstract methods
123  virtual void EnsureValidNodes() const = 0;
124  virtual bool IsCurveTouched(istd::CIndex2d position) const = 0;
125 
128 
129 private:
130  bool m_isEditableRotation;
131  bool m_isEditableWidth;
132  bool m_isEditableHeight;
133  bool m_isProportionalScaled;
134 
135  mutable i2d::CVector2d m_screenNodes[EN_LAST + 1];
136  mutable bool m_areNodesValid;
137 };
138 
139 
140 // inline methods
141 
143 {
144  return m_isEditableRotation;
145 }
146 
147 
149 {
150  m_isEditableRotation = state;
151 }
152 
153 
155 {
156  return m_isEditableWidth;
157 }
158 
159 
161 {
162  m_isEditableWidth = state;
163 }
164 
165 
167 {
168  return m_isEditableHeight;
169 }
170 
171 
173 {
174  m_isEditableHeight = state;
175 }
176 
177 
179 {
180  return m_isProportionalScaled;
181 }
182 
183 
185 {
186  m_isProportionalScaled = state;
187 }
188 
189 
190 // protected methods
191 
193 {
194  return m_areNodesValid;
195 }
196 
197 
198 } // namespace iview
199 
200 
201 #endif // !iview_CRectControlledShapeBase_included
202 
203 
204 
virtual i2d::CRect CalcBoundingBox() const
Calculate bounding box.
i2d::CAffine2d CalcMoveTransform(i2d::CVector2d position, const i2d::CAffine2d &transform)
virtual void EnsureValidNodes() const =0
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.
i2d::CAffine2d CalcScaleTransform(const i2d::CVector2d &center, const i2d::CVector2d &isPos, const i2d::CVector2d &shouldPos)
virtual void SetLogDragPosition(const i2d::CVector2d &position)
Simple rectangle with integer bounds.
Definition: CRect.h:21
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
virtual bool IsCurveTouched(istd::CIndex2d position) const =0
void CalcNodes(const i2d::CAffine2d &parallTransform) const
virtual bool IsProportionalScaled() const
Check, if both axis will be scaled proportional.
i2d::CAffine2d CalcRotatedTransform(const i2d::CVector2d &center, const i2d::CVector2d &isPos, const i2d::CVector2d &shouldPos)
virtual void DrawFigure(QPainter &drawContext) const
bool IsParallTouched(const i2d::CAffine2d &parallTransform, istd::CIndex2d position) const
virtual bool IsTickerTouched(istd::CIndex2d position) const
virtual void InvalidateBoundingBox()
Invalidate bounding box.
i2d::CAffine2d CalcSizeTransform(const i2d::CVector2d &center, const i2d::CVector2d &isPos, const i2d::CVector2d &shouldPos)
virtual bool IsEditableHeight()
Check, if height is editable.
virtual void SetEditableWidth(bool state=true)
virtual void BeginLogDrag(const i2d::CVector2d &reference)
virtual bool IsEditableRotation()
Check, if rotation is editable.
virtual void SetEditableHeight(bool state=true)
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual TouchState IsTouched(istd::CIndex2d position) const
Check, if any shape is touched.
TouchState
Enumeration for possible shape touch states.
Definition: ITouchable.h:24
virtual void SetEditableRotation(bool state=true)
virtual bool IsEditableWidth()
Check, if width is editable.
This class defines an affine 2D-transformation.
Definition: CAffine2d.h:17
virtual void SetProportionalScaled(bool state=true)
virtual void DrawTickers(QPainter &drawContext) const
virtual void Draw(QPainter &drawContext) const
Draw this shape using draw context.

© 2007-2017 Witold Gantzke and Kirill Lepskiy