ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
iview::CShapeBase Class Referenceabstract

#include <CShapeBase.h>

Inheritance diagram for iview::CShapeBase:
imod::CSingleModelObserverBase iview::IShape imod::IObserver imod::IObserver iview::IVisualizable iview::ITouchable istd::IPolymorphic istd::IPolymorphic istd::IPolymorphic istd::IPolymorphic iview::CDistanceToolShape iview::CImageShape iview::CInteractiveShapeBase iview::CPolypointShape iqtgui::TGuiObserverWrap< CViewProviderGuiComp, iview::CImageShape > iview::CAffineTransformation2dShape iview::CLineShape iview::CParallelogramShape iview::CPinShape iview::CRectControlledShapeBase iview::CRectangleShape iqt2d::CImageViewComp iview::CAnnulusShape iview::CArcShape iview::CCenterPinShape iview::CCircleShape iview::CLabelShape iview::CStarShape iview::CGraphPlotShape iview::CPolygonShape

Public Types

enum  ShapeTransformMode { STM_VIEW , STM_SHAPE , STM_COMBINE }
 Describe how shape tranformation is interpreted. More...
 
typedef imod::CSingleModelObserverBase BaseClass
 
- Public Types inherited from imod::CSingleModelObserverBase
typedef imod::IModel ModelType
 
- Public Types inherited from iview::IShape
enum  ChangeFlags { CF_CALIB = 0x3663adf }
 Data model change notification flags. More...
 
- Public Types inherited from iview::ITouchable
enum  TouchState {
  TS_NONE , TS_INACTIVE , TS_TICKER , TS_DRAGGABLE ,
  TS_AREA , TS_OTHER , TS_LAST = TS_OTHER
}
 Enumeration for possible shape touch states. More...
 

Public Member Functions

 CShapeBase ()
 
 CShapeBase (const CShapeBase &shape)
 
virtual ~CShapeBase ()
 
virtual bool AssignToLayer (int layerType)
 Assign this shape to same layer.
 
virtual void Invalidate ()
 
iview::IDisplayGetDisplayPtr () const
 Get access to currently connected display.
 
ShapeTransformMode GetTransformMode () const
 Get shape transformation mode.
 
void SetTransformMode (ShapeTransformMode mode)
 Set shape transformation mode.
 
i2d::CVector2d GetScreenPosition (const i2d::CVector2d &logPosition) const
 Get screen position based on logical position.
 
i2d::CVector2d GetLogPosition (const i2d::CVector2d &screenPosition) const
 Get logical position based on screen position.
 
virtual int GetLayerType () const override
 Get layer type of this shape object.
 
virtual i2d::CRect GetBoundingBox () const override
 Return bounding box in client window coordinates.
 
virtual void SetVisible (bool state=true) override
 Make shape to be visible or not.
 
virtual const IColorSchemaGetUserColorSchema () const override
 Get color schema from view or user defined.
 
virtual void SetUserColorSchema (const IColorSchema *schemaPtr) override
 Set color schema to draw shape.
 
virtual void SetDefaultDescription (const QString &description) override
 Set default description will be used to display on console.
 
virtual void SetToolTip (const QString &toolTip) override
 
virtual bool IsInside (const istd::CIndex2d &screenPosition) const override
 
virtual bool IsVisible () const override
 Check, if this object is visible.
 
virtual bool IsDisplayAccepted (const IDisplay &display) const override
 Check if this object can be connected to this display.
 
virtual void OnConnectDisplay (IDisplay *displayPtr) override
 Called after display is connected.
 
virtual void OnDisconnectDisplay (IDisplay *displayPtr) override
 Called after display is disconnected.
 
virtual bool OnDisplayChange (const istd::IChangeable::ChangeSet &changeSet) override
 It informs about changes in display.
 
virtual ITouchable::TouchState IsTouched (istd::CIndex2d position) const override
 Check, if any shape is touched.
 
virtual QString GetShapeDescriptionAt (istd::CIndex2d position) const override
 Get description to shape at specified position.
 
virtual QString GetToolTipAt (istd::CIndex2d position) const override
 Get tooltip at specified position.
 
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 OnModelDetached (imod::IModel *modelPtr) override
 Callback invoked when an observable model is about to be detached from this observer.
 
virtual void OnUpdate (const istd::IChangeable::ChangeSet &changeSet) override
 Called on update of observed model.
 
- Public Member Functions inherited from imod::CSingleModelObserverBase
 CSingleModelObserverBase ()
 
virtual ~CSingleModelObserverBase ()
 
imod::IModelGetObservedModel () const
 Get access to observed model.
 
imod::IModelGetModelPtr () const
 Get access to observed model.
 
void EnsureModelDetached ()
 Make sure this observer is detached.
 
