A wrapper around the interfaces for MDL material instances and function calls. More...
Public Member Functions | |
General methods | |
Argument_editor (ITransaction *transaction, const char *name, IMdl_factory *mdl_factory) | |
Constructs an MDL argument editor for a fixed material instance or function call. More... | |
bool | is_valid () const |
Indicates whether the argument editor is in a valid state. More... | |
Element_type | get_type () const |
Indicates whether the argument editor acts on a material instance or on a function call. More... | |
const char * | get_definition () const |
Returns the DB name of the corresponding material or function definition. More... | |
const char * | get_mdl_definition () const |
Returns the MDL name of the corresponding material or function definition. More... | |
bool | is_array_constructor () const |
Indicates whether the argument editor acts on a function call that is an instance of the array constructor. More... | |
const IType * | get_return_type () const |
Returns the return type. More... | |
Size | get_parameter_count () const |
Returns the number of parameters. More... | |
const char * | get_parameter_name (Size index) const |
Returns the name of the parameter at index . More... | |
Size | get_parameter_index (const char *name) const |
Returns the index position of a parameter. More... | |
const IType_list * | get_parameter_types () const |
Returns the types of all parameters. More... | |
bool | is_parameter_enabled (Size index, IMdl_evaluator_api *evaluator) const |
Checks the enable_if condition of the given parameter. More... | |
const IExpression_list * | get_arguments () const |
Returns all arguments. More... | |
IExpression::Kind | get_argument_kind (Size parameter_index) const |
Returns the expression kind of an argument. More... | |
IExpression::Kind | get_argument_kind (const char *parameter_name) const |
Returns the expression kind of an argument. More... | |
Methods related to constant expressions for arguments | |
template<class T > | |
Sint32 | get_value (Size parameter_index, T &value) const |
Returns a non-compound argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | get_value (const char *parameter_name, T &value) const |
Returns a non-compound argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | get_value (Size parameter_index, Size component_index, T &value) const |
Returns a component of a compound argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | get_value (const char *parameter_name, Size component_index, T &value) const |
Returns a component of a compound argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | get_value (Size parameter_index, const char *field_name, T &value) const |
Returns a field of a struct argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | get_value (const char *parameter_name, const char *field_name, T &value) const |
Returns a field of a struct argument (values of constants only, no calls). More... | |
template<class T > | |
Sint32 | set_value (Size parameter_index, const T &value) |
Sets a non-compound argument. More... | |
template<class T > | |
Sint32 | set_value (const char *parameter_name, const T &value) |
Sets a non-compound argument. More... | |
template<class T > | |
Sint32 | set_value (Size parameter_index, Size component_index, const T &value) |
Sets a component of a compound argument. More... | |
template<class T > | |
Sint32 | set_value (const char *parameter_name, Size component_index, const T &value) |
Sets a component of a compound argument. More... | |
template<class T > | |
Sint32 | set_value (Size parameter_index, const char *field_name, const T &value) |
Sets a field of a struct argument. More... | |
template<class T > | |
Sint32 | set_value (const char *parameter_name, const char *field_name, const T &value) |
Sets a field of a struct argument. More... | |
Sint32 | get_array_length (Uint32 parameter_index, Size &size) const |
Returns the length of an array argument. More... | |
Sint32 | get_array_length (const char *parameter_name, Size &size) const |
Returns the length of an array argument. More... | |
Sint32 | set_array_size (Uint32 parameter_index, Size size) |
Sets the length of a dynamic array argument. More... | |
Sint32 | set_array_size (const char *parameter_name, Size size) |
Sets the length of a dynamic array argument. More... | |
Methods related to call expressions for arguments | |
const char * | get_call (Size parameter_index) const |
Returns an argument (call expressions only). More... | |
const char * | get_call (const char *parameter_name) const |
Returns an argument (call expressions only). More... | |
Sint32 | set_call (Size parameter_index, const char *call_name) |
Sets an argument (call expressions only). More... | |
Sint32 | set_call (const char *parameter_name, const char *call_name) |
Sets the call of an argument. More... | |
Methods related to member access. | |
ITransaction * | get_transaction () const |
Get the transaction. More... | |
IMdl_factory * | get_mdl_factory () const |
Get the MDL factory. More... | |
IValue_factory * | get_value_factory () const |
Get the value factory. More... | |
IExpression_factory * | get_expression_factory () const |
Get the expression factory. More... | |
const IScene_element * | get_scene_element () const |
Get the MDL function call or material instance. More... | |
IScene_element * | get_scene_element () |
Get the MDL function call or material instance. More... | |
Element_type | get_element_type () const |
Get the element type. More... | |
const std::string & | get_name () const |
Get the DB name of the MDL function call or material instance. More... | |
A wrapper around the interfaces for MDL material instances and function calls.
The purpose of the MDL argument editor is to simplify working with MDL material instances and function calls. There are two key benefits: unified treatment of material instance and function calls, and wrapping of API call sequences occurring in typical tasks into one single method call.
Unified treatment of material instances and function calls avoids duplication of code. For example, a GUI editor for the arguments can be essentially identical for materials and functions.
Furthermore, the argument editor wraps several API calls needed in typical tasks into one single method call. For example, changing the value of an argument typically needs at least seven API calls (even more in case of arrays or if you do not use mi::neuraylib::set_value()). The argument editor offers a single method to support this task.
See mi::neuraylib::IMaterial_instance and mi::neuraylib::IFunction_call for the underlying interfaces. See also mi::neuraylib::Definition_wrapper for a similar wrapper for MDL material and function definitions.
|
inline |
Constructs an MDL argument editor for a fixed material instance or function call.
transaction | The transaction to be used. |
name | The name of the wrapped material instance or function call. |
mdl_factory | A pointer to the API component mi::neuraylib::IMdl_factory. Needed by all mutable methods, can be NULL if only const methods are used. |
|
inline |
Returns the expression kind of an argument.
This method should be used to figure out whether mi::neuraylib::Argument_editor::get_value() or mi::neuraylib::Argument_editor::get_call() should be used for reading an argument.
|
inline |
Returns the expression kind of an argument.
This method should be used to figure out whether mi::neuraylib::Argument_editor::get_value() or mi::neuraylib::Argument_editor::get_call() should be used for reading an argument.
|
inline |
Returns all arguments.
|
inline |
Returns the length of an array argument.
If a literal 0
is passed for argument_index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
parameter_index | The index of the argument in question. | |
[out] | size | The current length of the array of the specified argument. |
false
.parameter_index
is out of range.
|
inline |
Returns the length of an array argument.
parameter_name | The name of the argument in question. | |
[out] | size | The current length of the array of the specified argument. |
false
.parameter_name
is invalid.
|
inline |
Returns an argument (call expressions only).
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. |
NULL
if parameter_index
is out of bounds or the argument expression is not a call.
|
inline |
Returns an argument (call expressions only).
parameter_name | The name of the argument in question. |
NULL
if parameter_name
is invalid or the argument expression is not a call.
|
inline |
Returns the DB name of the corresponding material or function definition.
|
inline |
Get the element type.
|
inline |
Get the expression factory.
|
inline |
Returns the MDL name of the corresponding material or function definition.
|
inline |
Get the MDL factory.
|
inline |
Get the DB name of the MDL function call or material instance.
|
inline |
Returns the number of parameters.
|
inline |
Returns the index position of a parameter.
name | The name of the parameter. |
name
is invalid.
|
inline |
Returns the name of the parameter at index
.
index | The index of the parameter. |
NULL
if index
is out of range.
|
inline |
Returns the types of all parameters.
|
inline |
Returns the return type.
NULL
.
|
inline |
Get the MDL function call or material instance.
|
inline |
Get the MDL function call or material instance.
|
inline |
Get the transaction.
|
inline |
Indicates whether the argument editor acts on a material instance or on a function call.
false
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | Size | parameter_index, |
T & | value | ||
) | const |
Returns a non-compound argument (values of constants only, no calls).
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | const char * | parameter_name, |
T & | value | ||
) | const |
Returns a non-compound argument (values of constants only, no calls).
parameter_name | The name of the argument in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_name
is invalid.T
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | Size | parameter_index, |
Size | component_index, | ||
T & | value | ||
) | const |
Returns a component of a compound argument (values of constants only, no calls).
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. | |
component_index | The index of the component in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_index
is out of range.component_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | const char * | parameter_name, |
Size | component_index, | ||
T & | value | ||
) | const |
Returns a component of a compound argument (values of constants only, no calls).
parameter_name | The name of the argument in question. | |
component_index | The index of the component in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_name
is invalid.component_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | Size | parameter_index, |
const char * | field_name, | ||
T & | value | ||
) | const |
Returns a field of a struct argument (values of constants only, no calls).
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. | |
field_name | The name of the struct field in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_index
is out of range.field_name
is invalid.T
. Sint32 mi::neuraylib::Argument_editor::get_value | ( | const char * | parameter_name, |
const char * | field_name, | ||
T & | value | ||
) | const |
Returns a field of a struct argument (values of constants only, no calls).
parameter_name | The name of the argument in question. | |
field_name | The name of the struct field in question. | |
[out] | value | The current value of the specified argument. |
false
.parameter_name
is invalid.field_name
is invalid.T
.
|
inline |
Get the value factory.
|
inline |
Indicates whether the argument editor acts on a function call that is an instance of the array constructor.
|
inline |
Checks the enable_if condition of the given parameter.
index | The index of the parameter. |
evaluator | A pointer to the API component mi::neuraylib::IMdl_evaluator_api. |
|
inline |
Indicates whether the argument editor is in a valid state.
The argument editor is valid if and only if the name passed in the constructor identifies a material instance or function call. This method should be immediately called after invoking the constructor. If it returns false
, no other methods of this class should be called.
Sets the length of a dynamic array argument.
If the current argument is a call expression, it will be replaced by a constant expression.
If a literal 0
is passed for argument_index
, the call is ambiguous. You need to explicitly cast the value to mi::Uint32.
parameter_index | The index of the argument in question. |
size | The new length of the array of the specified argument. |
false
.parameter_index
is out of range.
|
inline |
Sets the length of a dynamic array argument.
If the current argument is a call expression, it will be replaced by a constant expression.
parameter_name | The name of the argument in question. |
size | The new length of the array of the specified argument. |
false
.parameter_name
is invalid.
|
inline |
Sets an argument (call expressions only).
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. |
call_name | The name of the call to set. |
false
.parameter_index
is out of range.call_name
does not match the argument type.call_name
is invalid.
|
inline |
Sets the call of an argument.
parameter_name | The name of the argument in question. |
call_name | The name of the call to set. |
false
.parameter_name
is invalid.call_name
does not match the argument type.call_name
is invalid. Sint32 mi::neuraylib::Argument_editor::set_value | ( | Size | parameter_index, |
const T & | value | ||
) |
Sets a non-compound argument.
If the current argument is a call expression, it will be replaced by a constant expression.
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. |
value | The new value of the specified argument. |
false
.parameter_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::set_value | ( | const char * | parameter_name, |
const T & | value | ||
) |
Sets a non-compound argument.
If the current argument is a call expression, it will be replaced by a constant expression.
parameter_name | The name of the argument in question. |
value | The new value of the specified argument. |
false
.parameter_name
is invalid.T
. Sint32 mi::neuraylib::Argument_editor::set_value | ( | Size | parameter_index, |
Size | component_index, | ||
const T & | value | ||
) |
Sets a component of a compound argument.
If the current argument is a call expression, it will be replaced by a constant expression.
This method does not change the size of dynamic arrays. You need to call explicitly mi::neuraylib::Argument_editor::set_array_size() for that.
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. |
component_index | The index of the component in question. |
value | The new value of the specified argument. |
false
.parameter_index
is out of range.component_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::set_value | ( | const char * | parameter_name, |
Size | component_index, | ||
const T & | value | ||
) |
Sets a component of a compound argument.
If the current argument is a call expression, it will be replaced by a constant expression.
This method does not change the size of dynamic arrays. You need to call explicitly mi::neuraylib::Argument_editor::set_array_size() for that.
parameter_name | The name of the argument in question. |
component_index | The index of the component in question. |
value | The new value of the specified argument. |
false
.parameter_name
is invalid.component_index
is out of range.T
. Sint32 mi::neuraylib::Argument_editor::set_value | ( | Size | parameter_index, |
const char * | field_name, | ||
const T & | value | ||
) |
Sets a field of a struct argument.
If the current argument is a call expression, it will be replaced by a constant expression.
If a literal 0
is passed for parameter_index
, the call is ambiguous. You need to explicitly cast the value to mi::Size.
parameter_index | The index of the argument in question. |
field_name | The name of the struct_field in question. |
value | The new value of the specified argument. |
false
.parameter_index
is out of range.field_name
is invalid.T
. Sint32 mi::neuraylib::Argument_editor::set_value | ( | const char * | parameter_name, |
const char * | field_name, | ||
const T & | value | ||
) |
Sets a field of a struct argument.
If the current argument is a call expression, it will be replaced by a constant expression.
parameter_name | The name of the argument in question. |
field_name | The name of the struct_field in question. |
value | The new value of the specified argument. |
false
.parameter_name
is invalid.field_name
is invalid.T
.