ImFusion C++ SDK 4.4.0
ImFusion::TrackingInstrumentComboBox Class Reference

#include <ImFusion/Stream/StreamGUIHelpers.h>

QComboBox widget for selecting TrackingInstruments from a TrackingStream. More...

Inheritance diagram for ImFusion::TrackingInstrumentComboBox:

Detailed Description

QComboBox widget for selecting TrackingInstruments from a TrackingStream.

This helper class provides a convenient interface for presenting tracking instruments in a dropdown list with flexible formatting options. It can be initialized from a TrackingStream (with automatic updates when instruments change) or from a static list of TrackerIDs.

The widget supports configurable display formats combining ID, model number, and name fields, and optionally allows a "no selection" state.

Example usage with a tracking stream:

auto* comboBox = new TrackingInstrumentComboBox(parent);
comboBox->initFromTrackingStream(
trackingStream,
);
comboBox->signalSelectedInstrumentChanged.connect([](const std::string& id) {
// Handle instrument selection change
});
TrackingInstrumentComboBox(QWidget *parent=nullptr, bool supportsPreInitializationSelection=true)
Constructor for the combobox.
@ Name
Show name.
Definition StreamGUIHelpers.h:47
@ ID
Show unique id.
Definition StreamGUIHelpers.h:45
Note
This is a Qt widget and must be used on the GUI thread. Signals from TrackingStream are automatically invoked on the GUI thread using Qt's event system.

Public Types

enum  FormattingOptions { ID = 1 << 0 , ModelNumber = 1 << 1 , Name = 1 << 2 , All = 0xFF }
 Bitfield enum for formatting options. More...

Public Member Functions

 TrackingInstrumentComboBox (QWidget *parent=nullptr, bool supportsPreInitializationSelection=true)
 Constructor for the combobox.
void initFromTrackingStream (TrackingStream *trackingStream, Flags< FormattingOptions > idFormatting=FormattingOptions::All, bool supportsNoSelection=false)
 Initializes the combo box from a TrackingStream with automatic updates.
void initFromInstruments (const std::vector< TrackerID > &trackingInstrumentIDs, Flags< FormattingOptions > idFormatting=FormattingOptions::All, bool supportsNoSelection=false)
 Initializes the combo box from a static list of instruments.
bool selectInstrument (const std::string &trackerId)
 Selects an instrument by its unique ID.
std::string selectedInstrument () const
 Returns the unique ID of the currently selected instrument, or empty string if none selected.
void setSeparator (const std::string &separator)
 Sets the separator between display fields (default "|").
Public Member Functions inherited from ImFusion::SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.

Public Attributes

ProtectedSignal< const std::string & > signalSelectedInstrumentChanged
 Emit the newly selected instrument ID when the selected instrument changes (empty string if none selected).

Additional Inherited Members

Protected Member Functions inherited from ImFusion::SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.

Member Enumeration Documentation

◆ FormattingOptions

Bitfield enum for formatting options.

All fields are displayed by default.

Enumerator
ID 

Show unique id.

ModelNumber 

Show model number.

Name 

Show name.

All 

Show all fields in the form "id|modelNumber|name" (equivalent to TrackerID::toIDModelNameString).

Constructor & Destructor Documentation

◆ TrackingInstrumentComboBox()

ImFusion::TrackingInstrumentComboBox::TrackingInstrumentComboBox ( QWidget * parent = nullptr,
bool supportsPreInitializationSelection = true )

Constructor for the combobox.

If supportsPreInitializationSelection is true, a selected instrument is saved and set later once the instruments are initialized.

Member Function Documentation

◆ initFromTrackingStream()

void ImFusion::TrackingInstrumentComboBox::initFromTrackingStream ( TrackingStream * trackingStream,
Flags< FormattingOptions > idFormatting = FormattingOptions::All,
bool supportsNoSelection = false )

Initializes the combo box from a TrackingStream with automatic updates.

The combo box will automatically reflect changes to the tracking stream's instrument list by connecting to the stream's signalInstrumentsUpdated. Updates are invoked on the GUI thread. If supportsNoSelection is true, a "<no instrument>" entry is added at the top of the list.

◆ initFromInstruments()

void ImFusion::TrackingInstrumentComboBox::initFromInstruments ( const std::vector< TrackerID > & trackingInstrumentIDs,
Flags< FormattingOptions > idFormatting = FormattingOptions::All,
bool supportsNoSelection = false )

Initializes the combo box from a static list of instruments.

Use this when you have a fixed list of instruments or want to manage updates manually.

◆ selectInstrument()

bool ImFusion::TrackingInstrumentComboBox::selectInstrument ( const std::string & trackerId)

Selects an instrument by its unique ID.

If the instrument list is empty and supportsPreInitializationSelection is true, selection is deferred until the instruments are initialized. Returns true if successfully selected, false if not found or selection failed.

◆ setSeparator()

void ImFusion::TrackingInstrumentComboBox::setSeparator ( const std::string & separator)

Sets the separator between display fields (default "|").

For example, with separator "#" and formatting {ID | Name}, displays as "tool-1#Pointer".


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