7#ifndef MI_NEURAYLIB_ARGUMENT_EDITOR_H
8#define MI_NEURAYLIB_ARGUMENT_EDITOR_H
27class IMdl_execution_context;
81 bool intent_to_edit =
false);
390 Sint32 get_value(
const char* parameter_name,
const char* field_name, T& value)
const;
593 Sint32 set_value(
const char* parameter_name,
const char* field_name,
const T& value);
676 const char*
get_call(
const char* parameter_name)
const;
711 Sint32 set_call(
const char* parameter_name,
const char* call_name);
739 const std::string&
get_name()
const;
744 void promote_to_edit_if_needed();
769 = m_mdl_factory ? m_mdl_factory->create_value_factory( m_transaction.get()) : 0;
771 = m_mdl_factory ? m_mdl_factory->create_expression_factory( m_transaction.get()) : 0;
773 if( intent_to_edit) {
776 m_old_access = m_edit;
780 m_type = m_access ? m_access->get_element_type() :
static_cast<Element_type>( 0);
786 return m_access.is_valid_interface();
794 return m_access->is_valid( context);
802 promote_to_edit_if_needed();
804 return m_edit->repair( flags, context);
817 return m_access->get_function_definition();
825 return m_access->get_mdl_function_definition();
833 return m_access->is_array_constructor();
841 return m_access->is_material();
849 return m_access->get_parameter_count();
857 return m_access->get_parameter_name( parameter_index);
865 return m_access->get_parameter_index( name);
873 return m_access->get_return_type();
881 return m_access->get_parameter_types();
893 m_transaction.get(), m_value_factory.get(), m_access.get(), index, 0));
896 return b->get_value();
904 promote_to_edit_if_needed();
906 return m_edit->reset_argument( index);
914 promote_to_edit_if_needed();
916 return m_edit->reset_argument( name);
925 return m_access->get_arguments();
960 if( !argument_constant)
964 return result == 0 ? 0 : -5;
979 if( !argument_constant)
983 return result == 0 ? 0 : -5;
998 if( !argument_constant)
1002 return result == 0 ? 0 : -5;
1017 if( !argument_constant)
1021 return result == 0 ? 0 : -5;
1036 if( !argument_constant)
1040 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1055 if( !argument_constant)
1059 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1064 Size parameter_index,
const char* field_name, T& value)
const
1075 if( !argument_constant)
1079 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1084 const char* parameter_name,
const char* field_name, T& value)
const
1095 if( !argument_constant)
1099 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1108 promote_to_edit_if_needed();
1110 if( m_edit->is_default())
1122 m_expression_factory->create_constant( new_value.
get()));
1123 result = m_edit->set_argument( parameter_index, new_expression.
get());
1134 promote_to_edit_if_needed();
1136 if( m_edit->is_default())
1148 m_expression_factory->create_constant( new_value.
get()));
1149 result = m_edit->set_argument( parameter_name, new_expression.
get());
1160 promote_to_edit_if_needed();
1162 if( m_edit->is_default())
1172 if( !type->is_immediate_sized())
1173 new_value->set_size( n);
1178 m_expression_factory->create_constant( new_value.
get()));
1179 result = m_edit->set_argument( parameter_index, new_expression.
get());
1190 promote_to_edit_if_needed();
1192 if( m_edit->is_default())
1202 if( !type->is_immediate_sized())
1203 new_value->set_size( n);
1208 m_expression_factory->create_constant( new_value.
get()));
1209 result = m_edit->set_argument( parameter_name, new_expression.
get());
1220 promote_to_edit_if_needed();
1222 if( m_edit->is_default())
1236 return result == -3 ? -3 : -5;
1237 result = m_edit->set_argument( parameter_index, new_argument.
get());
1246 return result == -3 ? -3 : -5;
1248 m_expression_factory->create_constant( new_value.
get()));
1249 result = m_edit->set_argument( parameter_index, new_expression.
get());
1261 promote_to_edit_if_needed();
1263 if( m_edit->is_default())
1277 return result == -3 ? -3 : -5;
1278 result = m_edit->set_argument( parameter_name, new_argument.
get());
1287 return result == -3 ? -3 : -5;
1289 m_expression_factory->create_constant( new_value.
get()));
1290 result = m_edit->set_argument( parameter_name, new_expression.
get());
1298 Size parameter_index,
const char* field_name,
const T& value)
1303 promote_to_edit_if_needed();
1305 if( m_edit->is_default())
1319 return result == -3 ? -3 : -5;
1320 result = m_edit->set_argument( parameter_index, new_argument.
get());
1329 return result == -3 ? -3 : -5;
1331 m_expression_factory->create_constant( new_value.
get()));
1332 result = m_edit->set_argument( parameter_index, new_expression.
get());
1340 const char* parameter_name,
const char* field_name,
const T& value)
1345 promote_to_edit_if_needed();
1347 if( m_edit->is_default())
1361 return result == -3 ? -3 : -5;
1362 result = m_edit->set_argument( parameter_name, new_argument.
get());
1371 return result == -3 ? -3 : -5;
1373 m_expression_factory->create_constant( new_value.
get()));
1374 result = m_edit->set_argument( parameter_name, new_expression.
get());
1391 if( !argument_constant)
1396 size = value->get_size();
1411 if( !argument_constant)
1416 size = value->get_size();
1425 promote_to_edit_if_needed();
1427 if( m_edit->is_default())
1442 Sint32 result = new_value->set_size( size);
1445 result = m_edit->set_argument( parameter_index, new_argument.
get());
1455 Sint32 result = new_value->set_size( size);
1459 m_expression_factory->create_constant( new_value.
get()));
1460 result = m_edit->set_argument( parameter_index, new_expression.
get());
1471 promote_to_edit_if_needed();
1473 if( m_edit->is_default())
1488 Sint32 result = new_value->set_size( size);
1491 result = m_edit->set_argument( parameter_name, new_argument.
get());
1501 Sint32 result = new_value->set_size( size);
1505 m_expression_factory->create_constant( new_value.
get()));
1506 result = m_edit->set_argument( parameter_name, new_expression.
get());
1522 return argument->get_call();
1535 return argument->get_call();
1543 promote_to_edit_if_needed();
1548 return m_edit->set_argument( parameter_index, new_argument.
get());
1556 promote_to_edit_if_needed();
1561 return m_edit->set_argument( parameter_name, new_argument.
get());
1566 m_transaction->retain();
1567 return m_transaction.get();
1572 m_mdl_factory->retain();
1573 return m_mdl_factory.get();
1578 m_value_factory->retain();
1579 return m_value_factory.get();
1584 m_expression_factory->retain();
1585 return m_expression_factory.get();
1591 return m_access.get();
1596 promote_to_edit_if_needed();
1599 return m_edit.get();
1612inline void Argument_editor::promote_to_edit_if_needed()
1619 m_old_access = m_access;
Handle class template for interfaces, automatizing the lifetime control via reference counting.
Definition: handle.h:113
A wrapper around the interface for MDL material instances and function calls.
Definition: argument_editor.h:57
bool is_valid() const
Indicates whether the argument editor is in a valid state.
Definition: argument_editor.h:784
IExpression::Kind get_argument_kind(Size parameter_index) const
Returns the expression kind of an argument.
Definition: argument_editor.h:928
IValue_factory * get_value_factory() const
Get the value factory.
Definition: argument_editor.h:1576
Sint32 set_value(Size parameter_index, const T &value)
Sets an argument.
Definition: argument_editor.h:1103
Sint32 set_array_size(Uint32 parameter_index, Size size)
Sets the length of a deferred-sized array argument.
Definition: argument_editor.h:1420
const std::string & get_name() const
Get the DB name of the MDL function call or material instance.
Definition: argument_editor.h:1607
bool is_material() const
Indicates whether the argument editor acts on a material instance.
Definition: argument_editor.h:836
bool is_array_constructor() const
Indicates whether the argument editor acts on a function call that is an instance of the array constr...
Definition: argument_editor.h:828
Sint32 get_value(Size parameter_index, T &value) const
Returns an argument (values of constants only, no calls).
Definition: argument_editor.h:949
const char * get_definition() const
Returns the DB name of the corresponding material or function definition.
Definition: argument_editor.h:812
IExpression_factory * get_expression_factory() const
Get the expression factory.
Definition: argument_editor.h:1582
const char * get_parameter_name(Size index) const
Returns the name of the parameter at index.
Definition: argument_editor.h:852
Element_type get_element_type() const
Get the element type.
Definition: argument_editor.h:1602
Size get_parameter_count() const
Returns the number of parameters.
Definition: argument_editor.h:844
Sint32 set_call(Size parameter_index, const char *call_name)
Sets an argument (call expressions only).
Definition: argument_editor.h:1538
const IFunction_call * get_scene_element() const
Get the MDL function call or material instance.
Definition: argument_editor.h:1588
Size get_parameter_index(const char *name) const
Returns the index position of a parameter.
Definition: argument_editor.h:860
bool is_parameter_enabled(Size index, IMdl_evaluator_api *evaluator) const
Checks the enable_if condition of the given parameter.
Definition: argument_editor.h:884
ITransaction * get_transaction() const
Get the transaction.
Definition: argument_editor.h:1564
Sint32 reset_argument(Size index)
Resets the argument at index.
Definition: argument_editor.h:899
const IExpression_list * get_arguments() const
Returns all arguments.
Definition: argument_editor.h:920
const IType * get_return_type() const
Returns the return type.
Definition: argument_editor.h:868
bool is_valid_instance(IMdl_execution_context *context) const
Indicates whether the material instance or function call referenced by this argument editor is valid.
Definition: argument_editor.h:789
Element_type get_type() const
Indicates whether the argument editor acts on a material instance or on a function call.
Definition: argument_editor.h:807
const char * get_call(Size parameter_index) const
Returns an argument (call expressions only).
Definition: argument_editor.h:1512
const char * get_mdl_definition() const
Returns the MDL name of the corresponding material or function definition.
Definition: argument_editor.h:820
Argument_editor(ITransaction *transaction, const char *name, IMdl_factory *mdl_factory, bool intent_to_edit=false)
Constructs an MDL argument editor for a fixed material instance or function call.
Definition: argument_editor.h:759
mi::Sint32 repair(mi::Uint32 flags, IMdl_execution_context *context)
Attempts to repair an invalid material instance or function call.
Definition: argument_editor.h:797
IMdl_factory * get_mdl_factory() const
Get the MDL factory.
Definition: argument_editor.h:1570
Sint32 get_array_length(Uint32 parameter_index, Size &size) const
Returns the length of an array argument.
Definition: argument_editor.h:1380
const IType_list * get_parameter_types() const
Returns the types of all parameters.
Definition: argument_editor.h:876
An indirect call expression.
Definition: iexpression.h:173
A constant expression.
Definition: iexpression.h:94
The interface for creating expressions.
Definition: iexpression.h:648
An ordered collection of expressions identified by name or index.
Definition: iexpression.h:315
Kind
The possible kinds of expressions.
Definition: iexpression.h:51
@ EK_CONSTANT
A constant expression. See mi::neuraylib::IExpression_constant.
Definition: iexpression.h:53
This interface represents a function call.
Definition: ifunction_call.h:52
Provides access to various functions for the evaluation of MDL expressions.
Definition: imdl_evaluator_api.h:27
virtual const IValue_bool * is_function_parameter_enabled(ITransaction *trans, IValue_factory *fact, const IFunction_call *call, Size index, Sint32 *error) const =0
Evaluates if a function call parameter is enabled, i.e., the enable_if condition evaluates to true).
The execution context can be used to query status information like error and warning messages concern...
Definition: imdl_execution_context.h:131
Factory for various MDL interfaces and functions.
Definition: imdl_factory.h:53
virtual Element_type get_element_type() const =0
Indicates the actual scene element represented by interfaces derived from this interface.
A transaction provides a consistent view on the database.
Definition: itransaction.h:83
virtual const base::IInterface * access(const char *name)=0
Retrieves an element from the database.
virtual base::IInterface * edit(const char *name)=0
Retrieves an element from the database and returns it ready for editing.
The type of kind array.
Definition: itype.h:349
An ordered collection of types identified by name or index.
Definition: itype.h:540
The interface to MDL types.
Definition: itype.h:51
A value of type array.
Definition: ivalue.h:403
The interface for creating values.
Definition: ivalue.h:660
Handle<Interface> make_handle_dup(Interface *iptr)
Converts passed-in interface pointer to a handle, without taking interface over.
Definition: handle.h:439
Handle<New_interface> get_interface() const
Returns a new handle for a possibly different interface type, similar to a dynamic cast,...
Definition: handle.h:353
Interface * get() const
Access to the interface. Returns 0 for an invalid interface.
Definition: handle.h:294
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
signed int Sint32
32-bit signed integer.
Definition: types.h:46
#define mi_neuray_assert(expr)
If expr evaluates to true this macro shall have no effect.
Definition: assert.h:67
mi::Sint32 set_value(mi::neuraylib::IValue *value, const T &v)
Simplifies setting the value of mi::neuraylib::IValue from the corresponding classes from the base an...
Definition: ivalue.h:925
mi::Sint32 get_value(const mi::neuraylib::IValue *value, T &v)
Simplifies reading the value of mi::neuraylib::IValue into the corresponding classes from the base an...
Definition: ivalue.h:1254
Element_type
Distinguishes scene elements.
Definition: iscene_element.h:30
Smart-pointer handle class for interfaces, const and non-const version.
Expressions of the MDL type system.
Scene element Function_call.
Scene element Material_instance.
API component that gives access to the MDL evaluator.
API component that gives access to some MDL functionality.
Types of the MDL type system.
Values of the MDL type system.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Assertions and compile-time assertions.