CInteractiveShapeBase.h
Go to the documentation of this file.
1 #ifndef iview_CInteractiveShapeBase_included
2 #define iview_CInteractiveShapeBase_included
3 
4 
5 // ACF includes
6 #include <istd/CChangeGroup.h>
7 #include <istd/TDelPtr.h>
8 #include <imod/IModel.h>
10 #include <iview/IDraggable.h>
11 #include <iview/ISelectable.h>
12 #include <iview/CShapeBase.h>
13 
14 // Qt includes
15 #include <QtGui/QPen>
16 
17 
18 namespace iview
19 {
20 
21 
23  public CShapeBase,
24  virtual public IInteractiveShape,
25  virtual public IDraggable
26 {
27 public:
29 
32 
33  virtual ~CInteractiveShapeBase();
34 
35  virtual bool IsEditablePosition() const;
36  virtual void SetEditablePosition(bool state = true);
37 
38  // reimplemented (iview::IInteractiveShape)
39  virtual bool IsSelected() const;
40  virtual void SetSelected(bool selectFlag = true);
41 
42  // reimplemented (iview::IMouseActionObserver)
43  virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
44  virtual bool OnMouseMove(istd::CIndex2d position);
45 
46  // reimplemented (iview::IDraggable)
47  virtual bool IsDraggable() const;
48  virtual void BeginDrag(const istd::CIndex2d& position);
49  virtual void SetDragPosition(const istd::CIndex2d& position);
50  virtual void EndDrag();
51 
52  // reimplemented (imod::IObserver)
53  virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
54  virtual bool OnModelDetached(imod::IModel* modelPtr);
55 
56 protected:
57  void BeginTickerDrag();
58  void EndTickerDrag();
59  void UpdateModelChanges();
60 
65  int GetKeysState() const;
66 
71  int GetEditMode() const;
72 
76  void DrawText(QPainter& drawContext, istd::CIndex2d point, const QString& text) const;
77 
78  // reimplemented (iview::CShapeBase)
79  virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet& changeSet);
80 
81  // abstract methods
82  virtual void BeginLogDrag(const i2d::CVector2d& reference) = 0;
83  virtual void SetLogDragPosition(const i2d::CVector2d& position) = 0;
84 
85 private:
86  bool m_isSelected;
87  bool m_isEditablePosition;
88 
89  istd::TDelPtr<istd::CChangeGroup> m_dragNotifierPtr;
90 };
91 
92 
93 // inline methods
94 
96 {
97  return m_isEditablePosition;
98 }
99 
100 
102 {
103  m_isEditablePosition = state;
104 }
105 
106 
107 // protected methods
108 
110 {
111  ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplayPtr());
112  if (selectablePtr != NULL){
113  return selectablePtr->GetKeysState();
114  }
115  else{
116  return 0;
117  }
118 }
119 
120 
122 {
123  ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplayPtr());
124  if (selectablePtr != NULL){
125  return selectablePtr->GetEditMode();
126  }
127  else{
128  return ISelectable::EM_NONE;
129  }
130 }
131 
132 
133 // reimplemented (iview::CShapeBase)
134 
136 {
138 }
139 
140 
141 } // namespace iview
142 
143 
144 #endif // !iview_CInteractiveShapeBase_included
145 
146 
virtual bool IsEditablePosition() const
virtual void SetSelected(bool selectFlag=true)
Inform that this object was selected or deselected.
virtual void SetEditablePosition(bool state=true)
virtual int GetKeysState() const =0
Get state of system keys.
virtual void SetDragPosition(const istd::CIndex2d &position)
Set new drag position.
Edit mode is changed.
Definition: IDisplay.h:44
virtual bool OnModelDetached(imod::IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
virtual bool OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
virtual bool IsDraggable() const
Check if drag is enabled.
Common interface for all display console shapes which can interacts with user.
virtual void SetLogDragPosition(const i2d::CVector2d &position)=0
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
int GetEditMode() const
Get actual edit mode.
virtual void EndDrag()
Called after dragging.
Common interface for all, you can drag.
Definition: IDraggable.h:17
void DrawText(QPainter &drawContext, istd::CIndex2d point, const QString &text) const
Draw text on a given position.
virtual int GetEditMode() const =0
Get actual edit mode.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
virtual bool IsSelected() const
Check, if this shape is selected.
iview::IDisplay * GetDisplayPtr() const
Get access to currently connected display.
#define NULL
Definition: istd.h:64
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
virtual void BeginDrag(const istd::CIndex2d &position)
Called before dragging is begin.
bool Contains(int changeId) const
Check if there is specific change flag in the set.
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 void BeginLogDrag(const i2d::CVector2d &reference)=0
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
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.
int GetKeysState() const
Get actual keys state.

© 2007-2017 Witold Gantzke and Kirill Lepskiy