ImFusion C++ SDK 4.5.0
ImFusion::GUI::PointBasedAnnotationEventHandler Class Reference

#include <ImFusion/GUI/PointBasedAnnotationEventHandler.h>

Event handler for creating and editing point-based annotations. More...

Inheritance diagram for ImFusion::GUI::PointBasedAnnotationEventHandler:

Detailed Description

Event handler for creating and editing point-based annotations.

This event handler can operate in two different modes:

  • In "creation mode" the editing of the existing points is not possible and the only actions you can perform are to append additional points at the end, or to finish or abort the creation. Usually, this is the initial mode when starting with an empty annotation without any points.
  • In "regular mode" the full set of editing actions are available.

If you need an interactively editable GlPointBasedAnnotation you additionally instantiate the PointBasedAnnotationEventHandler and wrap the two together in a TypedViewObject.

Classes

struct  RegularMode
struct  CreateMode
struct  MovePointMode
struct  MoveAnnotationMode

Public Types

enum class  Action {
  CreateAppendPoint = 0 , AbortCreation = 1 , FinishCreation = 2 , MovePoint = 3 ,
  InsertPoint = 4 , RemovePoint = 5 , MoveAnnotation = 6
}
 Enumeration of available actions this event handler can perform on the underlying annotation. More...

Public Member Functions

 PointBasedAnnotationEventHandler (GlPointBasedAnnotation &annotation, bool startInCreationMode=true)
 Instantiates a new PointBasedAnnotationEventHandler for the given annotation additionally specifying the initial state whether the event handler is in "creation mode" or not.
bool isInCreationMode () const
 Returns whether this class is currently in "creation mode" where the only possible action for the user is to append new points at the end, or if it is in "regular mode" where you can edit an existing annotation.
bool enableCreationMode ()
 Switches the event handler into "creation mode" where the only possible action for the user is to append new points at the end.
std::optional< InputEvent::KeyboardModifier > snapToAngleModifier () const
 Returns the keyboard modifier that can be used to snap angles to 45° during creation/moving of points.
void setSnapToAngleModifier (std::optional< InputEvent::KeyboardModifier > value)
 Sets the keyboard modifier that can be used to snap angles to 45° during creation/moving of points.
std::optional< InputEvent::KeyboardModifier > insertPointModifier () const
 Returns the keyboard modifier that can be used to preview the insertion of points when hovering with the mouse.
void setInsertPointModifier (std::optional< InputEvent::KeyboardModifier > value)
 Sets the keyboard modifier that can be used to preview the insertion of points when hovering with the mouse.
InputEventMapper< Action > & actionMapper ()
 Get access to the mapping of input events to Actions of this event handler.
EventResult handleInputEvent (const InputEvent &event, const View &parentView) override
 This function is called by sources of input events in order to dispatch them to the handlers.
void setAllowCursorChanges (bool change)

Public Attributes

Signal< Action > signalActionHappened
 Signal emitted whenever an action has been performed.

Protected Member Functions

int getInsertionIndex (const std::vector< vec3 > &points, const GL::ViewState &viewState, const vec2 &screenPos) const
GUI::EventResult handleMouseEvent (const GUI::MouseEvent &event, const View &parentView)
GUI::EventResult handleKeyEvent (const GUI::KeyEvent &event, const View &parentView)

Static Protected Member Functions

static vec3 snapToAngle (const GL::ViewState &viewState, const vec3 &previousPointWorld, const vec3 &currentPointWorld)

Protected Attributes

GlPointBasedAnnotation & m_annotation
InputEventMapper< Action > m_eventMapper
std::optional< InputEvent::KeyboardModifier > m_snapToAngleModifier = InputEvent::KeyboardModifier::Shift
std::optional< InputEvent::KeyboardModifier > m_insertPointModifier = InputEvent::KeyboardModifier::Alt
Utils::Variant< RegularMode, CreateMode, MovePointMode, MoveAnnotationMode > m_currentMode = RegularMode()
bool m_stopPropagationOfNextMouseReleaseEvent = false
bool m_allowCursorChanges = true

Member Enumeration Documentation

◆ Action

Enumeration of available actions this event handler can perform on the underlying annotation.

Enumerator
CreateAppendPoint 

Append a point to the end while in "creation mode".

AbortCreation 

Abort "creation mode", remove all previously created points, and switch to "regular mode".

FinishCreation 

Finish "creation mode" and switch to "regular mode".

MovePoint 

Move an existing point while in "regular mode".

InsertPoint 

Insert a new point to the annotation while in "regular mode".

RemovePoint 

Remove an existing point while in "regular mode".

MoveAnnotation 

Move the entire annotation while in "regular mode".

Member Function Documentation

◆ enableCreationMode()

bool ImFusion::GUI::PointBasedAnnotationEventHandler::enableCreationMode ( )

Switches the event handler into "creation mode" where the only possible action for the user is to append new points at the end.

Returns false if "creation mode" cannot be enabled because the maximum number of points is already reached.

◆ actionMapper()

InputEventMapper< Action > & ImFusion::GUI::PointBasedAnnotationEventHandler::actionMapper ( )
inline

Get access to the mapping of input events to Actions of this event handler.

You can use this to customize the mapping of mouse and keyboard buttons, or disable certain Actions altogether.

◆ handleInputEvent()

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

This function is called by sources of input events in order to dispatch them to the handlers.

In case there are more than one InputEventHandlers dispatchers are intended call this function consecutively until the first handler indicates to stop by returning a result where EventResult::stopPropagation() is true.

Implements ImFusion::GUI::ViewObject::EventHandler.


The documentation for this class was generated from the following file:
  • ImFusion/GUI/PointBasedAnnotationEventHandler.h
Search Tab / S to search, Esc to close