Graphite  Version 3
An experimental 3D geometry processing program
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. 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 Commandcurrent ()
 Gets the current command. More...
 
static Commandlatest ()
 Gets the latest command. More...
 
static Commandqueued ()
 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...
 

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 1027 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 1010 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 362 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 1042 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 312 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 417 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 401 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 1238 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 1294 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 1280 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 1252 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 1308 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 447 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 1266 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 489 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 514 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 542 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 572 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 605 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 640 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 677 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 716 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 467 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 772 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 794 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 818 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 844 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 873 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 904 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 937 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 972 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 752 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 265 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 274 of file command.h.

◆ latest()

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

Gets the latest command.

Returns
a pointer to the command that was last executed.

Used by playback mechanism ('F5' in applications).

Definition at line 322 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 235 of file command.h.

◆ queued()

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

Gets the queued command.

Returns
a pointer to the command that is about to be executed

Definition at line 330 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 348 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:1417

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 1417 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 1429 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 247 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 430 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: