ICF 3.1.1.10
Technical documentation of ICF Libraries
CShapeBase.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_CShapeBase_included
7#define iview_CShapeBase_included
8
9
10// ICF includes
14#include <iview/IShape.h>
15#include <iview/IDisplay.h>
17
18
19namespace iview
20{
21
22
23class IColorSchema;
24
25
33 virtual public IShape
34{
35public:
37
58
60 CShapeBase(const CShapeBase& shape);
61 virtual ~CShapeBase();
62
67 virtual bool AssignToLayer(int layerType);
68
69 virtual void Invalidate();
70
75
81
87
88 // reimplemented (iview::IShape)
89 int GetLayerType() const override;
90 i2d::CRect GetBoundingBox() const override;
91 void SetVisible(bool state = true) override;
92 const IColorSchema* GetUserColorSchema() const override;
93 void SetUserColorSchema(const IColorSchema* schemaPtr) override;
94 void SetDefaultDescription(const QString& description) override;
95
96 // reimplemented (iview::IVisualizable)
97 bool IsVisible() const override;
98 bool IsDisplayAccepted(const IDisplay& display) const override;
99 void OnDisplayConnected(IDisplay* displayPtr) override;
100 void OnDisplayDisconnected(IDisplay* displayPtr) override;
101 bool OnDisplayChanged(const istd::IChangeable::ChangeSet& changeSet) override;
102
103 // reimplemented (iview::ITouchable)
105 QString GetShapeDescriptionAt(istd::CIndex2d position) const override;
106
107 // reimplemented (imod::IObserver)
108 bool OnModelAttached(imod::IModel* modelPtr, istd::IChangeable::ChangeSet& changeMask) override;
109 bool OnModelDetached(imod::IModel* modelPtr) override;
110 void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
111
112protected:
120 i2d::CVector2d GetLogPosition(const i2d::CVector2d& screenPosition) const;
124 double GetLocalLineWidth(const i2d::CVector2d& screenPosition) const;
125
131
138 virtual void InvalidateBoundingBox();
139
143 bool IsDisplayConnected() const;
144
150
156
157 bool IsBoundingBoxValid() const;
158
160
162
163 // abstract methods
168 virtual i2d::CRect CalcBoundingBox() const = 0;
169
170private:
175 class CalibrationObserver: public imod::TSingleModelObserverBase<i2d::ICalibration2d>
176 {
177 public:
178 explicit CalibrationObserver(CShapeBase* parentPtr);
179
180 // reimplemented (imod::CSingleModelObserverBase)
181 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet);
182
183 private:
184 CShapeBase* m_parentPtr;
185 };
186
187 IDisplay* m_displayPtr;
188
189 // calibration management
190 CalibrationObserver m_calibrationObserver;
191
192 // display meta information
193 const IColorSchema* m_userColorSchemaPtr;
194
195 // management of bounding box
196 mutable bool m_isBoundingBoxValid;
197 mutable i2d::CRect m_boundingBox;
198
199 mutable bool m_hasPendingChanges; // True, if current shape was changed and this should be signalized to display
200
201 // attributes
202 bool m_isVisible;
203 int m_layerType;
204 ShapeTransformMode m_shapeTransformMode;
205
206 istd::CMainThreadCaller m_updateGuiCaller;
207
208 QString m_defaultDescription;
209};
210
211
212} // namespace iview
213
214
215#endif // !iview_CShapeBase_included
216
217
Simple rectangle with integer bounds.
Definition CRect.h:26
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:29
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:25
Call some function in main application thread.
Set of change flags (its IDs).
Definition IChangeable.h:38
Base class of standard shape implementation.
Definition CShapeBase.h:34
ShapeTransformMode GetTransformMode() const
Get shape transformation mode.
bool OnModelDetached(imod::IModel *modelPtr) override
This call back function will be called, if an observable object is about to be detached.
CShapeBase(const CShapeBase &shape)
virtual const iview::CScreenTransform & GetViewToScreenTransform() const
bool OnDisplayChanged(const istd::IChangeable::ChangeSet &changeSet) override
It informs about changes in display.
void OnDisplayConnected(IDisplay *displayPtr) override
Called after display is connected.
virtual void Invalidate()
void SetDefaultDescription(const QString &description) override
Set default description will be used to display on console.
const IColorSchema & GetColorSchema() const
Get color schema for this shape.
void SetVisible(bool state=true) override
Make shape to be visible or not.
ITouchable::TouchState IsTouched(istd::CIndex2d position) const override
Check, if any shape is touched.
bool IsDisplayConnected() const
Check if display is connected.
i2d::CRect GetBoundingBox() const override
Return bounding box in client window coordinates.
QString GetShapeDescriptionAt(istd::CIndex2d position) const override
Get description to shape at specified position.
bool IsDisplayAccepted(const IDisplay &display) const override
Check if this object can be connected to this display.
imod::CSingleModelObserverBase BaseClass
Definition CShapeBase.h:36
virtual ~CShapeBase()
virtual void InvalidateBoundingBox()
Invalidate bounding box.
i2d::CVector2d GetLogPosition(const i2d::CVector2d &screenPosition) const
Get logical position based on screen position.
double GetLocalLineWidth(const i2d::CVector2d &screenPosition) const
Get line with (in logical coordinates) for single screen position.
virtual i2d::CRect CalcBoundingBox() const =0
Calculate bounding box.
bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
This call back function will be called, if an observable object is about to be attached.
bool IsBoundingBoxValid() const
void DisconnectDisplay()
iview::IDisplay * GetDisplay() const
Get access to currently connected display.
bool IsVisible() const override
Check, if this object is visible.
i2d::CRect GetClientRect() const
Get display client rectangle.
i2d::CVector2d GetScreenPosition(const i2d::CVector2d &logPosition) const
Get screen position based on logical position.
void SetTransformMode(ShapeTransformMode mode)
Set shape transformation mode.
const IColorSchema * GetUserColorSchema() const override
Get color schema from view or user defined.
void OnDisplayDisconnected(IDisplay *displayPtr) override
Called after display is disconnected.
int GetLayerType() const override
Get layer type of this shape object.
virtual bool IsDisplayChangeImportant(const istd::IChangeable::ChangeSet &changeSet)
Get display changes mask.
ShapeTransformMode
Describe how shape tranformation is interpreted.
Definition CShapeBase.h:42
@ STM_SHAPE
View transformation will be ignored, shape transformation will be used.
Definition CShapeBase.h:51
@ STM_VIEW
Shape transformation will be ignored, view transformation will be used.
Definition CShapeBase.h:46
@ STM_COMBINE
Both transformation will be used, shape transformation will be used as local transformation.
Definition CShapeBase.h:56
void OnUpdate(const istd::IChangeable::ChangeSet &changeSet) override
Called on update of observed model.
virtual bool AssignToLayer(int layerType)
Assign this shape to same layer.
void SetUserColorSchema(const IColorSchema *schemaPtr) override
Set color schema to draw shape.
Defines set of standard pens, brushes and simple management of unions.
Common interface for all display console shapes.
Definition IShape.h:37
TouchState
Enumeration for possible shape touch states.
Definition ITouchable.h:30
In this library is defined 2D view concept and standard visualisation objects.

© Witold Gantzke and Kirill Lepskiy