ICF 3.1.1.10
Technical documentation of ICF Libraries
CInteractiveShapeBase.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iview_CInteractiveShapeBase_included
7#define iview_CInteractiveShapeBase_included
8
9
10// ICF includes
11#include <istd/CChangeGroup.h>
12#include <imod/IModel.h>
14#include <iview/IDraggable.h>
15#include <iview/ISelectable.h>
16#include <iview/CShapeBase.h>
17
18// Qt includes
19#include <QtGui/QPen>
20
21
22namespace iview
23{
24
25
31 public CShapeBase,
32 virtual public IInteractiveShape,
33 virtual public IDraggable
34{
35public:
37
40
42
43 virtual bool IsEditablePosition() const;
44 virtual void SetEditablePosition(bool state = true);
45
46 // reimplemented (iview::IInteractiveShape)
47 virtual bool IsSelected() const;
48 virtual void SetSelected(bool selectFlag = true);
49
50 // reimplemented (iview::IMouseActionObserver)
51 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag);
52 virtual bool OnMouseMove(istd::CIndex2d position);
53
54 // reimplemented (iview::IDraggable)
55 virtual bool IsDraggable() const;
56 virtual void BeginDrag(const istd::CIndex2d& position);
57 virtual void SetDragPosition(const istd::CIndex2d& position);
58 virtual void EndDrag();
59
60 // reimplemented (imod::IObserver)
61 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask);
62 virtual bool OnModelDetached(imod::IModel* modelPtr);
63
64protected:
68
73 int GetKeysState() const;
74
79 int GetEditMode() const;
80
84 void DrawText(QPainter& drawContext, istd::CIndex2d point, const QString& text) const;
85
86 // reimplemented (iview::CShapeBase)
87 virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet& changeSet);
88
89 // abstract methods
90 virtual void BeginLogDrag(const i2d::CVector2d& reference) = 0;
91 virtual void SetLogDragPosition(const i2d::CVector2d& position) = 0;
92
93private:
94 bool m_isSelected;
95 bool m_isEditablePosition;
96
97 std::unique_ptr<istd::CChangeGroup> m_dragNotifierPtr;
98};
99
100
101// inline methods
102
104{
105 return m_isEditablePosition;
106}
107
108
110{
111 m_isEditablePosition = state;
112}
113
114
115// protected methods
116
118{
119 ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplay());
120 if (selectablePtr != nullptr){
121 return selectablePtr->GetKeysState();
122 }
123 else{
124 return 0;
125 }
126}
127
128
130{
131 ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplay());
132 if (selectablePtr != nullptr){
133 return selectablePtr->GetEditMode();
134 }
135 else{
137 }
138}
139
140
141// reimplemented (iview::CShapeBase)
142
147
148
149} // namespace iview
150
151
152#endif // !iview_CInteractiveShapeBase_included
153
154
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:29
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:25
Set of change flags (its IDs).
Definition IChangeable.h:38
bool Contains(int changeId) const
Check if there is specific change flag in the set.
Base class of shape implementation with user interaction.
virtual void BeginDrag(const istd::CIndex2d &position)
Called before dragging is begin.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
virtual void BeginLogDrag(const i2d::CVector2d &reference)=0
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 OnMouseMove(istd::CIndex2d position)
It is called, when mouse is moved.
virtual void SetLogDragPosition(const i2d::CVector2d &position)=0
virtual bool OnModelDetached(imod::IModel *modelPtr)
This call back function will be called, if an observable object is about to be detached.
int GetEditMode() const
Get actual edit mode.
void DrawText(QPainter &drawContext, istd::CIndex2d point, const QString &text) const
Draw text on a given position.
virtual bool IsDraggable() const
Check if drag is enabled.
virtual void SetEditablePosition(bool state=true)
virtual bool IsEditablePosition() 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.
int GetKeysState() const
Get actual keys state.
virtual bool IsSelected() const
Check, if this shape is selected.
virtual void EndDrag()
Called after dragging.
virtual void SetSelected(bool selectFlag=true)
Inform that this object was selected or deselected.
virtual void SetDragPosition(const istd::CIndex2d &position)
Set new drag position.
CInteractiveShapeBase(const CInteractiveShapeBase &shape)
Base class of standard shape implementation.
Definition CShapeBase.h:34
iview::IDisplay * GetDisplay() const
Get access to currently connected display.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
@ CF_EDIT_MODE
Edit mode is changed.
Definition IDisplay.h:49
Common interface for all, you can drag.
Definition IDraggable.h:23
Common interface for all display console shapes which can interacts with user.
virtual int GetKeysState() const =0
Get state of system keys.
virtual int GetEditMode() const =0
Get actual edit mode.
In this library is defined 2D view concept and standard visualisation objects.

© Witold Gantzke and Kirill Lepskiy