A wrapper around the interfaces for MDL material instances and function calls. More...
Public Member Functions | |
General methods | |
Mdl_argument_editor (neuraylib::ITransaction *transaction, const char *name, neuraylib::IFactory *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_name () const |
Returns the MDL name of the material instance of function call. More... |
|
const char * | get_definition () const |
Returns the DB name of the corresponding material or function definition. More... |
|
Uint32 | get_parameter_count () const |
Returns the number of parameters. More... |
|
const char * | get_parameter_name (Uint32 index) const |
Returns the name of the parameter at index . More... |
|
const char * | get_parameter_type (const char *parameter_name) const |
Returns the type of a parameter. More... |
|
bool | is_parameter_type_uniform (const char *parameter_name) const |
Indicates whether the type of a parameter is uniform. More... |
|
const char * | get_argument_type (const char *argument_name) const |
Returns the type of an argument. More... |
|
const char * | get_return_type () const |
Returns the return type. More... |
|
bool | is_return_type_varying () const |
Indicates whether the return type is varying. More... |
|
Methods related to argument values (no attachments) | |
template<class T > | |
Sint32 | get_value (const char *argument_name, T &value) const |
Returns the value of a non-array argument. More... |
|
template<class T > | |
Sint32 | get_value (const char *argument_name, Size array_index, T &value) const |
Returns the value of an element of an array argument. More... |
|
template<class T > | |
Sint32 | set_value (const char *argument_name, const T &value) |
Sets the value of a non-array argument. More... |
|
template<class T > | |
Sint32 | set_value (const char *argument_name, Size array_index, const T &value) |
Sets the value of an element of an array argument. More... |
|
Methods related to attachments | |
bool | has_attachment (const char *argument_name) const |
Indicates whether an argument has an attachment. More... |
|
bool | has_attachment (const char *argument_name, Size array_index) const |
Indicates whether an element of an array argument has an attachment. More... |
|
const char * | get_attachment (const char *argument_name) const |
Returns the attachment of an argument. More... |
|
const char * | get_attachment (const char *argument_name, Size array_index) const |
Returns the attachment of an element of an array argument. More... |
|
Sint32 | set_attachment (const char *argument_name, const char *attachment_name) |
Sets the attachment of an argument. More... |
|
Sint32 | set_attachment (const char *argument_name, Size array_index, const char *attachment_name) |
Sets the attachment of an element of an array argument. More... |
|
Sint32 | remove_attachment (const char *argument_name) |
Removes the attachment of an argument. More... |
|
Sint32 | remove_attachment (const char *argument_name, Size array_index) |
Removes the attachment of an element of an array argument. More... |
|
Methods related to arrays | |
Sint32 | get_array_length (const char *argument_name, Size &size) const |
Returns the length of an array argument. More... |
|
Sint32 | set_array_length (const char *argument_name, Size size) |
Sets the length of an array argument. 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 three API calls (even more in case of arrays or if you do not use mi::set_value()). The argument editor offers a single method to support this task.
See mi::IMdl_material_instance and mi::IMdl_function_call for the underlying interfaces. See also mi::Mdl_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 use for all DB interactions. |
name | The name of the wrapped material instance or function call. |
factory | A pointer to the API component mi::neuraylib::IFactory. Needed by all mutable methods, can be NULL if only const methods are used. |
|
inline |
Returns the type of an argument.
argument_name | The name of the argument. |
NULL
if argument_name
is invalid.
|
inline |
Returns the length of an array argument.
argument_name | The name of the argument in question. | |
[out] | size | The current length of the array of the specified argument. |
false
.argument_name
is invalid.
|
inline |
Returns the attachment of an argument.
argument_name | The name of the argument in question. |
NULL
in case of failures.
|
inline |
Returns the attachment of an element of an array argument.
argument_name | The name of the argument in question. |
array_index | The array element of the argument in question. |
NULL
in case of failures.
|
inline |
Returns the DB name of the corresponding material or function definition.
|
inline |
Returns the MDL name of the material instance of function call.
|
inline |
Returns the number of parameters.
|
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 type of a parameter.
parameter_name | The name of the parameter. |
NULL
if parameter_name
is invalid.
|
inline |
Returns the return type.
NULL
.
|
inline |
Indicates whether the argument editor acts on a material instance or on a function call.
false
. Sint32 mi::Mdl_argument_editor::get_value | ( | const char * | argument_name, |
T & | value | ||
) | const |
Returns the value of a non-array argument.
argument_name | The name of the argument in question. | |
[out] | value | The current value of the specified argument. |
false
.argument_name
is invalid.Sint32 mi::Mdl_argument_editor::get_value | ( | const char * | argument_name, |
Size | array_index, | ||
T & | value | ||
) | const |
Returns the value of an element of an array argument.
argument_name | The name of the argument in question. | |
array_index | The array element of the argument in question. | |
[out] | value | The current value of the specified element of the array argument. |
false
.argument_name
or array_index
is invalid.
|
inline |
Indicates whether an argument has an attachment.
argument_name | The name of the argument in question. |
true
if the specified argument has an attachment, otherwise false
(including argument_name
is invalid).
|
inline |
Indicates whether an element of an array argument has an attachment.
argument_name | The name of the argument in question. |
array_index | The array element of the argument in question. |
true
if the specified element of the argument has an attachment, otherwise false
(including argument_name
or array_index
is invalid).
|
inline |
Indicates whether the type of a parameter is uniform.
parameter_name | The name of the parameter. |
true
if the parameter is uniform, otherwise false
(including invalid name
).
|
inline |
Indicates whether the return type is varying.
true
if the return type is varying, otherwise false
.
|
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.
|
inline |
Removes the attachment of an argument.
Attempts to remove a non-existing attachment is not considered a failure (as long as argument_name
is valid).
argument_name | The name of the argument in question. |
false
.argument_name
is invalid.
|
inline |
Removes the attachment of an element of an array argument.
Attempts to remove a non-existing attachment is not considered a failure (as long as argument_name
is valid).
argument_name | The name of the argument in question. |
array_index | The array element of the argument in question. |
false
.argument_name
or array_index
is invalid.Sets the length of an array argument.
argument_name | The name of the argument in question. |
size | The new length of the dynamic array of the specified argument. |
false
.argument_name
is invalid.
|
inline |
Sets the attachment of an argument.
argument_name | The name of the argument in question. |
attachment_name | The name of the attachment to set. |
false
.argument_name
is invalid.attachment_name
is invalid.
|
inline |
Sets the attachment of an element of an array argument.
argument_name | The name of the argument in question. |
array_index | The array element of the argument in question. |
attachment_name | The name of the attachment to set. |
false
.argument_name
or array_index
is invalid.attachment_name
is invalid.Sint32 mi::Mdl_argument_editor::set_value | ( | const char * | argument_name, |
const T & | value | ||
) |
Sets the value of a non-array argument.
argument_name | The name of the argument in question. |
value | The new value of the specified argument. |
false
.argument_name
is invalid.Sint32 mi::Mdl_argument_editor::set_value | ( | const char * | argument_name, |
Size | array_index, | ||
const T & | value | ||
) |
Sets the value of an element of an array argument.
argument_name | The name of the argument in question. |
array_index | The array element of the argument in question. |
value | The new value of the specified element of the array argument. |
false
.argument_name
or array_index
is invalid.