7#ifndef MI_NEURAYLIB_ARGUMENT_EDITOR_H
8#define MI_NEURAYLIB_ARGUMENT_EDITOR_H
27class IMdl_execution_context;
81 bool intent_to_edit =
false);
393 Sint32 get_value(
const char* parameter_name,
const char* field_name, T& value)
const;
596 Sint32 set_value(
const char* parameter_name,
const char* field_name,
const T& value);
679 const char*
get_call(
const char* parameter_name)
const;
720 Sint32 set_call(
const char* parameter_name,
const char* call_name);
748 const std::string&
get_name()
const;
753 void promote_to_edit_if_needed();
778 = m_mdl_factory ? m_mdl_factory->create_value_factory( m_transaction.get()) : 0;
780 = m_mdl_factory ? m_mdl_factory->create_expression_factory( m_transaction.get()) : 0;
782 if( intent_to_edit) {
785 m_old_access = m_edit;
789 m_type = m_access ? m_access->get_element_type() :
static_cast<Element_type>( 0);
795 return m_access.is_valid_interface();
803 return m_access->is_valid( context);
811 promote_to_edit_if_needed();
813 return m_edit->repair( flags, context);
826 return m_access->get_function_definition();
834 return m_access->get_mdl_function_definition();
842 return m_access->is_array_constructor();
850 return m_access->is_declarative();
858 return m_access->is_material();
866 return m_access->get_parameter_count();
874 return m_access->get_parameter_name( parameter_index);
882 return m_access->get_parameter_index( name);
890 return m_access->get_return_type();
898 return m_access->get_parameter_types();
910 m_transaction.get(), m_value_factory.get(), m_access.get(), index, 0));
913 return b->get_value();
921 promote_to_edit_if_needed();
923 return m_edit->reset_argument( index);
931 promote_to_edit_if_needed();
933 return m_edit->reset_argument( name);
942 return m_access->get_arguments();
977 if( !argument_constant)
981 return result == 0 ? 0 : -5;
996 if( !argument_constant)
1000 return result == 0 ? 0 : -5;
1015 if( !argument_constant)
1019 return result == 0 ? 0 : -5;
1034 if( !argument_constant)
1038 return result == 0 ? 0 : -5;
1053 if( !argument_constant)
1057 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1072 if( !argument_constant)
1076 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1081 Size parameter_index,
const char* field_name, T& value)
const
1092 if( !argument_constant)
1096 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1101 const char* parameter_name,
const char* field_name, T& value)
const
1112 if( !argument_constant)
1116 return result == 0 ? 0 : (result == -3 ? -3 : -5);
1125 promote_to_edit_if_needed();
1127 if( m_edit->is_default())
1139 m_expression_factory->create_constant( new_value.
get()));
1140 result = m_edit->set_argument( parameter_index, new_expression.
get());
1151 promote_to_edit_if_needed();
1153 if( m_edit->is_default())
1165 m_expression_factory->create_constant( new_value.
get()));
1166 result = m_edit->set_argument( parameter_name, new_expression.
get());
1177 promote_to_edit_if_needed();
1179 if( m_edit->is_default())
1189 if( !type->is_immediate_sized())
1190 new_value->set_size( n);
1195 m_expression_factory->create_constant( new_value.
get()));
1196 result = m_edit->set_argument( parameter_index, new_expression.
get());
1207 promote_to_edit_if_needed();
1209 if( m_edit->is_default())
1219 if( !type->is_immediate_sized())
1220 new_value->set_size( n);
1225 m_expression_factory->create_constant( new_value.
get()));
1226 result = m_edit->set_argument( parameter_name, new_expression.
get());
1237 promote_to_edit_if_needed();
1239 if( m_edit->is_default())
1253 return result == -3 ? -3 : -5;
1254 result = m_edit->set_argument( parameter_index, new_argument.
get());
1263 return result == -3 ? -3 : -5;
1265 m_expression_factory->create_constant( new_value.
get()));
1266 result = m_edit->set_argument( parameter_index, new_expression.
get());
1278 promote_to_edit_if_needed();
1280 if( m_edit->is_default())
1294 return result == -3 ? -3 : -5;
1295 result = m_edit->set_argument( parameter_name, new_argument.
get());
1304 return result == -3 ? -3 : -5;
1306 m_expression_factory->create_constant( new_value.
get()));
1307 result = m_edit->set_argument( parameter_name, new_expression.
get());
1315 Size parameter_index,
const char* field_name,
const T& value)
1320 promote_to_edit_if_needed();
1322 if( m_edit->is_default())
1336 return result == -3 ? -3 : -5;
1337 result = m_edit->set_argument( parameter_index, new_argument.
get());
1346 return result == -3 ? -3 : -5;
1348 m_expression_factory->create_constant( new_value.
get()));
1349 result = m_edit->set_argument( parameter_index, new_expression.
get());
1357 const char* parameter_name,
const char* field_name,
const T& value)
1362 promote_to_edit_if_needed();
1364 if( m_edit->is_default())
1378 return result == -3 ? -3 : -5;
1379 result = m_edit->set_argument( parameter_name, new_argument.
get());
1388 return result == -3 ? -3 : -5;
1390 m_expression_factory->create_constant( new_value.
get()));
1391 result = m_edit->set_argument( parameter_name, new_expression.
get());
1408 if( !argument_constant)
1413 size = value->get_size();
1428 if( !argument_constant)
1433 size = value->get_size();
1442 promote_to_edit_if_needed();
1444 if( m_edit->is_default())
1459 Sint32 result = new_value->set_size( size);
1462 result = m_edit->set_argument( parameter_index, new_argument.
get());
1472 Sint32 result = new_value->set_size( size);
1476 m_expression_factory->create_constant( new_value.
get()));
1477 result = m_edit->set_argument( parameter_index, new_expression.
get());
1488 promote_to_edit_if_needed();
1490 if( m_edit->is_default())
1505 Sint32 result = new_value->set_size( size);
1508 result = m_edit->set_argument( parameter_name, new_argument.
get());
1518 Sint32 result = new_value->set_size( size);
1522 m_expression_factory->create_constant( new_value.
get()));
1523 result = m_edit->set_argument( parameter_name, new_expression.
get());
1539 return argument->get_call();
1552 return argument->get_call();
1560 promote_to_edit_if_needed();
1565 return m_edit->set_argument( parameter_index, new_argument.
get());
1573 promote_to_edit_if_needed();
1578 return m_edit->set_argument( parameter_name, new_argument.
get());
1583 m_transaction->retain();
1584 return m_transaction.get();
1589 m_mdl_factory->retain();
1590 return m_mdl_factory.get();
1595 m_value_factory->retain();
1596 return m_value_factory.get();
1601 m_expression_factory->retain();
1602 return m_expression_factory.get();
1608 return m_access.get();
1613 promote_to_edit_if_needed();
1616 return m_edit.get();
1629inline void Argument_editor::promote_to_edit_if_needed()
1636 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:793
bool is_declarative() const
Indicates whether the corresponding material or function definition is declarative.
Definition: argument_editor.h:845
IExpression::Kind get_argument_kind(Size parameter_index) const
Returns the expression kind of an argument.
Definition: argument_editor.h:945
IValue_factory * get_value_factory() const
Get the value factory.
Definition: argument_editor.h:1593
Sint32 set_value(Size parameter_index, const T &value)
Sets an argument.
Definition: argument_editor.h:1120
Sint32 set_array_size(Uint32 parameter_index, Size size)
Sets the length of a deferred-sized array argument.
Definition: argument_editor.h:1437
const std::string & get_name() const
Get the DB name of the MDL function call or material instance.
Definition: argument_editor.h:1624
bool is_material() const
Indicates whether the argument editor acts on a material instance.
Definition: argument_editor.h:853
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:837
Sint32 get_value(Size parameter_index, T &value) const
Returns an argument (values of constants only, no calls).
Definition: argument_editor.h:966
const char * get_definition() const
Returns the DB name of the corresponding material or function definition.
Definition: argument_editor.h:821
IExpression_factory * get_expression_factory() const
Get the expression factory.
Definition: argument_editor.h:1599
const char * get_parameter_name(Size index) const
Returns the name of the parameter at index.
Definition: argument_editor.h:869
Element_type get_element_type() const
Get the element type.
Definition: argument_editor.h:1619
Size get_parameter_count() const
Returns the number of parameters.
Definition: argument_editor.h:861
Sint32 set_call(Size parameter_index, const char *call_name)
Sets an argument (call expressions only).
Definition: argument_editor.h:1555
const IFunction_call * get_scene_element() const
Get the MDL function call or material instance.
Definition: argument_editor.h:1605
Size get_parameter_index(const char *name) const
Returns the index position of a parameter.
Definition: argument_editor.h:877
bool is_parameter_enabled(Size index, IMdl_evaluator_api *evaluator) const
Checks the enable_if condition of the given parameter.
Definition: argument_editor.h:901
ITransaction * get_transaction() const
Get the transaction.
Definition: argument_editor.h:1581
Sint32 reset_argument(Size index)
Resets the argument at index.
Definition: argument_editor.h:916
const IExpression_list * get_arguments() const
Returns all arguments.
Definition: argument_editor.h:937
const IType * get_return_type() const
Returns the return type.
Definition: argument_editor.h:885
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:798
Element_type get_type() const
Indicates whether the argument editor acts on a material instance or on a function call.
Definition: argument_editor.h:816
const char * get_call(Size parameter_index) const
Returns an argument (call expressions only).
Definition: argument_editor.h:1529
const char * get_mdl_definition() const
Returns the MDL name of the corresponding material or function definition.
Definition: argument_editor.h:829
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:768
mi::Sint32 repair(mi::Uint32 flags, IMdl_execution_context *context)
Attempts to repair an invalid material instance or function call.
Definition: argument_editor.h:806
IMdl_factory * get_mdl_factory() const
Get the MDL factory.
Definition: argument_editor.h:1587
Sint32 get_array_length(Uint32 parameter_index, Size &size) const
Returns the length of an array argument.
Definition: argument_editor.h:1397
const IType_list * get_parameter_types() const
Returns the types of all parameters.
Definition: argument_editor.h:893
An indirect call expression.
Definition: iexpression.h:175
A constant expression.
Definition: iexpression.h:96
The interface for creating expressions.
Definition: iexpression.h:650
An ordered collection of expressions identified by name or index.
Definition: iexpression.h:317
Kind
The possible kinds of expressions.
Definition: iexpression.h:53
@ EK_CONSTANT
A constant expression. See mi::neuraylib::IExpression_constant.
Definition: iexpression.h:55
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 *errors) 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:82
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:452
An ordered collection of types identified by name or index.
Definition: itype.h:646
The interface to MDL types.
Definition: itype.h:151
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.