ACF $AcfVersion:0$
CShapeBase.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
8#include <iview/IShape.h>
9#include <iview/IDisplay.h>
11
12
13namespace iview
14{
15
16
17class IColorSchema;
18
19
22 virtual public IShape
23{
24public:
26
47
49 CShapeBase(const CShapeBase& shape);
50 virtual ~CShapeBase();
51
56 virtual bool AssignToLayer(int layerType);
57
58 virtual void Invalidate();
59
64
70
76
81
85 i2d::CVector2d GetLogPosition(const i2d::CVector2d& screenPosition) const;
86
87 // reimplemented (iview::IShape)
88 virtual int GetLayerType() const override;
89 virtual i2d::CRect GetBoundingBox() const override;
90 virtual void SetVisible(bool state = true) override;
91 virtual const IColorSchema* GetUserColorSchema() const override;
92 virtual void SetUserColorSchema(const IColorSchema* schemaPtr) override;
93 virtual void SetDefaultDescription(const QString& description) override;
94 virtual void SetToolTip(const QString& toolTip) override;
95 virtual bool IsInside(const istd::CIndex2d& screenPosition) const override;
96
97 // reimplemented (iview::IVisualizable)
98 virtual bool IsVisible() const override;
99 virtual bool IsDisplayAccepted(const IDisplay& display) const override;
100 virtual void OnConnectDisplay(IDisplay* displayPtr) override;
101 virtual void OnDisconnectDisplay(IDisplay* displayPtr) override;
102 virtual bool OnDisplayChange(const istd::IChangeable::ChangeSet& changeSet) override;
103
104 // reimplemented (iview::ITouchable)
105 virtual ITouchable::TouchState IsTouched(istd::CIndex2d position) const override;
106 virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const override;
107 virtual QString GetToolTipAt(istd::CIndex2d position) const override;
108
109 // reimplemented (imod::IObserver)
110 virtual bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
111 virtual bool OnModelDetached(imod::IModel* modelPtr) override;
112 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
113
114protected:
118 double GetLocalLineWidth(const i2d::CVector2d& screenPosition) const;
119
125
132 virtual void InvalidateBoundingBox();
133
137 bool IsDisplayConnected() const;
138
144
150
151 bool IsBoundingBoxValid() const;
152
154
156
157 // abstract methods
162 virtual i2d::CRect CalcBoundingBox() const = 0;
163
164private:
169 class CalibrationObserver: public imod::TSingleModelObserverBase<i2d::ICalibration2d>
170 {
171 public:
172 explicit CalibrationObserver(CShapeBase* parentPtr);
173
174 // reimplemented (imod::CSingleModelObserverBase)
175 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
176
177 private:
178 CShapeBase* m_parentPtr = nullptr;
179 };
180
181 IDisplay* m_displayPtr = nullptr;
182
183 // calibration management
184 CalibrationObserver m_calibrationObserver;
185
186 // display meta information
187 const IColorSchema* m_userColorSchemaPtr = nullptr;
188
189 // managemant of bounding box
190 mutable bool m_isBoundingBoxValid = false;
191 mutable i2d::CRect m_boundingBox;
192
193 // attributes
194 bool m_isVisible = true;
195 int m_layerType = 0;
196 ShapeTransformMode m_shapeTransformMode;
197
198 QString m_defaultDescription;
199 QString m_defaultToolTip;
200};
201
202
203} // namespace iview
204
205
206
207
Simple rectangle with integer bounds.
Definition CRect.h:22
Definition of position or mathematical vector on 2D plane.
Definition CVector2d.h:29
Basic implementation for a single model observer.
Common interface for model objects, that supports Model/Observer design pattern.
Definition IModel.h:25
Basic implementation for a single model observer with binding to concrete data object interface.
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
Set of change flags (its IDs).
Definition IChangeable.h:36
ShapeTransformMode GetTransformMode() const
Get shape transformation mode.
CShapeBase(const CShapeBase &shape)
virtual void OnDisconnectDisplay(IDisplay *displayPtr) override
Called after display is disconnected.
virtual const iview::CScreenTransform & GetViewToScreenTransform() const
virtual bool IsDisplayAccepted(const IDisplay &display) const override
Check if this object can be connected to this display.
virtual void Invalidate()
const IColorSchema & GetColorSchema() const
Get color schema for this shape.
virtual void OnUpdate(const istd::IChangeable::ChangeSet &changeSet) override
Called on update of observed model.
bool IsDisplayConnected() const
Check if display is connected.
virtual void SetToolTip(const QString &toolTip) override
virtual bool OnModelDetached(imod::IModel *modelPtr) override
Callback invoked when an observable model is about to be detached from this observer.
virtual void SetVisible(bool state=true) override
Make shape to be visible or not.
virtual QString GetShapeDescriptionAt(istd::CIndex2d position) const override
Get description to shape at specified position.
virtual ~CShapeBase()
virtual void SetUserColorSchema(const IColorSchema *schemaPtr) override
Set color schema to draw shape.
virtual void InvalidateBoundingBox()
Invalidate bounding box.
i2d::CVector2d GetLogPosition(const i2d::CVector2d &screenPosition) const
Get logical position based on screen position.
virtual void SetDefaultDescription(const QString &description) override
Set default description will be used to display on console.
double GetLocalLineWidth(const i2d::CVector2d &screenPosition) const
Get line with (in logical coordinates) for single screen position.
virtual QString GetToolTipAt(istd::CIndex2d position) const override
Get tooltip at specified position.
virtual bool IsVisible() const override
Check, if this object is visible.
imod::CSingleModelObserverBase BaseClass
Definition CShapeBase.h:25
virtual i2d::CRect CalcBoundingBox() const =0
Calculate bounding box.
bool IsBoundingBoxValid() const
virtual ITouchable::TouchState IsTouched(istd::CIndex2d position) const override
Check, if any shape is touched.
void DisconnectDisplay()
virtual void OnConnectDisplay(IDisplay *displayPtr) override
Called after display is connected.
iview::IDisplay * GetDisplayPtr() const
Get access to currently connected display.
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.
i2d::CRect GetClientRect() const
Get display client rectangle.
virtual i2d::CRect GetBoundingBox() const override
Return bounding box in client window coordinates.
virtual int GetLayerType() const override
Get layer type of this shape object.
i2d::CVector2d GetScreenPosition(const i2d::CVector2d &logPosition) const
Get screen position based on logical position.
void SetTransformMode(ShapeTransformMode mode)
Set shape transformation mode.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
virtual const IColorSchema * GetUserColorSchema() const override
Get color schema from view or user defined.
ShapeTransformMode
Describe how shape tranformation is interpreted.
Definition CShapeBase.h:31
@ STM_SHAPE
View transformation will be ignored, shape transformation will be used.
Definition CShapeBase.h:40
@ STM_VIEW
Shape transformation will be ignored, view transformation will be used.
Definition CShapeBase.h:35
@ STM_COMBINE
Both transformation will be used, shape transformation will be used as local transformation.
Definition CShapeBase.h:45
virtual bool IsInside(const istd::CIndex2d &screenPosition) const override
virtual bool AssignToLayer(int layerType)
Assign this shape to same layer.
virtual bool OnDisplayChange(const istd::IChangeable::ChangeSet &changeSet) override
It informs about changes in display.
Defines set of standard pens, brushes and simple management of unions.
Common interface for all display console shapes.
Definition IShape.h:32
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:25
In this library is defined 2D view concept and standard visualisation objects.