Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GEO::Command Class Reference

Manages the GUI of a command with ImGUI. More...

#include <geogram_gfx/gui/command.h>

Inheritance diagram for GEO::Command:
GEO::Counted

Public Member Functions

 Command (const std::string &prototype)
 Command constructor.
 
const std::string & name () const
 Gets the name of this command.
 
void set_invoker (CommandInvoker *invoker)
 Sets the invoker.
 
 ~Command () override
 Command destructor.
 
bool is_visible () const
 Tests whether this Command is visible.
 
bool * is_visible_ptr ()
 Gets a pointer to the visibility flag of this command.
 
virtual void draw ()
 Displays and manages the GUI of this Command.
 
virtual void reset_factory_settings ()
 Restores default parameter values for all parameters.
 
virtual void apply ()
 Gets the value of the parameters and does the task.
 
bool bool_arg_by_index (index_t i) const
 Gets the value of a boolean argument by index.
 
int int_arg_by_index (index_t i) const
 Gets the value of an integer argument by index.
 
unsigned int uint_arg_by_index (index_t i) const
 Gets the value of an unsigned integer argument by index.
 
float float_arg_by_index (index_t i) const
 Gets the value of a floating-point argument by index.
 
double double_arg_by_index (index_t i) const
 Gets the value of a floating-point argument by index and converts it to a double.
 
std::string string_arg_by_index (index_t i) const
 Gets the value of a string argument by index.
 
template<class T >
void get_arg_by_index (index_t i, T &val)
 Gets the value of an argument by index.
 
template<class T >
void invoke (T *target, void(T::*fptr)(void))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 >
void invoke (T *target, void(T::*fptr)(ARG0))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6))
 Invokes a member function with the stored arguments.
 
template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 , class ARG7 >
void invoke (T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
 Invokes a member function with the stored arguments.
 
void invoke (void(*fptr)(void))
 Invokes a function with the stored arguments.
 
template<class ARG0 >
void invoke (void(*fptr)(ARG0))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 >
void invoke (void(*fptr)(ARG0, ARG1))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6))
 Invokes a function with the stored arguments.
 
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 , class ARG7 >
void invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
 Invokes a function with the stored arguments.
 
template<>
void get_arg_by_index (index_t i, bool &val)
 Gets the value of an argument by index.
 
template<>
void get_arg_by_index (index_t i, int &val)
 Gets the value of an argument by index.
 
template<>
void get_arg_by_index (index_t i, unsigned int &val)
 Gets the value of an argument by index.
 
template<>
void get_arg_by_index (index_t i, float &val)
 Gets the value of an argument by index.
 
template<>
void get_arg_by_index (index_t i, double &val)
 Gets the value of an argument by index.
 
template<>
void get_arg_by_index (index_t i, std::string &val)
 Gets the value of an argument by index.
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count.
 
void unref () const
 Decrements the reference count.
 
bool is_shared () const
 Check if the object is shared.
 
int nb_refs () const
 Gets the number of references that point to this object.
 

Static Public Member Functions

template<class FPTR >
static void set_current (const std::string &prototype, FPTR tfun)
 Binds the current command to a function.
 
template<class T , class TFPTR >
static void set_current (const std::string &prototype, T *target, TFPTR tfun)
 Binds the current command to a member function of an object.
 
static void flush_queue ()
 Flushes the potentially queued command invokation.
 
static Commandcurrent ()
 Gets the current command.
 
static void reset_current ()
 Resets the current command.
 
static void set_current (Command *command)
 Sets the current command.
 
- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count.
 
static void unref (const Counted *counted)
 Decrements the reference count.
 

Protected Member Functions

void assert_nb_args_matches (index_t nb)
 Tests whether the number of declared arguments matches a specified number.
 
template<class T >
void add_arg (const std::string &name, const T &default_val, const std::string &help="")
 Adds a parameter to this command.
 
template<class T >
void create_arg (index_t i, const T &default_val)
 Creates an argument at a given index.
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object.
 
virtual ~Counted ()
 Destroys a reference counted object.
 

Static Protected Member Functions

static void set_queued (Command *command)
 

Detailed Description

Manages the GUI of a command with ImGUI.

Client code will only need to use set_current()

Definition at line 99 of file command.h.

