ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
iqt2d::CSelectableSceneExtenderComp Class Reference

#include <CSelectableSceneExtenderComp.h>

Inheritance diagram for iqt2d::CSelectableSceneExtenderComp:
icomp::CComponentBase imod::TSingleModelObserverBase< iprm::ISelectionParam > iqt2d::IViewExtender icomp::IComponent imod::CSingleModelObserverBase istd::IPolymorphic istd::IPolymorphic imod::IObserver istd::IPolymorphic

Public Types

typedef icomp::CComponentBase BaseClass
 
typedef imod::TSingleModelObserverBase< iprm::ISelectionParamBaseClass2
 
- Public Types inherited from imod::TSingleModelObserverBase< iprm::ISelectionParam >
typedef CSingleModelObserverBase BaseClass
 
typedef iprm::ISelectionParam ModelType
 
- Public Types inherited from imod::CSingleModelObserverBase
typedef imod::IModel ModelType
 
- Public Types inherited from iqt2d::IViewExtender
enum  SceneFlags { SF_BACKGROUND = 1 , SF_DIRECT = 2 }
 Standard flags for items . More...
 

Public Member Functions

 CSelectableSceneExtenderComp ()
 
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 AddItemsToScene (iqt2d::IViewProvider *providerPtr, int flags) override
 Called when items should be added to specified scene.
 
virtual void RemoveItemsFromScene (iqt2d::IViewProvider *providerPtr) override
 Called when items should be removed from specified scene.
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 
- Public Member Functions inherited from imod::TSingleModelObserverBase< iprm::ISelectionParam >
 TSingleModelObserverBase ()
 
iprm::ISelectionParamGetObservedObject () const
 Get instance of observed object.
 
iprm::ISelectionParamGetObjectPtr () const
 Get instance of observed object.
 
bool AttachOrSetObject (iprm::ISelectionParam *objectPtr)
 Attach to model of object or set object pointer, if no connection is possible.
 
- 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.
 

Protected Member Functions

void AttachCurrent ()
 
void DetachCurrent ()
 
virtual void AfterUpdate (imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
 Callback invoked after an update of the observer's content occurs.
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual void OnComponentCreated ()
 
virtual void OnComponentDestroyed ()
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 
- Protected Member Functions inherited from imod::TSingleModelObserverBase< iprm::ISelectionParam >
virtual iprm::ISelectionParamCastFromModel (imod::IModel *modelPtr) const
 
- Protected Member Functions inherited from imod::CSingleModelObserverBase
void SetModelPtr (imod::IModel *modelPtr)
 Set internal model pointer to specified value.
 
virtual void OnUpdate (const istd::IChangeable::ChangeSet &changeSet)
 Called on update of observed model.
 

Additional Inherited Members

- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 
- Static Protected Attributes inherited from imod::CSingleModelObserverBase
static const istd::IChangeable::ChangeSet s_undoChanges
 

Detailed Description

Definition at line 16 of file CSelectableSceneExtenderComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 22 of file CSelectableSceneExtenderComp.h.

◆ BaseClass2

Definition at line 23 of file CSelectableSceneExtenderComp.h.

Constructor & Destructor Documentation

◆ CSelectableSceneExtenderComp()

iqt2d::CSelectableSceneExtenderComp::CSelectableSceneExtenderComp ( )

Member Function Documentation

◆ AddItemsToScene()

virtual void iqt2d::CSelectableSceneExtenderComp::AddItemsToScene ( iqt2d::IViewProvider providerPtr,
int  flags 
)
overridevirtual

Called when items should be added to specified scene.

Implements iqt2d::IViewExtender.

◆ AfterUpdate()

virtual void iqt2d::CSelectableSceneExtenderComp::AfterUpdate ( imod::IModel modelPtr,
const istd::IChangeable::ChangeSet changeSet 
)
overrideprotectedvirtual

Callback invoked after an update of the observer's content occurs.

This is the primary notification method where observers react to model changes. It's called after the model has finished updating its state. The implementation should examine the changeSet to determine what changed and update accordingly.

Parameters
modelPtrPointer to the model that has changed
changeSetContains information about what changed in the model. Use changeSet.Contains(changeId) to check for specific changes. The changeSet respects the mask specified in OnModelAttached().
Note
This is typically where you update your GUI, recalculate derived values, or trigger other dependent operations.
Keep this method fast - it's called frequently and may block the UI thread.
Use the changeSet to perform incremental updates rather than refreshing everything.
virtual void AfterUpdate(IModel* modelPtr,
const istd::IChangeable::ChangeSet& changeSet)
{
CMyModel* model = dynamic_cast<CMyModel*>(modelPtr);
if (!model) return;
// Selective update based on what changed
if (changeSet.Contains(CMyModel::CF_NAME_CHANGED)) {
m_nameLabel->setText(model->GetName());
}
if (changeSet.Contains(CMyModel::CF_VALUE_CHANGED)) {
m_valueSpinBox->setValue(model->GetValue());
RecalculateDependentValues();
}
// Re-enable signals if blocked in BeforeUpdate
if (m_widget) {
m_widget->blockSignals(false);
}
}
virtual void AfterUpdate(imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override
Callback invoked after an update of the observer's content occurs.
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.
See also
BeforeUpdate(), OnModelAttached()

Reimplemented from imod::CSingleModelObserverBase.

◆ AttachCurrent()

void iqt2d::CSelectableSceneExtenderComp::AttachCurrent ( )
protected

◆ DetachCurrent()

void iqt2d::CSelectableSceneExtenderComp::DetachCurrent ( )
protected

◆ OnModelAttached()

virtual bool iqt2d::CSelectableSceneExtenderComp::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;
}
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::TSingleModelObserverBase< iprm::ISelectionParam >.

◆ OnModelDetached()

virtual bool iqt2d::CSelectableSceneExtenderComp::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::TSingleModelObserverBase< iprm::ISelectionParam >.

◆ RemoveItemsFromScene()

virtual void iqt2d::CSelectableSceneExtenderComp::RemoveItemsFromScene ( iqt2d::IViewProvider providerPtr)
overridevirtual

Called when items should be removed from specified scene.

Implements iqt2d::IViewExtender.


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