VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::AnnotationManager Class Reference

#include <framework/script/annotationManager.h>

Inheritance diagram for visutwin::canvas::AnnotationManager:
[legend]

Public Member Functions

AnnotationactiveAnnotation () const
 The currently selected (clicked) annotation, or nullptr.
const ColoractiveColor () const
void handleClick (float screenX, float screenY)
 Handle mouse click at screen coordinates — selects/deselects the nearest annotation.
const ColorhotspotColor () const
float hotspotSize () const
const ColorhoverColor () const
AnnotationhoveredAnnotation () const
 The currently hovered annotation (nearest to mouse within hotspot radius), or nullptr.
void initialize () override
float opacity () const
const std::vector< AnnotationScreenInfo > & screenInfos () const
void setActiveColor (const Color &value)
void setHotspotColor (const Color &value)
void setHotspotSize (float value)
void setHoverColor (const Color &value)
void setOpacity (float value)
void update (float dt) override
void updateHover (float mouseX, float mouseY)
 Update hover state based on mouse position (call each frame with current mouse pos).
Public Member Functions inherited from visutwin::canvas::Script
bool enabled () const
virtual void fixedUpdate (float fixedDt)
virtual void postInitialize ()
virtual void postUpdate (float dt)
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Static Public Member Functions

static constexpr const char * scriptName ()

Additional Inherited Members

Protected Member Functions inherited from visutwin::canvas::Script
Entityentity () const
Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)

Detailed Description

A manager script that handles annotation registration, screen-space projection, and click interaction. All rendering is delegated to an external overlay system (e.g., ImGuiOverlay) which reads the projected screen positions each frame.

The manager listens for engine-level events to automatically register annotations:

  • annotation:add — fired when an Annotation script initializes
  • annotation:remove — fired when an Annotation script is destroyed

The manager handles:

  • Global hotspot size and color configuration
  • Per-frame world-to-screen projection of all annotations
  • Mouse hover detection (nearest annotation within hotspot radius)
  • Click interaction for selecting/deselecting annotations

All visual rendering (hotspot circles, tooltip panels, connector lines) is done externally by reading annotations(), activeAnnotation(), and hoveredAnnotation().

Definition at line 56 of file annotationManager.h.

Member Function Documentation

◆ activeAnnotation()

Annotation * visutwin::canvas::AnnotationManager::activeAnnotation ( ) const
inline

The currently selected (clicked) annotation, or nullptr.

Definition at line 81 of file annotationManager.h.

◆ activeColor()

const Color & visutwin::canvas::AnnotationManager::activeColor ( ) const
inline

Definition at line 67 of file annotationManager.h.

◆ handleClick()

void visutwin::canvas::AnnotationManager::handleClick ( float screenX,
float screenY )

Handle mouse click at screen coordinates — selects/deselects the nearest annotation.

Definition at line 187 of file annotationManager.cpp.

References visutwin::canvas::Annotation::text(), and visutwin::canvas::Annotation::title().

◆ hotspotColor()

const Color & visutwin::canvas::AnnotationManager::hotspotColor ( ) const
inline

Definition at line 64 of file annotationManager.h.

◆ hotspotSize()

float visutwin::canvas::AnnotationManager::hotspotSize ( ) const
inline

Definition at line 61 of file annotationManager.h.

References hotspotSize().

Referenced by hotspotSize().

◆ hoverColor()

const Color & visutwin::canvas::AnnotationManager::hoverColor ( ) const
inline

Definition at line 70 of file annotationManager.h.

◆ hoveredAnnotation()

Annotation * visutwin::canvas::AnnotationManager::hoveredAnnotation ( ) const
inline

The currently hovered annotation (nearest to mouse within hotspot radius), or nullptr.

Definition at line 84 of file annotationManager.h.

◆ initialize()

void visutwin::canvas::AnnotationManager::initialize ( )
overridevirtual

Called when script is about to run for the first time. Override this method in subclasses to implement custom initialization logic.

Reimplemented from visutwin::canvas::Script.

Definition at line 27 of file annotationManager.cpp.

References visutwin::canvas::Entity::engine(), and visutwin::canvas::Script::entity().

◆ opacity()

float visutwin::canvas::AnnotationManager::opacity ( ) const
inline

Definition at line 73 of file annotationManager.h.

◆ screenInfos()

const std::vector< AnnotationScreenInfo > & visutwin::canvas::AnnotationManager::screenInfos ( ) const
inline

All registered annotations with their current screen positions. Updated each frame in update(). Use this to render annotations externally.

Definition at line 78 of file annotationManager.h.

◆ scriptName()

constexpr const char * visutwin::canvas::AnnotationManager::scriptName ( )
inlinestaticconstexpr

Definition at line 59 of file annotationManager.h.

◆ setActiveColor()

void visutwin::canvas::AnnotationManager::setActiveColor ( const Color & value)
inline

Definition at line 68 of file annotationManager.h.

◆ setHotspotColor()

void visutwin::canvas::AnnotationManager::setHotspotColor ( const Color & value)
inline

Definition at line 65 of file annotationManager.h.

◆ setHotspotSize()

void visutwin::canvas::AnnotationManager::setHotspotSize ( float value)
inline

Definition at line 62 of file annotationManager.h.

◆ setHoverColor()

void visutwin::canvas::AnnotationManager::setHoverColor ( const Color & value)
inline

Definition at line 71 of file annotationManager.h.

◆ setOpacity()

void visutwin::canvas::AnnotationManager::setOpacity ( float value)
inline

Definition at line 74 of file annotationManager.h.

◆ update()

◆ updateHover()

void visutwin::canvas::AnnotationManager::updateHover ( float mouseX,
float mouseY )

Update hover state based on mouse position (call each frame with current mouse pos).

Definition at line 166 of file annotationManager.cpp.


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