Constructor & Destructor Documentation

◆ Command()

GEO::Command::Command ( const std::string &  prototype)

Command constructor.

Parameters
[in]prototypea const reference to a string with the prototype of the function that implements the callback, as declared in the C++ sources.
Note
Regular client code should not need to use this function.

Member Function Documentation

◆ add_arg()

template<class T >
void GEO::Command::add_arg ( const std::string &  name,
const T &  default_val,
const std::string &  help = "" 
)
inlineprotected

Adds a parameter to this command.

Template Parameters
Ttype of the parameter, deduced from default_val
Parameters
[in]namename of the parameter
[in]default_valdefault value of the parameter
[in]helpoptionnal text, displayed in a tooltip

Definition at line 1002 of file command.h.

◆ apply()

virtual void GEO::Command::apply ( )
virtual

Gets the value of the parameters and does the task.

This is the function that is called when the user pushes the 'apply' button. It does not invoke the command immediatly, the command invocation is queued, and executed later by Command::flush_queue(), once we are no longer in the ImGui handler (else we would have two nested ImGui handlers, which is not correct).

Note
Regular client code should not need to use this function.

◆ assert_nb_args_matches()

void GEO::Command::assert_nb_args_matches ( index_t  nb)
inlineprotected

Tests whether the number of declared arguments matches a specified number.

If the number of arguments differs from the expected number, then an assertion failure is triggered. When auto_create_args_ is set, number of stored arguments should be 0.

Parameters
[in]nbexpected number of arguments.

Definition at line 985 of file command.h.

◆ bool_arg_by_index()

bool GEO::Command::bool_arg_by_index ( index_t  i) const
inline

Gets the value of a boolean argument by index.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

Definition at line 337 of file command.h.

◆ create_arg()

template<class T >
void GEO::Command::create_arg ( index_t  i,
const T &  default_val 
)
inlineprotected

Creates an argument at a given index.

Used by the auto_create_args mechanism, used when client code did not provide any function prototype

Template Parameters
Ttype of the parameter, deduced from default_val
Parameters
[in]default_valdefault value of the parameter

Definition at line 1017 of file command.h.

◆ current()

static Command * GEO::Command::current ( )
inlinestatic

Gets the current command.

Returns
a pointer to the current command
Note
Regular client code should not need to use this function.

Definition at line 306 of file command.h.

◆ double_arg_by_index()

double GEO::Command::double_arg_by_index ( index_t  i) const
inline

Gets the value of a floating-point argument by index and converts it to a double.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

Definition at line 392 of file command.h.

◆ draw()

virtual void GEO::Command::draw ( )
virtual

Displays and manages the GUI of this Command.

Note
Regular client code should not need to use this function.

◆ float_arg_by_index()

float GEO::Command::float_arg_by_index ( index_t  i) const
inline

Gets the value of a floating-point argument by index.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

Definition at line 376 of file command.h.

◆ flush_queue()

static void GEO::Command::flush_queue ( )
static

Flushes the potentially queued command invokation.

When the user pushes the 'apply' button, the command is not invoked immediatly, because we are still in the ImGUI handling function. This function is called by the framework at the end of the frame, when the ImGUI handler is already finished. It can potentially re-trigger frame rendering operations, through the Logger and ProgressLogger. Without this mechanism, it would nest two ImGUI handlers, which is not allowed.

◆ get_arg_by_index() [1/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
bool &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1215 of file command.h.

◆ get_arg_by_index() [2/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
double &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1271 of file command.h.

◆ get_arg_by_index() [3/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
float &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1257 of file command.h.

◆ get_arg_by_index() [4/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
int &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1229 of file command.h.

◆ get_arg_by_index() [5/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
std::string &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1285 of file command.h.

◆ get_arg_by_index() [6/7]

template<class T >
void GEO::Command::get_arg_by_index ( index_t  i,
T &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 422 of file command.h.

◆ get_arg_by_index() [7/7]

template<>
void GEO::Command::get_arg_by_index ( index_t  i,
unsigned int &  val 
)
inline

Gets the value of an argument by index.

This function is generic, and has several specializations for bool, int, unsigned int, float, double and std::string. For all other types, an assertion failure is triggered.

Template Parameters
Ttype of the argument
Parameters
[in]ithe index of the argument
[out]vala reference to the argument
Note
Regular client code should not need to use this function.

Definition at line 1243 of file command.h.

◆ int_arg_by_index()

int GEO::Command::int_arg_by_index ( index_t  i) const

Gets the value of an integer argument by index.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

◆ invoke() [1/18]

template<class T , class ARG0 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0type of the argument
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 464 of file command.h.

◆ invoke() [2/18]

template<class T , class ARG0 , class ARG1 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG1types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 489 of file command.h.

◆ invoke() [3/18]

template<class T , class ARG0 , class ARG1 , class ARG2 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG1,ARG2types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 517 of file command.h.

◆ invoke() [4/18]

template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2, ARG3)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG1,ARG2,ARG3types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 547 of file command.h.

◆ invoke() [5/18]

template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2, ARG3, ARG4)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG4types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 580 of file command.h.

◆ invoke() [6/18]

template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG5types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 615 of file command.h.

◆ invoke() [7/18]

template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG6types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 652 of file command.h.

◆ invoke() [8/18]

template<class T , class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 , class ARG7 >
void GEO::Command::invoke ( T *  target,
void(T::*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
ARG0,ARG7types of the arguments
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 691 of file command.h.

◆ invoke() [9/18]

template<class T >
void GEO::Command::invoke ( T *  target,
void(T::*)(void)  fptr 
)
inline

Invokes a member function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
Tclass of the target object
Parameters
[in]targetthe target object
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 442 of file command.h.

◆ invoke() [10/18]

template<class ARG0 >
void GEO::Command::invoke ( void(*)(ARG0)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0type of the argument
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 747 of file command.h.

◆ invoke() [11/18]

template<class ARG0 , class ARG1 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG1types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 769 of file command.h.

◆ invoke() [12/18]

template<class ARG0 , class ARG1 , class ARG2 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG1,ARG2types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 793 of file command.h.

◆ invoke() [13/18]

template<class ARG0 , class ARG1 , class ARG2 , class ARG3 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2, ARG3)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG1,ARG2,ARG3types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 819 of file command.h.

◆ invoke() [14/18]

template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2, ARG3, ARG4)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG1,ARG2,ARG3,ARG4types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 848 of file command.h.

◆ invoke() [15/18]

template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG5types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 879 of file command.h.

◆ invoke() [16/18]

template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG6types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 912 of file command.h.

◆ invoke() [17/18]

template<class ARG0 , class ARG1 , class ARG2 , class ARG3 , class ARG4 , class ARG5 , class ARG6 , class ARG7 >
void GEO::Command::invoke ( void(*)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Template Parameters
ARG0,ARG7types of the arguments
Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 947 of file command.h.

◆ invoke() [18/18]

void GEO::Command::invoke ( void(*)(void)  fptr)
inline

Invokes a function with the stored arguments.

If the type or number of stored arguments do not match the function pointer, then an assertion failure is triggered.

Parameters
[in]fptrthe pointer to the member function to be called.
Note
Used by internal CommandInvoker mechanism.

Definition at line 727 of file command.h.

◆ is_visible()

bool GEO::Command::is_visible ( ) const
inline

Tests whether this Command is visible.

Return values
trueif this Command is visible
falseotherwise

Definition at line 259 of file command.h.

◆ is_visible_ptr()

bool * GEO::Command::is_visible_ptr ( )
inline

Gets a pointer to the visibility flag of this command.

Returns
a pointer to the visibility flag

Definition at line 268 of file command.h.

◆ name()

const std::string & GEO::Command::name ( ) const
inline

Gets the name of this command.

Returns
a const reference to the name of this command.

Definition at line 229 of file command.h.

◆ reset_current()

static void GEO::Command::reset_current ( )
inlinestatic

Resets the current command.

Definition at line 313 of file command.h.

◆ reset_factory_settings()

virtual void GEO::Command::reset_factory_settings ( )
virtual

Restores default parameter values for all parameters.

This is the function that is called when the user pushes the 'default' button.

Note
Regular client code should not need to use this function.

◆ set_current() [1/3]

static void GEO::Command::set_current ( Command command)
inlinestatic

Sets the current command.

Parameters
[in]commanda pointer to the command to be set as current
Note
Regular client code should not need to use this function.

Definition at line 323 of file command.h.

◆ set_current() [2/3]

template<class FPTR >
void GEO::Command::set_current ( const std::string &  prototype,
FPTR  tfun 
)
inlinestatic

Binds the current command to a function.

This makes the command dialog box display parameters that correspond to the arguments of the function, and whenever the 'apply' button is pushed, the function is invoked with the arguments. Example:

void my_command_impl(float x, float y, bool normalize) {
... do something
}
...
...
if(ImGui::MenuItem("my command")) {
"void my_command_impl(float x, float y, bool normalize)",
&my_command_impl
)
}
static void set_current(const std::string &prototype, FPTR tfun)
Binds the current command to a function.
Definition command.h:1394

The first argument (the string with the function prototype) is necessary to retrieve the names of the parameters. In addition, default values and tooltips may be specified, as follows:

"void my_command_impl( "
" float x=0 [this is the x coordinate], "
" float y=0 [this is the y coordinate], "
" bool normalize=true [normalize the vector]"
") [does something with a vector] ",
&my_command_impl
)

Each text in the square brackets corresponds to a tooltip attached to an argument. There can be also one for the function. The default values are those that are obtained at initialization, or those that are set when the 'default' button is pushed.

Template Parameters
FPTRfunction pointer type
Parameters
[in]prototypea string with the prototype of the function, as written in C++. In addition, the function and each parameter can be documented in square brackets.
[in]tfunthe function pointer.

Definition at line 1394 of file command.h.

◆ set_current() [3/3]

template<class T , class TFPTR >
void GEO::Command::set_current ( const std::string &  prototype,
T *  target,
TFPTR  tfun 
)
inlinestatic

Binds the current command to a member function of an object.

This makes the command dialog box display parameters that correspond to the arguments of the function, and whenever the 'apply' button is pushed, the function is invoked with the arguments. Example:

class MyCommands {
void my_command_impl(float x, float y, bool normalize) {
... do something
}
};
MyCommands my_commands;
...
...
if(ImGui::MenuItem("my command")) {
"void my_command_impl(float x, float y, bool normalize)",
&my_commands, &MyCommands::my_command_impl
)
}

The first argument (the string with the function prototype) is necessary to retrieve the names of the parameters. In addition, default values and tooltips may be specified, as follows:

"void my_command_impl( "
" float x=0 [this is the x coordinate], "
" float y=0 [this is the y coordinate], "
" bool normalize=true [normalize the vector]"
") [does something with a vector] ",
&my_commands, &MyCommands::my_command_impl
)

Each text in the square brackets corresponds to a tooltip attached to an argument. There can be also one for the function. The default values are those that are obtained at initialization, or those that are set when the 'default' button is pushed.

Template Parameters
Tobject class
TFPTRfunction pointer type, should be a member function of class T
Parameters
[in]prototypea string with the prototype of the function, as written in C++. In addition, the function and each parameter can be documented in square brackets.
[in]targeta pointer to the object, of class T
[in]tfunthe pointer to the member function

Definition at line 1406 of file command.h.

◆ set_invoker()

void GEO::Command::set_invoker ( CommandInvoker invoker)
inline

Sets the invoker.

The invoker is used internally to transmit the stored arguments to the parameters of a function.

Parameters
[in]invokera pointer to the CommandInvoker. Ownership is transferred to this Command.
Note
Regular client code should not need to use this function.

Definition at line 241 of file command.h.

◆ set_queued()

static void GEO::Command::set_queued ( Command command)
inlinestaticprotected

Definition at line 1026 of file command.h.

◆ string_arg_by_index()

std::string GEO::Command::string_arg_by_index ( index_t  i) const
inline

Gets the value of a string argument by index.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

Definition at line 405 of file command.h.

◆ uint_arg_by_index()

unsigned int GEO::Command::uint_arg_by_index ( index_t  i) const

Gets the value of an unsigned integer argument by index.

If the index is out of range, or if the argument is not of the correct type, then an assertion failure is triggered. If the stored value is negative, then it is clamped to 0, and a warning message is displayed on the console.

Parameters
[in]ithe index of the argument
Returns
the value of the argument
Note
Regular client code should not need to use this function.

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