14 #include <QtCore/QHash>
27 typedef class Node *creator(
unsigned int );
30 Template *m_pTemplate;
38 const QString &sDisplayName, creator *pCreator,
int iVersion = 0,
int iStreamVersion = 0 );
40 const ClassDesc *Parent(
unsigned int iIndex = 0 )
const;
42 const QString &Name(
void )
const;
44 const QString &DisplayName(
void )
const;
46 void SetDisplayName(
const QString &sName );
49 bool IsDerivedFrom(
const ClassDesc *pClass )
const;
51 class Node *CreateInstances(
int iCount = 1 )
const;
65 int Version(
void )
const;
91 #define DECLARE_CLASS \
93 static mudbox::ClassDesc s_cMyClass; \
95 virtual const mudbox::ClassDesc *RuntimeClass( void ) const { return &s_cMyClass; }; \
96 static const mudbox::ClassDesc *StaticClass( void ); \
97 static mudbox::Node *CreateInstances( unsigned int iCount = 1 );
99 #define IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, instanceclass, version, streamversion ) \
100 mudbox::ClassDesc name::s_cMyClass( parent0::StaticClass(), parent1::StaticClass(), #name, displayname, name::CreateInstances, version, streamversion ); \
101 const mudbox::ClassDesc *name::StaticClass( void ) { return &s_cMyClass; }; \
102 mudbox::Node *name::CreateInstances( unsigned int iCount ) \
104 if ( iCount > 1 ) { p = new instanceclass[iCount]; for ( unsigned int i = 0; i < iCount; i++ ) p[i].Initialize(); } \
105 else { p = new instanceclass; p->Initialize(); }; \
108 #define IMPLEMENT_SDK_VCLASS( name, parent, displayname, instanceclass, streamversion ) IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, instanceclass, 0, streamversion )
109 #define IMPLEMENT_SDK_CLASS( name, parent, displayname, instanceclass ) IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, instanceclass, 0, 0 )
110 #define IMPLEMENT_VCLASS2( name, parent0, parent1, displayname, version ) IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, version, 0 )
111 #define IMPLEMENT_VCLASS( name, parent, displayname, version ) IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, version, 0 )
112 #define IMPLEMENT_CLASS2( name, parent0, parent1, displayname ) IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, 0, 0 )
113 #define IMPLEMENT_CLASS( name, parent, displayname ) IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, 0 )
114 #define IMPLEMENT_SCLASS( name, parent, displayname, streamversion ) IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, streamversion )
145 #define IMPLEMENT_SCLASS2( name, parent0, parent1, displayname, streamversion ) IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, 0, streamversion )
209 unsigned int TargetCount(
void )
const;
211 Attribute *Target(
unsigned int iIndex )
const;
219 virtual AttributeType Type(
void )
const;
226 void SetName(
const QString &sName );
230 void SetCategory(
const QString &sCategory,
bool bSeparator =
false );
232 bool Separator(
void )
const;
234 void SetSeparator(
bool bSeparator );
236 bool Const(
void )
const;
238 void SetConst(
bool bConst );
240 bool InstantEdit(
void )
const;
243 void SetInstantEdit(
bool bOn );
245 bool Visible(
void )
const;
247 void SetVisible(
bool bVisible );
251 void SetToolTip(
const QString &sToolTip );
253 unsigned int Size(
void )
const;
257 float LabelWidth(
void )
const;
259 void SetLabelWidth(
float fLabelWidth );
261 int Index(
void )
const;
263 void SetIndex(
int iIndex );
266 Node *Owner(
void )
const;
268 virtual void Serialize(
Stream &
s );
272 virtual QString AsString(
bool bLocalized =
false )
const;
276 virtual void SetFromString(
const QString &sValue,
bool bInternal =
true,
bool bLocalized =
false );
283 void ClearTargets(
void );
285 void ClearSource(
void );
288 virtual void AddTarget(
Attribute &cTarget,
bool bInternal =
false );
291 void Connect(
Attribute &cSource,
bool bInternal =
false );
293 virtual void UpdateTargets(
void );
300 virtual const ClassDesc* TargetType(
void )
const;
303 virtual void SetPointerValue(
Node *pValue,
bool bLink =
true );
306 virtual Node *PointerValue(
void )
const;
308 virtual bool ValidatePointerValue(
const Node *pValue );
319 void SetOwner(
Node *pOwner );
334 virtual unsigned int ParameterCount(
void )
const;
336 virtual QString ParameterName(
unsigned int iIndex )
const;
338 virtual QString ParameterValue(
unsigned int iIndex )
const;
340 virtual void SetParameterValue(
const QString &sName,
const QString &sValue );
344 void LogTargets(
void );
346 void LogSource(
void );
348 void CheckValidity(
void );
370 void Uninstall(
void );
393 template <
typename type >
418 for (
unsigned int i = 0; i < TargetCount(); i++ )
420 if ( Target(i)->Size() == Size() )
433 if ( cTarget.
Size() )
436 if ( pT->
Value() != Value() )
445 virtual QString AsString(
bool bLocalized =
false )
const;
447 virtual void SetFromString(
const QString &sValue,
bool bInternal =
true,
bool =
false );
456 #define OPERATORS_NOEXCMARK( type ) \
458 inline operator type( void ) const { return AttributeInstance<type>::Value(); }; \
460 inline type const &operator ~( void ) const { return AttributeInstance<type>::Value(); }; \
462 inline type operator =( type cValue ) { SetValue( cValue, true ); return cValue; }; \
464 inline type operator =( const AttributeInstance<type> &cValue ) { SetValue( cValue.AttributeInstance<type>::Value(), true ); return cValue; }; \
466 inline bool operator ==( type cValue ) const { return AttributeInstance<type>::Value() == cValue; }; \
468 inline bool operator !=( type cValue ) const { return AttributeInstance<type>::Value() != cValue; }; \
474 inline const QString &operator <<=( const QString &sCategory ) { AttributeInstance<type>::SetCategory( sCategory ); return sCategory; };
475 #define OPERATORS( type ) \
476 OPERATORS_NOEXCMARK( type ) \
478 inline bool operator !( void ) { return !AttributeInstance<type>::Value(); };
505 const unsigned char *tData = (
const unsigned char *)(
void *)(&m_cValue);
506 for (
unsigned int i = 0; i <
sizeof(m_cValue); i++ )
520 unsigned char *tData = (
unsigned char *)(
void *)(&cValue);
521 for (
int i = 0; i < (
int)
sizeof(cValue); i++ )
523 SetValue( cValue, bInternal );
527 typedef AttributeInstance<int>
aint;
536 bool astring::operator !(
void) {
return !(m_cValue.isEmpty()); }
539 QString aint::AsString(
bool bLocalized )
const;
541 QString afloat::AsString(
bool bLocalized )
const;
543 QString abool::AsString(
bool bLocalized )
const;
545 QString astring::AsString(
bool bLocalized )
const {
return m_cValue; };
548 void aint::SetFromString(
const QString &sValue,
bool bInternal,
bool bLocalized );
550 void afloat::SetFromString(
const QString &sValue,
bool bInternal,
bool bLocalized );
552 void abool::SetFromString(
const QString &sValue,
bool bInternal,
bool bLocalized );
554 void astring::SetFromString(
const QString &sValue,
bool bInternal,
bool bLocalized ) { SetValue( sValue, bInternal ); };
557 Attribute::AttributeType aint::Type(
void )
const {
return typeInt; };
559 Attribute::AttributeType abool::Type(
void )
const {
return typeBool; };
561 Attribute::AttributeType afloat::Type(
void )
const {
return typeFloat; };
563 Attribute::AttributeType astring::Type(
void )
const {
return typeString; };
570 AttributeWidget *abool::CreateEditorWidget(
QWidget *pParent,
int iWidth ) {
return CreateNewBoolWidget( pParent, iWidth,
this ); };
572 AttributeWidget *aint::CreateEditorWidget(
QWidget *pParent,
int iWidth ) {
return CreateNewIntWidget( pParent, iWidth,
this ); };
576 template <
typename type >
inline
582 template <
typename type >
inline
600 template <
typename type >
603 const ClassDesc *TargetType(
void )
const {
return type::StaticClass(); };
605 void UpdateTargets(
void )
607 for (
unsigned int i = 0; i < AttributeInstance<type *>::TargetCount(); i++ )
611 typedef bool validator(
const type *pTarget );
612 validator *m_pValidator;
613 bool ValidatePointerValue(
const Node *pValue )
615 if ( m_pValidator == 0 || m_pValidator( dynamic_cast< const type *>( pValue ) ) )
623 { SetValue( 0,
true ); m_pValidator = 0; m_sNullString =
"NULL"; m_bAllowNull =
true; };
626 { SetValue( 0,
true ); m_pValidator = 0; m_sNullString =
"NULL"; m_bAllowNull =
true; };
629 { SetValue( cOther.
Value(), true ); m_pValidator = 0; m_sNullString =
"NULL"; m_bAllowNull =
true; };
631 QString AsString(
bool )
const {
if ( PointerValue() )
return PointerValue()->Name();
else return m_sNullString; };
637 inline void SetValidator( validator *pValidator ) { m_pValidator = pValidator; };
642 if ( pNode && m_pValidator && !m_pValidator( dynamic_cast<type *>( pNode ) ) )
645 SetValue( dynamic_cast<type *>( pNode ) );
655 cValue->m_pThis.AddTarget( *
this );
657 Attribute::ClearSource();
661 Attribute::AddTarget( cTarget );
662 if ( cTarget.
Size() )
693 for (
unsigned int i = 0; i < AttributeInstance<type *>::TargetCount(); i++ )
697 #define PTROPERATORS( type ) \
698 OPERATORS( type* ); \
700 inline type *operator =( int iValue ) { MB_ASSERT( iValue == 0 ); return operator =( (type *)(uint64)iValue ); }; \
702 inline bool operator ==( int iValue ) { MB_ASSERT( iValue == 0 ); return operator ==( (type *)(uint64)iValue ); }; \
704 inline bool operator !=( int iValue ) { MB_ASSERT( iValue == 0 ); return operator !=( (type *)(uint64)iValue ); }; \
706 inline type *operator ->( void ) { return AttributeInstance<type *>::Value(); }; \
708 inline const type *operator ->( void ) const { return AttributeInstance<type *>::Value(); }; \
710 inline operator bool( void ) const { return AttributeInstance<type *>::Value() != 0; };
723 #define aptr AttributePointer
724 template <
typename type >
731 const ClassDesc *TargetType(
void )
const;
749 mutable unsigned int m_iVersion;
761 static Node *s_pFirstNode;
762 static int s_iNextID;
763 static bool s_bUseHashTable;
765 static NodeIDMap *s_NodeIDMap;
778 static void StartHashing();
796 virtual ~
Node(
void );
798 virtual void Initialize(
void );
827 virtual void OnEvent(
const EventGate &cEvent );
829 void RequestDeferredEvent(
Attribute &cAttribute );
833 void LoadTemplate(
const QString &sFileName =
"",
bool bStartEvent =
false );
835 void SaveTemplate(
const QString &sFileName =
"",
bool bSaveOnlyVisible =
false);
837 unsigned int Version(
void )
const;
839 void SetVersion(
unsigned int iVersion );
841 unsigned int ReferenceCount(
void )
const;
843 Attribute *ReferencePointer(
unsigned int iIndex )
const;
845 Node *ReferenceNode(
unsigned int iIndex )
const;
851 static Node *First(
void );
857 int ID(
void )
const {
return m_iID; }
861 bool SetID(
int iID );
865 static Node *ByID(
int iID );
880 virtual void SetName(
const QString &sName );
885 virtual void SetStringID(
const QString &sStringID );
888 virtual QString DisplayName(
void )
const;
893 virtual void SetDisplayName(
const QString & sDisplayName );
895 virtual QString HelpID(
void )
const;
897 virtual void SetHelpID(
const QString &sHelpID );
900 void Annex(
Node *pSource,
const QString &sCategory =
"" );
906 unsigned int AttributeCount(
void )
const;
908 Attribute *AttributeByIndex(
int iIndex )
const;
914 void SetAttributeValue(
const QString &sAttributeID,
const QString &sNewValue );
918 void LogAttributes(
void )
const;
941 virtual void Serialize(
Stream &
s );
949 bool IsKindOf(
const ClassDesc *pClass )
const;
954 void ContentChanged(
void )
const;
960 virtual void CheckValidity(
DiagnosticLevel iLevel = dgnLevel2 )
const;
962 virtual void CopyTo(
Node *pNode)
const;
964 virtual Node *Duplicate(
void )
const;
1008 void Trigger(
void );
1024 mutable float m_fMin, m_fMax;
1025 mutable float m_fEditMin, m_fEditMax;
1042 float Min(
void )
const;
1043 float Max(
void )
const;
1044 void SetMin(
float fValue );
1045 void SetMax(
float fValue );
1047 void SetEditMin(
float fEditMin );
1048 void SetEditMax(
float fEditMax );
1049 float EditMin(
void )
const;
1050 float EditMax(
void )
const;
1060 int m_iControlWidth;
1077 bool m_bDisplayAsIcons;
1089 unsigned int AddItem(
const QString &sValue,
bool bEnabled =
true );
1090 void SetItem(
unsigned int iIndex,
const QString &sValue,
bool bEnabled =
true );
1093 bool bDisplayAsIcons
1094 ) { m_bDisplayAsIcons = bDisplayAsIcons; };
1098 bool IconMode(
void )
const {
return m_bDisplayAsIcons; };
1117 unsigned int ItemCount(
void )
const;
1119 QString Item(
unsigned int iIndex )
const;
1120 bool IsItemEnabled(
unsigned int iIndex )
const;
1174 unsigned int m_iBoolCount;
1183 void SetValue(
unsigned int iIndex,
bool bValue,
bool bInternal =
false );
1184 bool Value(
unsigned int iIndex )
const;
1185 int AddBool(
const QString &sName,
bool bValue =
false );
1186 unsigned int BoolCount(
void )
const;
1187 void SetBoolName(
unsigned int iIndex,
const QString &sName );
1188 QString BoolName(
unsigned int iIndex )
const;
AttributeFilename afilename
GLuint GLuint GLsizei GLenum type
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
void AddTarget(Attribute &cTarget)
#define MBDLL_TEMPLATE_DECL
AttributeEnumeration aenum
bool IconMode(void) const
Returns true if the attribute is displayed as buttons or false for combo.
An attribute that can hold a number and uses the specified number of digits when displaying on the UI...
This attribute represents a float value which has a minimum and a maximum value.
Very fast, cursory check.
AttributePointer(Node *pOwner=NULL, const QString &sID="")
Standard enum attribute, 4 bytes.
void SetPointerValue(Node *pNode, bool bLink=true)
This is valid only for pointer attributes (See AttributePointer).
AttributeWidget * CreateNewEventWidget(QWidget *pParent, int iWidth, EventGate *pAttribute)
Creates an event widget.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
virtual AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
Causes entire dialog to refresh its UI.
mudbox::Vector & operator<<(mudbox::Vector &v, const HWVector &r)
virtual Node * PointerValue(void) const
This is valid only for pointer attributes (See AttributePointer).
MBDLL_DECL AttributeWidget * CreateNewIntWidget(QWidget *pParent, int iWidth, aint *pAttribute)
bool operator==(const Attribute &cAttribute) const
This is a special operator, it does NOT compare the value of the attribute. See Node::OnNodeEvent for...
virtual unsigned int ParameterCount(void) const
AttributeFloatRange afloatr
String attribute, can store any UNICODE text.
The attribute is relinked to another attribute, so source is changed.
AttributeInstance< float > afloat
This type has to be used instead of the general float type.
This is the base class for most classes in the Mudbox SDK.
NodeEventType
Possible event types when Node::OnNodeEvent is called.
Indicates that the editing is finished on the attribute by the user.
virtual QString AsString(bool bLocalized=false) const
Returns the value of the attribute as a string.
virtual void SetValue(type *cValue, bool bInternal=false)
Set the value of the attribute to cValue.
AttributeTextureFilename atexturefilename
QString AsString(bool) const
Returns the value of the attribute as a string.
Color attribute, 4xfloat, See Color.
void AddTarget(Attribute &cTarget, bool bInternal=false)
Connection management.
AttributeInstance(const AttributeInstance< type > &o)
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
A fake attribute used to watch an attribute in your class which is not a member.
int ID(void) const
Returns an ID for the node. The ID is unique in the whole application life.
This is valid only for pointer type attributes (See AttributePointer). This is posted when the target...
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Node * Next(void) const
Returns the next node in the chain. Used to enumerate the current nodes. See also First()...
This attribute is a collection of bools.
Represents a special file name attribute that accepts texture files as value. Provides a create new a...
Value of an attribute is changed.
virtual void StartEvent(NodeEventType cType) const
int toInt(bool *ok=0, int base=10) const
virtual void SetFromString(const QString &sValue, bool bInternal=true, bool=false)
Sets the value of the attribute as a string.
virtual void AddTarget(Attribute &cTarget, bool bInternal=false)
Adds a new outgoing connection for this node to pTarget.
AttributeBoolCollection aboolc
MBDLL_DECL Stream & operator==(Stream &s, afilename &a)
void SetFromString(const QString &, bool=true, bool=false)
Sets the value of the attribute as a string.
AttributeInstance< QString > astring
This type has to be used instead of the String type.
#define OPERATORS_NOEXCMARK(type)
AttributeVoid(Node *pOwner, const QString &sName)
Category
Set's the category your program should be listed in in the mixer.
void StartEvent(NodeEventType cType) const
This is a generic attribute which can be used instead of the standard built in types.
This structure represents and describes a class.
virtual void SetValue(type cValue, bool bInternal=false)
Set the value of the attribute to cValue.
Standard integer, 4 bytes.
#define PTROPERATORS(type)
AttributeInstance(Node *pOwner, const QString &sID, const type &cValue)
Using this constructor you can also specify the initial value of the attribute with its name...
virtual void SetPointerValue(Node *pValue, bool bLink=true)
This is valid only for pointer attributes (See AttributePointer).
This class represents an event receiver/triggerer point.
DiagnosticLevel
Indicates the level of validity checking that is performed in CheckValidity()
const type & Value(void) const
Returns the value of the attribute.
MBDLL_DECL AttributeWidget * CreateNewPtrWidget(QWidget *pParent, int iWidth, Attribute *pAttribute, const ClassDesc *pType)
AttributePointer(Node *pOwner, const QString &sID, bool bInstall)
virtual QString ParameterName(unsigned int iIndex) const
Returns the name of a parameter with a given index.
bool operator!=(const QByteArray &a1, const QByteArray &a2)
OPERATORS_NOEXCMARK(QString)
MBDLL_DECL AttributeWidget * CreateNewBoolWidget(QWidget *pParent, int iWidth, abool *pAttribute)
unsigned int Size(void) const
Returns the size of the attribute value in bytes.
Used to insert expanded category item.
AttributeInstance< bool > abool
This type has to be used instead of the general bool type.
Similar to AttributeInstance but it provides a button on the interface where the user can bro...
virtual void SetParameterValue(const QString &sName, const QString &sValue)
Set the value of a parameter.
Pointer attribute, see AttributePointer.
AttributeInstance< int > aint
This type has to be used instead of the general int type.
A new attribute is linked to this one, or a link is removed.
AttributeInstance(Node *pOwner, const QString &sID)
Standard constructor. You have to specify the name of the attribute which will be used in the user in...
void SetIconMode(bool bDisplayAsIcons )
This function controls how the attribute should be displayed on the user interface.
Previously requested deferred event.
QString m_sSelectedFilter
Class: ConvolutionKernel.
This is an abstract base structure for all attributes.
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
AttributePointer(const AttributePointer< type > &cOther)
GLubyte GLubyte GLubyte a
virtual QString ParameterValue(unsigned int iIndex) const
Returns the value of parameter with a given index.
AttributeType
Type of the attribute.
void Connect(Attribute &cSource, bool bInternal=false)
Connect this attribute to another one.
Vector, 3xfloat, see Vector.
Streams are used to read information from a file, or to write it to a file.
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
This attribute is very similar to the aint type but on the user interface it will be displayed as a c...
Store< Attribute * > m_aTargets
const ClassDesc * Next(void) const
Returns the next ClassDesc structure. Used when you want to enumerate all the classes (See also First...
void SetValidator(validator *pValidator)
Register a function as the validator for this pointer.
#define Q_DECLARE_TR_FUNCTIONS(context)
void Serialize(Stream &s)
Serialize the value of the attribute into a stream.
virtual AttributeType Type(void) const
Returns the type of the attribute.
AttributeThisPointer m_pThis
virtual ~AttributeInstance(void)
UI data in attributes are changed.
This is valid only for pointer type attributes (See AttributePointer). The target node of the pointer...
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
This class can be used instead of standard pointers, when the pointer target class is derived from th...
Status of the attribute is changed (See SetConst()).
void DeleteTarget(void)
Deletes the object what is referred in this pointer.