![]() |
ImFusion C++ SDK 4.4.0
|
#include <ImFusion/Stream/StreamGUIHelpers.h>
QComboBox widget for selecting TrackingInstruments from a TrackingStream. More...
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:
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. | |
| SignalReceiver & | operator= (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. | |
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). |
| 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.
| 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.
| 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.
| 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.
| 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".