![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/InteractiveObject.h>
Wraps a GlObject pairing it with an optional Manipulator in order to attach it to an InteractiveView. More...
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
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.
sceneEvent(QEvent*)
: Forwards the Qt event to the Manipulator if the object is visible. The user must override this class to gather the events from the InteractiveView. When overriding, a good practice is to call InteractiveObject::sceneEvent to forward events to the manipulator properly.goTo()
: Moves the camera to center on the GlObject and sets focus in the InteractiveView GUI.handleInputEvent()
: Implements the interface of the non-qt base class GUI::Object and forwards the call to sceneEvent(). sceneEvent()
to customize how Qt events are handled.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 GlObject * | gl () const |
Get the underlying abstract GlObject. | |
GlObject * | gl () |
Get the underlying abstract GlObject. | |
const Manipulator * | manipulator () const |
Get the underlying manipulator. | |
Manipulator * | manipulator () |
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. | |
![]() | |
ViewObject (std::unique_ptr< GlObject > glObject) | |
Instantiate a new ViewObject taking ownership of the underlying GlObject which must not be null. | |
const GlObject & | glObject () const |
Get the underlying abstract GlObject. | |
GlObject & | glObject () |
const GlObject * | gl () const |
Original API methods for the underlying abstract GlObject. | |
GlObject * | gl () |
Public Attributes | |
Signal< const InteractiveObject * > | signalDeleted |
Signal emitted when this instance is deleted. | |
Protected Attributes | |
GlObject * | m_object |
Manipulator * | m_manipulator = nullptr |
bool | m_own = true |
![]() | |
std::unique_ptr< GlObject > | m_glObject |
|
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.
Reimplemented in InteractiveAnnotation.
|
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.
|
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.
event | User input event to handle. |
view | Parent 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.
Signal<const InteractiveObject*> signalDeleted |