ImFusion SDK 4.3
InteractiveObject Class Reference

#include <ImFusion/GUI/InteractiveObject.h>

Wraps a GlObject pairing it with an optional Manipulator in order to attach it to an InteractiveView. More...

+ Inheritance diagram for InteractiveObject:

Detailed Description

Wraps a GlObject pairing it with an optional Manipulator in order to attach it to an InteractiveView.

Attaching a InteractiveObject to a InteractiveView (in contrast to attaching a GlObject to a GlView) allows for receiving and handling user input (e.g. mouse events). Usually, event handling logic is implemented by the Manipulator and the InteractiveObject is merely supposed to coordinate the interaction between the user input (via Manipulator) and the GlObject.

This class serves as a bridge between the Qt GUI Layer and the OpenGL Layer by forwarding the Qt events coming from an interactiveView to a Manipulator and holding a reference to the GlObject which intended for interaction. Formally this class belongs to the Qt GUI Layer.

Remark: By default, InteractiveObject does not own either the GlObject or the Manipulator; both must be managed externally (e.g., by the Controller). However, if constructed using InteractiveObject::InteractiveObject(GlObject* object, Manipulator* manipulator, bool own) with own set to true, InteractiveObject takes ownership and will delete the GlObject and Manipulator in its destructor.

An InteractiveObject must be referenced by an InteractiveView to work properly. To achieve this bond, we can associate the InteractiveObject to the InteractiveView via InteractiveView::addObject. For example, inside a Controller we can call

m_disp->viewSlice(1)->addObject(myPointerToInteractiveObject);
m_disp->view3D()->addObject(myPointerToAnotherInteractiveObject);

The InteractiveView calls InteractiveObject::sceneEvent to propagate input events. These events can then be handled by the user via an overridable sceneEvent() method in a subclass, allowing the user to control of the GlObject.

Key Methods:

See also
Interactive<T, S> for a templated version of this class

Public Member Functions

 InteractiveObject (GlObject *object, Manipulator *manipulator=nullptr, bool own=true)
 Instantiate a new InteractiveOverlay, optionally taking ownership of the underlying GlObject and Manipulator.
 
template<typename T>
const T * gl () const
 Get a typed pointer to the underlying GlObject.
 
template<typename T>
T * gl ()
 Get a typed pointer to the underlying GlObject.
 
const GlObjectgl () const
 Get the underlying abstract GlObject.
 
GlObjectgl ()
 Get the underlying abstract GlObject.
 
const Manipulatormanipulator () const
 Get the underlying manipulator.
 
Manipulatormanipulator ()
 Get the underlying manipulator.
 
virtual bool sceneEvent (QEvent *event, InteractiveView *view)
 Called by the hosting InteractiveView to notify on user input events.
 
virtual void goTo (DisplayWidgetMulti *display, Data *data=nullptr, int frame=-1) const
 Center the views contained in the passed display widget which show data on the object.
 
GUI::EventResult handleInputEvent (const GUI::InputEvent &event, const GUI::View &view) override
 Gets called by the parent view in order to handle user input events.
 
- Public Member Functions inherited from ViewObject
 ViewObject (std::unique_ptr< GlObject > glObject)
 Instantiate a new ViewObject taking ownership of the underlying GlObject which must not be null.
 
const GlObjectglObject () const
 Get the underlying abstract GlObject.
 
GlObjectglObject ()
 
const GlObjectgl () const
 Original API methods for the underlying abstract GlObject.
 
GlObjectgl ()
 

Public Attributes

Signal< const InteractiveObject * > signalDeleted
 Signal emitted when this instance is deleted.
 

Protected Attributes

GlObjectm_object
 
Manipulatorm_manipulator = nullptr
 
bool m_own = true
 
- Protected Attributes inherited from ViewObject
std::unique_ptr< GlObjectm_glObject
 

Member Function Documentation

◆ sceneEvent()

virtual bool sceneEvent ( QEvent * event,
InteractiveView * view )
virtual

Called by the hosting InteractiveView to notify on user input events.

Default implementation will foward the event to the Manipulator if the object is visible.

Returns
true if the event has been handled and should no longer be passed to other objects.

Reimplemented in InteractiveAnnotation.

◆ goTo()

virtual void goTo ( DisplayWidgetMulti * display,
Data * data = nullptr,
int frame = -1 ) const
virtual

Center the views contained in the passed display widget which show data on the object.

If no data is specified, the default view group is centered.

Reimplemented in InteractiveAnnotation.

◆ handleInputEvent()

GUI::EventResult handleInputEvent ( const GUI::InputEvent & event,
const GUI::View & view )
overridevirtual

Gets called by the parent view in order to handle user input events.

It returns an EventResult to indicated if and how event propagation should continue.

Parameters
eventUser input event to handle.
viewParent View where the event originates from. This additional payload enables you to add the same ViewObject to multiple views and still implement view-specific handling logic.

Implements ViewObject.

Member Data Documentation

◆ signalDeleted

Signal<const InteractiveObject*> signalDeleted

Signal emitted when this instance is deleted.

Note
This method is called from a Data instance in the destructor of the very base class, therefore no type information for dynamic casts or other class attributes are available anymore.
Warning
Use with caution, only pointer comparison is allowed!

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close