void SetObservedIds (const istd::IChangeable::ChangeSet &changeMask)
 Set list of ID's beeing observed.
 
virtual bool IsModelAttached (const imod::IModel *modelPtr=NULL) const override
 Checks if the specified model is currently attached to this observer.
 
virtual void BeforeUpdate (imod::IModel *modelPtr) override
 Callback invoked before an update of the observer's content occurs.
 
virtual void AfterUpdate (imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
 Callback invoked after an update of the observer's content occurs.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 
- Public Member Functions inherited from iview::IShape
virtual bool IsAreaTouchAllowed () const
 
virtual void SetAreaTouchAllowed (bool=true)
 
virtual iview::ISelectable::MousePointerMode UpdateMousePointer (iview::ISelectable::MousePointerMode defaultPointer, ITouchable::TouchState, const istd::CIndex2d &) const
 
- Public Member Functions inherited from iview::IVisualizable
virtual void Draw (QPainter &drawContext) const =0
 Draw this shape using draw context.
 

Protected Member Functions

double GetLocalLineWidth (const i2d::CVector2d &screenPosition) const
 Get line with (in logical coordinates) for single screen position.
 
virtual bool IsDisplayChangeImportant (const istd::IChangeable::ChangeSet &changeSet)
 Get display changes mask.
 
virtual void InvalidateBoundingBox ()
 Invalidate bounding box.
 
bool IsDisplayConnected () const
 Check if display is connected.
 
const IColorSchemaGetColorSchema () const
 Get color schema for this shape.
 
i2d::CRect GetClientRect () const
 Get display client rectangle.
 
bool IsBoundingBoxValid () const
 
void DisconnectDisplay ()
 
virtual const iview::CScreenTransformGetViewToScreenTransform () const
 
virtual i2d::CRect CalcBoundingBox () const =0
 Calculate bounding box.
 
- Protected Member Functions inherited from imod::CSingleModelObserverBase
void SetModelPtr (imod::IModel *modelPtr)
 Set internal model pointer to specified value.
 

Additional Inherited Members

- Static Protected Attributes inherited from imod::CSingleModelObserverBase
static const istd::IChangeable::ChangeSet s_undoChanges
 

Detailed Description

Definition at line 20 of file CShapeBase.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 25 of file CShapeBase.h.

Member Enumeration Documentation

◆ ShapeTransformMode

Describe how shape tranformation is interpreted.

Enumerator
STM_VIEW 

Shape transformation will be ignored, view transformation will be used.

STM_SHAPE 

View transformation will be ignored, shape transformation will be used.

STM_COMBINE 

Both transformation will be used, shape transformation will be used as local transformation.

Definition at line 30 of file CShapeBase.h.

Constructor & Destructor Documentation

◆ CShapeBase() [1/2]

iview::CShapeBase::CShapeBase ( )

◆ CShapeBase() [2/2]

iview::CShapeBase::CShapeBase ( const CShapeBase shape)

◆ ~CShapeBase()

virtual iview::CShapeBase::~CShapeBase ( )
virtual

Member Function Documentation

◆ AssignToLayer()

virtual bool iview::CShapeBase::AssignToLayer ( int  layerType)
virtual

◆ CalcBoundingBox()

virtual i2d::CRect iview::CShapeBase::CalcBoundingBox ( ) const
protectedpure virtual

◆ DisconnectDisplay()

void iview::CShapeBase::DisconnectDisplay ( )
protected

◆ GetBoundingBox()

virtual i2d::CRect iview::CShapeBase::GetBoundingBox ( ) const
overridevirtual

Return bounding box in client window coordinates.

You can store this bounding box for optimization, because about every change of transformation you will be informed by calling OnDisplayChange(int) method.

Implements iview::IShape.

◆ GetClientRect()

i2d::CRect iview::CShapeBase::GetClientRect ( ) const
protected

Get display client rectangle.

It can be called only when display is connected

See also
IsDisplayConnected().

◆ GetColorSchema()

const IColorSchema & iview::CShapeBase::GetColorSchema ( ) const
protected

Get color schema for this shape.

It can be called only when display is connected

See also
IsDisplayConnected().

◆ GetDisplayPtr()

iview::IDisplay * iview::CShapeBase::GetDisplayPtr ( ) const

◆ GetLayerType()

virtual int iview::CShapeBase::GetLayerType ( ) const
overridevirtual

Get layer type of this shape object.

See also
IViewLayer::LayerType

Implements iview::IShape.

◆ GetLocalLineWidth()

double iview::CShapeBase::GetLocalLineWidth ( const i2d::CVector2d screenPosition) const
protected

Get line with (in logical coordinates) for single screen position.

◆ GetLogPosition()

i2d::CVector2d iview::CShapeBase::GetLogPosition ( const i2d::CVector2d screenPosition) const
virtual

Get logical position based on screen position.

Implements iview::IShape.

◆ GetScreenPosition()

i2d::CVector2d iview::CShapeBase::GetScreenPosition ( const i2d::CVector2d logPosition) const

Get screen position based on logical position.

◆ GetShapeDescriptionAt()

virtual QString iview::CShapeBase::GetShapeDescriptionAt ( istd::CIndex2d  position) const
overridevirtual

Get description to shape at specified position.

Implements iview::ITouchable.

Reimplemented in iview::CImageShape, iview::CPolygonShape, and iview::CPolylineShape.

◆ GetToolTipAt()

virtual QString iview::CShapeBase::GetToolTipAt ( istd::CIndex2d  position) const
overridevirtual

Get tooltip at specified position.

Implements iview::ITouchable.

◆ GetTransformMode()

ShapeTransformMode iview::CShapeBase::GetTransformMode ( ) const

Get shape transformation mode.

This mode describes which transformation will be used to display shape.

◆ GetUserColorSchema()

virtual const IColorSchema * iview::CShapeBase::GetUserColorSchema ( ) const
overridevirtual

Get color schema from view or user defined.

Implements iview::IShape.

◆ GetViewToScreenTransform()

virtual const iview::CScreenTransform & iview::CShapeBase::GetViewToScreenTransform ( ) const
protectedvirtual

◆ Invalidate()

virtual void iview::CShapeBase::Invalidate ( )
virtual

◆ InvalidateBoundingBox()

virtual void iview::CShapeBase::InvalidateBoundingBox ( )
protectedvirtual

Invalidate bounding box.

You can overload this method to provide validation of your internal attributes, because this method is called from Invalidate and OnDisplayChange methods. Please don't forget base method call in your implementations.

Reimplemented in iview::CLineShape, iview::CParallelogramShape, iview::CRectangleShape, and iview::CRectControlledShapeBase.

◆ IsBoundingBoxValid()

bool iview::CShapeBase::IsBoundingBoxValid ( ) const
protected

◆ IsDisplayAccepted()

virtual bool iview::CShapeBase::IsDisplayAccepted ( const IDisplay display) const
overridevirtual

Check if this object can be connected to this display.

Implements iview::IVisualizable.

◆ IsDisplayChangeImportant()

virtual bool iview::CShapeBase::IsDisplayChangeImportant ( const istd::IChangeable::ChangeSet changeSet)
protectedvirtual

Get display changes mask.

Only changes there are in mask will be accepted, rest will be ignored.

Reimplemented in iview::CInteractiveShapeBase.

Referenced by iview::CInteractiveShapeBase::IsDisplayChangeImportant().

◆ IsDisplayConnected()

bool iview::CShapeBase::IsDisplayConnected ( ) const
protected

Check if display is connected.

◆ IsInside()

virtual bool iview::CShapeBase::IsInside ( const istd::CIndex2d screenPosition) const
overridevirtual

Implements iview::IShape.

Reimplemented in iview::CPolygonShape.

◆ IsTouched()

virtual ITouchable::TouchState iview::CShapeBase::IsTouched ( istd::CIndex2d  position) const
overridevirtual

◆ IsVisible()

virtual bool iview::CShapeBase::IsVisible ( ) const
overridevirtual

Check, if this object is visible.

Implements iview::IVisualizable.

◆ OnConnectDisplay()

virtual void iview::CShapeBase::OnConnectDisplay ( IDisplay displayPtr)
overridevirtual

Called after display is connected.

It can be called only, when display is accepted (

See also
IsDisplayAccepted()).
Parameters
displayPtran observer object, which should be informed about all shape changes.

Implements iview::IVisualizable.

◆ OnDisconnectDisplay()

virtual void iview::CShapeBase::OnDisconnectDisplay ( IDisplay displayPtr)
overridevirtual

Called after display is disconnected.

Note, that this display must be previously connected.

Parameters
displayPtra disconnected observer object.

Implements iview::IVisualizable.

◆ OnDisplayChange()

virtual bool iview::CShapeBase::OnDisplayChange ( const istd::IChangeable::ChangeSet changeSet)
overridevirtual

It informs about changes in display.

It is called e.g. after view transformation change.

Returns
true, if this change follow shape changes.

Implements iview::IVisualizable.

◆ OnModelAttached()

virtual bool iview::CShapeBase::OnModelAttached ( imod::IModel modelPtr,
istd::IChangeable::ChangeSet changeMask 
)
overridevirtual

Callback invoked when an observable model is about to be attached to this observer.

This method is called by the model when attempting to establish an observer relationship. The implementation should:

  1. Validate that the model is of an acceptable type
  2. Set the changeMask to specify which changes to monitor
  3. Return true to accept the attachment, or false to reject it
Parameters
modelPtrPointer to the model object being attached. Never nullptr.
changeMaskOutput parameter where the observer specifies which change types it wants to be notified about. Set the appropriate change flags using changeMask.Set(changeId). An empty mask means the observer wants all changes.
Returns
true if the model is accepted and attachment succeeds, false to reject the attachment (e.g., if the model is of incompatible type).
Note
After successful attachment, the observer should initialize its state based on the current model data.
The changeMask allows filtering notifications for better performance. Only changes matching the mask will trigger AfterUpdate() calls.
virtual bool OnModelAttached(IModel* modelPtr,
{
// Type check
CMyModel* model = dynamic_cast<CMyModel*>(modelPtr);
if (!model) return false;
// Set up change filtering
changeMask.Set(CMyModel::CF_DATA_CHANGED);
changeMask.Set(CMyModel::CF_STATUS_CHANGED);
// Don't set CF_INTERNAL_CHANGED - we don't care about those
// Initialize view from current model state
UpdateViewFromModel(model);
return true;
}
Set of change flags (its IDs).
Definition IChangeable.h:36
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.
See also
OnModelDetached(), IsModelAttached(), AfterUpdate()

Reimplemented from imod::CSingleModelObserverBase.

Reimplemented in iqtgui::TGuiObserverWrap< CViewProviderGuiComp, iview::CImageShape >, iview::CAffineTransformation2dShape, iview::CAnnulusSegmentShape, iview::CAnnulusShape, iview::CArcShape, iview::CCircleShape, iview::CDistanceToolShape, iview::CGraphPlotShape, iview::CImageShape, iview::CInteractiveShapeBase, iview::CLabelShape, iview::CLineShape, iview::COrientedCircleShape, iview::CParallelogramShape, iview::CPinShape, iview::CPolygonShape, iview::CPolylineShape, iview::CPolypointShape, iview::CRectangleShape, and iview::CSplineShape.

◆ OnModelDetached()

virtual bool iview::CShapeBase::OnModelDetached ( imod::IModel modelPtr)
overridevirtual

Callback invoked when an observable model is about to be detached from this observer.

This method is called when the observer-model relationship is being terminated, either explicitly or because the model is being destroyed. The implementation should clean up any state or resources related to this model.

Parameters
modelPtrPointer to the model object being detached
Returns
true if the detachment was handled successfully, false otherwise
Note
After this call, the observer should not access the model pointer anymore.
This method may be called even if OnModelAttached() previously returned false.
Clean up any cached data or references to this model.
virtual bool OnModelDetached(IModel* modelPtr)
{
if (m_currentModel == modelPtr) {
// Clear any cached data
m_cachedData.clear();
m_currentModel = nullptr;
// Update UI to show no model is attached
ClearDisplay();
return true;
}
return false;
}
virtual bool OnModelDetached(imod::IModel *modelPtr) override
Callback invoked when an observable model is about to be detached from this observer.
See also
OnModelAttached(), IsModelAttached()

Reimplemented from imod::CSingleModelObserverBase.

Reimplemented in iqtgui::TGuiObserverWrap< CViewProviderGuiComp, iview::CImageShape >, and iview::CInteractiveShapeBase.

◆ OnUpdate()

virtual void iview::CShapeBase::OnUpdate ( const istd::IChangeable::ChangeSet changeSet)
overridevirtual

Called on update of observed model.

This method is designed to be overload by derrived classes.

Reimplemented from imod::CSingleModelObserverBase.

◆ SetDefaultDescription()

virtual void iview::CShapeBase::SetDefaultDescription ( const QString &  description)
overridevirtual

Set default description will be used to display on console.

Implements iview::IShape.

Referenced by iqt2d::TShapeParamsGuiCompBase< Ui, Shape, ShapeModel >::CreateShape().

◆ SetToolTip()

virtual void iview::CShapeBase::SetToolTip ( const QString &  toolTip)
overridevirtual

Implements iview::IShape.

◆ SetTransformMode()

void iview::CShapeBase::SetTransformMode ( ShapeTransformMode  mode)

Set shape transformation mode.

This mode describes which transformation will be used to display shape.

◆ SetUserColorSchema()

virtual void iview::CShapeBase::SetUserColorSchema ( const IColorSchema schemaPtr)
overridevirtual

Set color schema to draw shape.

Implements iview::IShape.

Referenced by iqt2d::TShapeParamsGuiCompBase< Ui, Shape, ShapeModel >::CreateShape().

◆ SetVisible()

virtual void iview::CShapeBase::SetVisible ( bool  state = true)
overridevirtual

Make shape to be visible or not.

Implements iview::IShape.

Referenced by iqt2d::TShapeParamsGuiCompBase< Ui, Shape, ShapeModel >::CreateShape().


The documentation for this class was generated from the following file: