Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Manages the GUI of a command with ImGUI. More...
#include <geogram_gfx/gui/command.h>
Public Member Functions | |
Command (const std::string &prototype) | |
Command constructor. More... | |
const std::string & | name () const |
Gets the name of this command. More... | |
void | set_invoker (CommandInvoker *invoker) |
Sets the invoker. More... | |
~Command () override | |
Command destructor. | |
bool | is_visible () const |
Tests whether this Command is visible. More... | |
bool * | is_visible_ptr () |
Gets a pointer to the visibility flag of this command. More... | |
virtual void | draw () |
Displays and manages the GUI of this Command. More... | |
virtual void | reset_factory_settings () |
Restores default parameter values for all parameters. More... | |
virtual void | apply () |
Gets the value of the parameters and does the task. More... | |
bool | bool_arg_by_index (index_t i) const |
Gets the value of a boolean argument by index. More... | |
int | int_arg_by_index (index_t i) const |
Gets the value of an integer argument by index. More... | |
unsigned int | uint_arg_by_index (index_t i) const |
Gets the value of an unsigned integer argument by index. More... | |
float | float_arg_by_index (index_t i) const |
Gets the value of a floating-point argument by index. More... | |
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. More... | |
std::string | string_arg_by_index (index_t i) const |
Gets the value of a string argument by index. More... | |
template<class T > | |
void | get_arg_by_index (index_t i, T &val) |
Gets the value of an argument by index. More... | |
template<class T > | |
void | invoke (T *target, void(T::*fptr)(void)) |
Invokes a member function with the stored arguments. More... | |
template<class T , class ARG0 > | |
void | invoke (T *target, void(T::*fptr)(ARG0)) |
Invokes a member function with the stored arguments. More... | |
template<class T , class ARG0 , class ARG1 > | |
void | invoke (T *target, void(T::*fptr)(ARG0, ARG1)) |
Invokes a member function with the stored arguments. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | invoke (void(*fptr)(void)) |
Invokes a function with the stored arguments. More... | |
template<class ARG0 > | |
void | invoke (void(*fptr)(ARG0)) |
Invokes a function with the stored arguments. More... | |
template<class ARG0 , class ARG1 > | |
void | invoke (void(*fptr)(ARG0, ARG1)) |
Invokes a function with the stored arguments. More... | |
template<class ARG0 , class ARG1 , class ARG2 > | |
void | invoke (void(*fptr)(ARG0, ARG1, ARG2)) |
Invokes a function with the stored arguments. More... | |
template<class ARG0 , class ARG1 , class ARG2 , class ARG3 > | |
void | invoke (void(*fptr)(ARG0, ARG1, ARG2, ARG3)) |
Invokes a function with the stored arguments. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<> | |
void | get_arg_by_index (index_t i, bool &val) |
Gets the value of an argument by index. More... | |
template<> | |
void | get_arg_by_index (index_t i, int &val) |
Gets the value of an argument by index. More... | |
template<> | |
void | get_arg_by_index (index_t i, unsigned int &val) |
Gets the value of an argument by index. More... | |
template<> | |
void | get_arg_by_index (index_t i, float &val) |
Gets the value of an argument by index. More... | |
template<> | |
void | get_arg_by_index (index_t i, double &val) |
Gets the value of an argument by index. More... | |
template<> | |
void | get_arg_by_index (index_t i, std::string &val) |
Gets the value of an argument by index. More... | |
Public Member Functions inherited from GEO::Counted | |
void | ref () const |
Increments the reference count. More... | |
void | unref () const |
Decrements the reference count. More... | |
bool | is_shared () const |
Check if the object is shared. More... | |
int | nb_refs () const |
Gets the number of references that point to this object. More... | |
Static Public Member Functions | |
template<class FPTR > | |
static void | set_current (const std::string &prototype, FPTR tfun) |
Binds the current command to a function. More... | |
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. More... | |
static void | flush_queue () |
Flushes the potentially queued command invokation. More... | |
static void | replay_latest () |
Replays the latest invoked command. | |
static Command * | current () |
Gets the current command. More... | |
static Command * | latest () |
Gets the latest command. More... | |
static Command * | queued () |
Gets the queued command. More... | |
static void | reset_current () |
Resets the current command. | |
static void | set_current (Command *command) |
Sets the current command. More... | |
Static Public Member Functions inherited from GEO::Counted | |
static void | ref (const Counted *counted) |
Increments the reference count. More... | |
static void | unref (const Counted *counted) |
Decrements the reference count. More... | |
Protected Member Functions | |
void | assert_nb_args_matches (index_t nb) |
Tests whether the number of declared arguments matches a specified number. More... | |
template<class T > | |
void | add_arg (const std::string &name, const T &default_val, const std::string &help="") |
Adds a parameter to this command. More... | |
template<class T > | |
void | create_arg (index_t i, const T &default_val) |
Creates an argument at a given index. More... | |
Protected Member Functions inherited from GEO::Counted | |
Counted () | |
Creates a reference counted object. More... | |
virtual | ~Counted () |
Destroys a reference counted object. More... | |
Manages the GUI of a command with ImGUI.
Client code will only need to use set_current()
GEO::Command::Command | ( | const std::string & | prototype | ) |
Command constructor.
[in] | prototype | a const reference to a string with the prototype of the function that implements the callback, as declared in the C++ sources. |
|
inlineprotected |
|
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).
|
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.
[in] | nb | expected number of arguments. |
|
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.
[in] | i | the index of the argument |
|
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
T | type of the parameter, deduced from default_val |
[in] | default_val | default value of the parameter |
|
inlinestatic |
|
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.
[in] | i | the index of the argument |
|
virtual |
Displays and manages the GUI of this Command.
|
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.
[in] | i | the index of the argument |
|
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.
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
|
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.
T | type of the argument |
[in] | i | the index of the argument |
[out] | val | a reference to the argument |
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.
[in] | i | the index of the argument |
|
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.
T | class of the target object |
ARG0 | type of the argument |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG1 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG1,ARG2 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG1,ARG2,ARG3 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG4 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG5 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG6 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
ARG0,ARG7 | types of the arguments |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
T | class of the target object |
[in] | target | the target object |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0 | type of the argument |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG1 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG1,ARG2 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG1,ARG2,ARG3 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG1,ARG2,ARG3,ARG4 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG5 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG6 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
ARG0,ARG7 | types of the arguments |
[in] | fptr | the pointer to the member function to be called. |
|
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.
[in] | fptr | the pointer to the member function to be called. |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inlinestatic |
|
virtual |
Restores default parameter values for all parameters.
This is the function that is called when the user pushes the 'default' button.
|
inlinestatic |
|
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:
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:
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.
FPTR | function pointer type |
[in] | prototype | a 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] | tfun | the function pointer. |
|
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:
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:
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.
T | object class |
TFPTR | function pointer type, should be a member function of class T |
[in] | prototype | a 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] | target | a pointer to the object, of class T |
[in] | tfun | the pointer to the member function |
|
inline |
Sets the invoker.
The invoker is used internally to transmit the stored arguments to the parameters of a function.
[in] | invoker | a pointer to the CommandInvoker. Ownership is transferred to this Command. |
|
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.
[in] | i | the index of the argument |
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.
[in] | i | the index of the argument |