ACF $AcfVersion:0$
CInteractiveShapeBase.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
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
18namespace iview
19{
20
21
23 public CShapeBase,
24 virtual public IInteractiveShape,
25 virtual public IDraggable
26{
27public:
29
32
34
35 virtual bool IsEditablePosition() const;
36 virtual void SetEditablePosition(bool state = true);
37
38 // reimplemented (iview::IInteractiveShape)
39 virtual bool IsSelected() const override;
40 virtual void SetSelected(bool selectFlag = true) override;
41
42 // reimplemented (iview::IMouseActionObserver)
43 virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override;
44 virtual bool OnMouseMove(istd::CIndex2d position) override;
45
46 // reimplemented (iview::IDraggable)
47 virtual bool IsDraggable() const override;
48 virtual void BeginDrag(const istd::CIndex2d& position) override;
49 virtual void SetDragPosition(const istd::CIndex2d& position) override;
50 virtual void EndDrag() override;
51
52 // reimplemented (imod::IObserver)
53 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
54 virtual bool OnModelDetached(imod::IModel* modelPtr) override;
55
56protected:
60
65 int GetKeysState() const;
66
71 int GetEditMode() const;
72
77 int GetDisplayMode() const;
78
82 void DrawText(QPainter& drawContext, istd::CIndex2d point, const QString& text) const;
83
84 // reimplemented (iview::CShapeBase)
85 virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet& changeSet) override;
86
87 // abstract methods
88 virtual void BeginLogDrag(const i2d::CVector2d& reference) = 0;
89 virtual void SetLogDragPosition(const i2d::CVector2d& position) = 0;
90
91private:
92 bool m_isSelected;
93 bool m_isEditablePosition;
94
95 istd::TDelPtr<istd::CChangeGroup> m_dragNotifierPtr;
96};
97
98
99// inline methods
100
102{
103 return m_isEditablePosition;
104}
105
106
108{
109 m_isEditablePosition = state;
110}
111
112
113// protected methods
114
116{
117 ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplayPtr());
118 if (selectablePtr != NULL){
119 return selectablePtr->GetKeysState();
120 }
121 else{
122 return 0;
123 }
124}
125
126
128{
129 ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplayPtr());
130 if (selectablePtr != NULL){
131 return selectablePtr->GetEditMode();
132 }
133 else{
135 }
136}
137
138
140{
141 ISelectable* selectablePtr = dynamic_cast<ISelectable*>(GetDisplayPtr());
142 if (selectablePtr != NULL) {
143 return selectablePtr->GetDisplayMode();
144 }
145 else {
147 }
148}
149
150
151// reimplemented (iview::CShapeBase)
152
157
158
159} // namespace iview
160
161
162
163
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:25
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
Set of change flags (its IDs).
Definition IChangeable.h:36
bool Contains(int changeId) const
Check if there is specific change flag in the set.
Pointer wrapper providing automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
Callback invoked when an observable model is about to be attached to this observer.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet) override
Get display changes mask.
virtual void EndDrag() override
Called after dragging.
virtual bool OnMouseButton(istd::CIndex2d position, Qt::MouseButton buttonType, bool downFlag) override
It is called, when mouse button is pushed down or up on this object.
virtual void BeginLogDrag(const i2d::CVector2d &reference)=0
virtual bool IsSelected() const override
Check, if this shape is selected.
virtual void SetLogDragPosition(const i2d::CVector2d &position)=0
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 override
Check if drag is enabled.
virtual void SetEditablePosition(bool state=true)
virtual void BeginDrag(const istd::CIndex2d &position) override
Called before dragging is begin.
virtual bool OnMouseMove(istd::CIndex2d position) override
It is called, when mouse is moved.
int GetDisplayMode() const
Get actual display mode.
virtual bool IsEditablePosition() const
virtual bool OnModelDetached(imod::IModel *modelPtr) override
Callback invoked when an observable model is about to be detached from this observer.
virtual void SetDragPosition(const istd::CIndex2d &position) override
Set new drag position.
int GetKeysState() const
Get actual keys state.
virtual void SetSelected(bool selectFlag=true) override
Inform that this object was selected or deselected.
CInteractiveShapeBase(const CInteractiveShapeBase &shape)
iview::IDisplay * GetDisplayPtr() const
Get access to currently connected display.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
@ CF_DISPLAY_MODE
Display mode is changed.
Definition IDisplay.h:49
@ CF_EDIT_MODE
Edit mode is changed.
Definition IDisplay.h:44
Common interface for all, you can drag.
Definition IDraggable.h:18
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.
virtual int GetDisplayMode() const =0
Get actual display mode.
#define NULL
Definition istd.h:74
In this library is defined 2D view concept and standard visualisation objects.