Mudbox/node.h Source File

node.h
Go to the documentation of this file.
1 //**************************************************************************/
2 // Copyright (c) 2008 Autodesk, Inc.
3 // All rights reserved.
4 //
5 // Use of this software is subject to the terms of the Autodesk license
6 // agreement provided at the time of installation or download, or which
7 // otherwise accompanies this software in either electronic or hard copy form.
8 //
9 //**************************************************************************/
10 // DESCRIPTION:
11 // CREATED: October 2008
12 //**************************************************************************/
13 
14 #include <QtCore/QHash>
15 
16 namespace mudbox {
17 
18 class Template;
19 class Node;
20 
23 {
24  const ClassDesc *m_pParent[2], *m_pNext;
25  QString m_sName;
26  QString m_sDisplayName;
27  typedef class Node *creator( unsigned int );
28  creator *m_pCreator;
29  static ClassDesc *s_pFirst;
30  Template *m_pTemplate;
31  int m_iVersion;
32 
33 public:
35 
37  ClassDesc( const ClassDesc *pParent0, const ClassDesc *pParent1, const QString &sName,
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 );
47 
49  bool IsDerivedFrom( const ClassDesc *pClass ) const;
51  class Node *CreateInstances( int iCount = 1 ) const;
52 
56  static const ClassDesc *First( void );
58  const ClassDesc *Next( void ) const { return m_pNext; };
60 
63  static const ClassDesc *ByName( const QString &sName );
65  int Version( void ) const;
66 
67  friend class Node;
68  friend class Stream;
69 };
70 
91 #define DECLARE_CLASS \
92 private: \
93  static mudbox::ClassDesc s_cMyClass; \
94 public: \
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 );
98 
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 ) \
103  { Node *p; \
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(); }; \
106  return p; };
107 
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 )
146 
149 {
173 };
174 
182 {
185  {
205  typeWatch
206  };
207 
209  unsigned int TargetCount( void ) const;
211  Attribute *Target( unsigned int iIndex ) const;
213  Attribute *Source( void ) const;
215  bool operator ==( const Attribute &cAttribute ) const;
217  bool operator !=( const Attribute &cAttribute ) const;
219  virtual AttributeType Type( void ) const;
220 
222  QString ID( void ) const;
224  QString Name( void ) const;
226  void SetName( const QString &sName );
228  QString Category( void ) const;
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 );
249  QString ToolTip( void ) const;
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 );
264 
266  Node *Owner( void ) const;
268  virtual void Serialize( Stream &s );
269 
272  virtual QString AsString( bool bLocalized = false ) const;
276  virtual void SetFromString( const QString &sValue, bool bInternal = true, bool bLocalized = false );
277 
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 );
295 
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 );
310 
311  virtual ~Attribute( void );
312  virtual void StartEvent( NodeEventType cType ) const;
313 
319  void SetOwner( Node *pOwner );
320 
326  virtual AttributeWidget *CreateEditorWidget( QWidget *pParent,
327  int iWidth
328  );
329 
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 );
342 
344  void LogTargets( void );
346  void LogSource( void );
348  void CheckValidity( void );
349 
350 protected:
351 
352  Attribute( Node *pOwner, const QString &sID);
353  Attribute( Node *pOwner, bool bInstall);
354 
355  int m_iSize;
356  Attribute *m_pSource, *m_pNext;
364  bool m_bConst;
366  int m_iIndex;
369 
370  void Uninstall( void );
371 
372  friend class Node;
373 };
374 
380 {
381 public:
382  AttributeVoid(Node *pOwner, const QString &sName ) : Attribute(pOwner, sName) {}
384 };
385 
387 
393 template < typename type >
395 {
397  AttributeInstance( Node *pOwner, const QString &sID ) : Attribute( pOwner, sID ) { m_iSize = sizeof(type); };
399  AttributeInstance( Node *pOwner, const QString &sID, const type &cValue ) : Attribute( pOwner, sID ) { m_cValue = cValue; m_iSize = sizeof(type); };
400  AttributeInstance( const AttributeInstance<type> &o ) : Attribute( 0, "" ) { SetValue( o.Value(), true ); m_iSize = sizeof(type); };
401 
402  virtual ~AttributeInstance( void );
403 
404  // Value management
406  const type &Value( void ) const { return m_cValue; };
409  virtual void SetValue( type cValue, bool bInternal = false )
410  {
411  m_cValue = cValue;
412  UpdateTargets();
413  if ( !bInternal )
414  StartEvent( etValueChanged );
415  };
416  void UpdateTargets( void )
417  {
418  for ( unsigned int i = 0; i < TargetCount(); i++ )
419  {
420  if ( Target(i)->Size() == Size() )
421  ((AttributeInstance<type> *)Target(i))->SetValue( m_cValue );
422  else
423  Target(i)->StartEvent( etValueChanged );
424  };
425  };
426  void Serialize( Stream &s );
427 
430  void AddTarget( Attribute &cTarget, bool bInternal = false )
431  {
432  Attribute::AddTarget( cTarget );
433  if ( cTarget.Size() )
434  {
436  if ( pT->Value() != Value() )
437  pT->SetValue( Value(), bInternal );
438  };
439 
440  StartEvent( etTargetChanged );
441  cTarget.StartEvent( etSourceChanged );
442  };
443 
444  // Default string operations
445  virtual QString AsString( bool bLocalized = false ) const;
446 
447  virtual void SetFromString( const QString &sValue, bool bInternal = true, bool /*bLocalized*/ = false );
448 
449  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth ) { return Attribute::CreateEditorWidget( pParent, iWidth ); };
451 
452  // Operators
453  // Used for the QString class which does not have a predefined ! operator
454  // if the line below is used, than pointers wont be linked into the target node THIS pointer.
455  //inline type operator =( type cValue ) { AttributeInstance<type>::SetValue( cValue, true ); return cValue; };
456 #define OPERATORS_NOEXCMARK( type ) \
457  \
458  inline operator type( void ) const { return AttributeInstance<type>::Value(); }; \
459  \
460  inline type const &operator ~( void ) const { return AttributeInstance<type>::Value(); }; \
461  \
462  inline type operator =( type cValue ) { SetValue( cValue, true ); return cValue; }; \
463  \
464  inline type operator =( const AttributeInstance<type> &cValue ) { /*AttributeInstance<type>::*/SetValue( cValue.AttributeInstance<type>::Value(), true ); return cValue; }; \
465  \
466  inline bool operator ==( type cValue ) const { return AttributeInstance<type>::Value() == cValue; }; \
467  \
468  inline bool operator !=( type cValue ) const { return AttributeInstance<type>::Value() != cValue; }; \
469  \
474  inline const QString &operator <<=( const QString &sCategory ) { AttributeInstance<type>::SetCategory( sCategory ); return sCategory; };
475 #define OPERATORS( type ) \
476  OPERATORS_NOEXCMARK( type ) \
477  \
478  inline bool operator !( void ) { return !AttributeInstance<type>::Value(); };
479 
480  OPERATORS( type );
481 
482 protected:
484  AttributeInstance( Node *pOwner, const QString &sName, bool bInstall ) : Attribute( pOwner, bInstall ) { m_sName = sName; m_iSize = sizeof(type); };
485 
486 private:
487 // HACK:
488 public:
489  type m_cValue;
490 };
491 
492 template<class T>
494 {
495  // no-op
496  // Implementation used to create vtable on GCC compilers.
497 }
498 
499 
500 template<class T>
501 QString AttributeInstance<T>::AsString( bool bLocalized ) const
502 {
503  bLocalized;
504  QString sValue;
505  const unsigned char *tData = (const unsigned char *)(void *)(&m_cValue);
506  for ( unsigned int i = 0; i < sizeof(m_cValue); i++ )
507  {
508  if ( i )
509  sValue += " ";
510  sValue += QString("%1").arg(int(tData[i]));
511  };
512  return sValue;
513 };
514 
515 
516 template<class T>
517 void AttributeInstance<T>::SetFromString( const QString &sValue, bool bInternal, bool /*bLocalized*/ )
518 {
519  T cValue;
520  unsigned char *tData = (unsigned char *)(void *)(&cValue);
521  for ( int i = 0; i < (int)sizeof(cValue); i++ )
522  tData[i] = sValue.section(' ', i, i).toInt();
523  SetValue( cValue, bInternal );
524 };
525 
527 typedef AttributeInstance<int> aint;
534 
535 template <> inline
536 bool astring::operator !(void) { return !(m_cValue.isEmpty()); }
537 
538 template <> MBDLL_DECL
539 QString aint::AsString( bool bLocalized ) const;
540 template <> MBDLL_DECL
541 QString afloat::AsString( bool bLocalized ) const;
542 template <> MBDLL_DECL
543 QString abool::AsString( bool bLocalized ) const;
544 template <> inline
545 QString astring::AsString( bool bLocalized ) const { return m_cValue; };
546 
547 template <> MBDLL_DECL
548 void aint::SetFromString( const QString &sValue, bool bInternal, bool bLocalized );
549 template <> MBDLL_DECL
550 void afloat::SetFromString( const QString &sValue, bool bInternal, bool bLocalized );
551 template <> MBDLL_DECL
552 void abool::SetFromString( const QString &sValue, bool bInternal, bool bLocalized );
553 template <> inline
554 void astring::SetFromString( const QString &sValue, bool bInternal, bool bLocalized ) { SetValue( sValue, bInternal ); };
555 
556 template <> inline
557 Attribute::AttributeType aint::Type( void ) const { return typeInt; };
558 template <> inline
559 Attribute::AttributeType abool::Type( void ) const { return typeBool; };
560 template <> inline
561 Attribute::AttributeType afloat::Type( void ) const { return typeFloat; };
562 template <> inline
563 Attribute::AttributeType astring::Type( void ) const { return typeString; };
564 
565 MBDLL_DECL AttributeWidget *CreateNewPtrWidget( QWidget *pParent, int iWidth, Attribute *pAttribute, const ClassDesc *pType );
566 MBDLL_DECL AttributeWidget *CreateNewBoolWidget( QWidget *pParent, int iWidth, abool *pAttribute );
567 MBDLL_DECL AttributeWidget *CreateNewIntWidget( QWidget *pParent, int iWidth, aint *pAttribute );
568 
569 template <> inline
570 AttributeWidget *abool::CreateEditorWidget( QWidget *pParent, int iWidth ) { return CreateNewBoolWidget( pParent, iWidth, this ); };
571 template <> inline
572 AttributeWidget *aint::CreateEditorWidget( QWidget *pParent, int iWidth ) { return CreateNewIntWidget( pParent, iWidth, this ); };
573 
576 template < typename type > inline
577 bool operator ==( const Attribute &cA, const AttributeInstance<type> &cB )
578 {
579  return &cA == &cB;
580 };
581 
582 template < typename type > inline
584 {
585  c.Serialize( s );
586  return s;
587 };
588 
589 class EventGate;
590 
600 template < typename type >
601 class AttributePointer : public AttributeInstance<type *>
602 {
603  const ClassDesc *TargetType( void ) const { return type::StaticClass(); };
604  Node *PointerValue( void ) const { return AttributeInstance<type *>::Value(); };
605  void UpdateTargets( void )
606  {
607  for ( unsigned int i = 0; i < AttributeInstance<type *>::TargetCount(); i++ )
608  AttributeInstance<type *>::Target(i)->SetPointerValue( PointerValue(), false );
609  };
610  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth ) { return CreateNewPtrWidget( pParent, iWidth, this, type::StaticClass() ); };
611  typedef bool validator( const type *pTarget );
612  validator *m_pValidator;
613  bool ValidatePointerValue( const Node *pValue )
614  {
615  if ( m_pValidator == 0 || m_pValidator( dynamic_cast< const type *>( pValue ) ) )
616  return true;
617 
618  return false;
619  };
620 
621 public:
622  AttributePointer( Node *pOwner=NULL, const QString &sID = "") : AttributeInstance<type *>( pOwner, sID )
623  { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
624 
625  AttributePointer( Node *pOwner, const QString &sID, bool bInstall ) : AttributeInstance<type *>( pOwner, sID, bInstall )
626  { SetValue( 0, true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
627 
629  { SetValue( cOther.Value(), true ); m_pValidator = 0; m_sNullString = "NULL"; m_bAllowNull = true; };
630 
631  QString AsString( bool /*bLocalized*/ ) const { if ( PointerValue() ) return PointerValue()->Name(); else return m_sNullString; };
632 
633  void SetFromString( const QString & /*sValue*/, bool /*bInternal*/ = true, bool /*bLocalized*/ = false ) { SetPointerValue( 0 ); };
634 
637  inline void SetValidator( validator *pValidator ) { m_pValidator = pValidator; };
638 
639  void SetPointerValue( Node *pNode, bool bLink = true )
640  {
641  // always accept 0 pointer, the target may be destroyed
642  if ( pNode && m_pValidator && !m_pValidator( dynamic_cast<type *>( pNode ) ) )
643  return;
644  if ( bLink )
645  SetValue( dynamic_cast<type *>( pNode ) );
646  else
647  AttributeInstance<type *>::SetValue( dynamic_cast<type *>( pNode ) );
648  };
649  virtual void SetValue( type *cValue, bool bInternal = false )
650  {
651  if ( cValue == AttributePointer<type>::Value() )
652  return;
653  AttributeInstance<type *>::SetValue( cValue, bInternal );
654  if ( cValue )
655  cValue->m_pThis.AddTarget( *this );
656  else
657  Attribute::ClearSource();
658  };
659  void AddTarget( Attribute &cTarget )
660  {
661  Attribute::AddTarget( cTarget );
662  if ( cTarget.Size() )
663  {
664  if ( cTarget.PointerValue() != PointerValue() )
665  cTarget.SetPointerValue( PointerValue() );
666  };
667  };
669  void DeleteTarget( void )
670  {
672  };
688  void Serialize( Stream &s );
689  void StartEvent( NodeEventType cType ) const
690  {
692  if ( cType == etPointerContentChanged || cType == etPointerTargetDestroyed || cType == etPointerTargetUIChanged || cType == etRefreshDialogUI )
693  for ( unsigned int i = 0; i < AttributeInstance<type *>::TargetCount(); i++ )
695  };
697 #define PTROPERATORS( type ) \
698  OPERATORS( type* ); \
699  \
700  inline type *operator =( int iValue ) { MB_ASSERT( iValue == 0 ); return operator =( (type *)(uint64)iValue ); }; \
701  \
702  inline bool operator ==( int iValue ) { MB_ASSERT( iValue == 0 ); return operator ==( (type *)(uint64)iValue ); }; \
703  \
704  inline bool operator !=( int iValue ) { MB_ASSERT( iValue == 0 ); return operator !=( (type *)(uint64)iValue ); }; \
705  \
706  inline type *operator ->( void ) { return AttributeInstance<type *>::Value(); }; \
707  \
708  inline const type *operator ->( void ) const { return AttributeInstance<type *>::Value(); }; \
709  \
710  inline operator bool( void ) const { return AttributeInstance<type *>::Value() != 0; };
711  PTROPERATORS( type );
712 
715 
716  friend class Node;
717  friend class AttributeThisPointer;
718  friend struct Attribute;
719 };
720 
721 //template < typename type>
722 //typedef AttributePointer<type> aptr<type>;
723 #define aptr AttributePointer
724 template < typename type >
725 inline Stream &operator ==( Stream &cStream, AttributePointer<type> &cPointer ) { cPointer.AttributePointer<type>::Serialize( cStream ); return cStream; };
726 
729 {
730  AttributeThisPointer( Node *pOwner );
731  const ClassDesc *TargetType( void ) const;
732  PTROPERATORS( Node );
733 
734  friend class Node;
735 };
736 
737 
738 //---------------------------------------------------------------------------------------
741 {
742 private:
743  Node *m_pNext;
744  Node *m_pPrev;
745 
746  Attribute *m_pAttributes;
747 
748  int m_iID;
749  mutable unsigned int m_iVersion;
750 
751  QString m_sStringID;
752  QString m_sDisplayName;
753  QString m_sHelpID;
754 
755  QList<Attribute *> m_aRuntimeAttributes;
756 
757  // We use a hash table so we can find nodes by ID fast.
758  // (was a performance bottleneck for undo/redo and file serialization)
759  typedef QHash<int, Node *> NodeIDMap;
760 
761  static Node *s_pFirstNode;
762  static int s_iNextID;
763  static bool s_bUseHashTable; // QHash crashes if used during static construction time, so dont.
764 
765  static NodeIDMap *s_NodeIDMap; // Hash map so we can find nodes by ID fast.
766 
767  friend struct Attribute;
768  friend class Stream;
769 
770 public:
771 
777  // Thanks Bjarne....
778  static void StartHashing();
779 
782  {
785 
788 
790  dgnLevel3
791  };
792 
795  Node( const QString &sStringID = "", const QString &sDisplayName = "" );
796  virtual ~Node( void );
797 
798  virtual void Initialize( void );
799 
804 
825  virtual void OnNodeEvent( const Attribute &cAttribute, NodeEventType cType );
827  virtual void OnEvent( const EventGate &cEvent );
829  void RequestDeferredEvent( Attribute &cAttribute );
831 
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;
846 
851  static Node *First( void );
852 
854  Node *Next( void ) const { return m_pNext; }
855 
857  int ID( void ) const { return m_iID; }
858 
861  bool SetID( int iID );
862 
865  static Node *ByID( int iID );
866 
870  static Node *ByName( const QString &sClass, const QString &sName );
872 
873  // TODO I18N: remove this deprecated interface.
876  virtual QString Name( const ClassDesc *pClass = 0 ) const;
877  // TODO I18N: remove this deprecated interface.
880  virtual void SetName( const QString &sName );
883  virtual QString StringID( const ClassDesc *pClass = 0 ) const;
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 );
898 
900  void Annex( Node *pSource, const QString &sCategory = "" );
901 
906  unsigned int AttributeCount( void ) const;
908  Attribute *AttributeByIndex( int iIndex ) const;
910  Attribute *AttributeByName( const QString &sName ) const;
912  Attribute *AttributeByID( const QString &sID ) const;
914  void SetAttributeValue( const QString &sAttributeID, const QString &sNewValue );
916  QString AttributeValue( const QString &sAttributeID ) const;
918  void LogAttributes( void ) const;
920  virtual QWidget *CreatePropertiesWindow( QWidget *pParent );
924  Attribute *AddAttribute(Attribute::AttributeType type, const QString &id);
925  // Allows SDK users to add attributes at runtime. The Attribute passed into the function
926  // *MUST* be allocated on the heap (dynamically allocated). Returns true on success & false on failure. On successfull adding
927  // then this node manages the attribute (deletes on node destructor). Returns true if attribute
928  // already exists. This function sets the owner of this attribute to the node. The new owner is
929  // responsible for deleting the attribute. Attribute visibility is set to false.
930  // Note that the attribute will be serialized when the node is serialized.
931  //
932  // Disabled until we support serialization of user-defined attribute types.
933  //bool AddAttribute(Attribute *pAttribute);
934 
935  // Runtime attribute count
937 
941  virtual void Serialize( Stream &s );
942 
944 
945  friend class EventGate;
946 
949  bool IsKindOf( const ClassDesc *pClass ) const;
950 
954  void ContentChanged( void ) const;
955 
960  virtual void CheckValidity( DiagnosticLevel iLevel = dgnLevel2 ) const;
961 
962  virtual void CopyTo( Node *pNode) const;
963 
964  virtual Node *Duplicate( void ) const;
965 
967 };
968 
970 AttributeWidget *CreateNewEventWidget( QWidget *pParent, int iWidth, EventGate *pAttribute );
971 
1000 {
1001  void StartEvent( NodeEventType cType ) const;
1002  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1003 
1004 public:
1006  EventGate( Node *pOwner = NULL, const QString &sID = "" );
1008  void Trigger( void );
1011  void Connect( EventGate &cEvent, bool bInternal = false );
1013  bool operator ==( const EventGate &cEvent ) const;
1014 };
1016 
1017 // special attributes
1020 class MBDLL_DECL AttributeFloatRange : public afloat
1021 {
1023 private:
1024  mutable float m_fMin, m_fMax;
1025  mutable float m_fEditMin, m_fEditMax;
1026  float m_fFactor;
1027  int m_iPrecision;
1028 
1029  QString AsString( bool /*bLocalized*/ ) const;
1030  void SetFromString( const QString &sValue, bool bInternal = true, bool bLocalized = false );
1031 
1032  unsigned int ParameterCount( void ) const;
1033  QString ParameterName( unsigned int iIndex ) const;
1034  QString ParameterValue( unsigned int iIndex ) const;
1035  void SetParameterValue( const QString &sName, const QString &sValue );
1036 public:
1038  AttributeFloatRange( Node *pOwner, const QString &sID, float fMinimum = 0, float fMaximum = 1, float fFactor = 1, int iPrecision = 2 );
1039  OPERATORS( float );
1040  void StartEvent( NodeEventType cType ) const;
1041  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1042  float Min( void ) const;
1043  float Max( void ) const;
1044  void SetMin( float fValue );
1045  void SetMax( float fValue );
1046  // Set the min max limit to the edit box
1047  void SetEditMin( float fEditMin );
1048  void SetEditMax( float fEditMax );
1049  float EditMin( void ) const;
1050  float EditMax( void ) const;
1051 };
1052 
1054 MBDLL_DECL Stream &operator ==( Stream &s, afloatr &a );
1055 
1058 {
1059  int m_iDigitCount;
1060  int m_iControlWidth;
1061  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1062 public:
1063  AttributeNumber( Node *pOwner, const QString &sID, int m_iControlwidth = 40, int m_iDigitCount = 0 );
1064  OPERATORS( int );
1065 };
1066 
1068 
1072 {
1074 private:
1075  Store<QString> m_aValues;
1076  Store<bool> m_aEnabledStates;
1077  bool m_bDisplayAsIcons;
1078 
1079  unsigned int ParameterCount( void ) const;
1080  QString ParameterName( unsigned int iIndex ) const;
1081  QString ParameterValue( unsigned int iIndex ) const;
1082  void SetParameterValue( const QString &sName, const QString &sValue );
1083 public:
1084  AttributeEnumeration( Node *pOwner, const QString &sID );
1085  OPERATORS( int );
1086  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
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; };
1113  AttributeEnumeration &operator <<( const char *sValue );
1114  AttributeEnumeration &operator =( const AttributeEnumeration &aeValue );
1115 
1117  unsigned int ItemCount( void ) const;
1118  void Clear( void );
1119  QString Item( unsigned int iIndex ) const;
1120  bool IsItemEnabled( unsigned int iIndex ) const;
1121 };
1123 MBDLL_DECL Stream &operator ==( Stream &s, aenum &a );
1124 
1126 class MBDLL_DECL AttributeFilename : public astring
1127 {
1128 public:
1129  AttributeFilename( Node *pOwner, const QString &sID, bool bMustExists = true );
1131  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1132 
1133  unsigned int ParameterCount( void ) const;
1134  QString ParameterName( unsigned int iIndex ) const;
1135  QString ParameterValue( unsigned int iIndex ) const;
1136  void SetParameterValue( const QString &sName, const QString &sValue );
1137 
1142 };
1144 
1147 {
1148 public:
1149  AttributeTextureFilename( Node *pOwner, const QString &sID, bool bMustExists = true );
1151  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1152 };
1154 MBDLL_DECL Stream &operator ==( Stream &s, afilename &a );
1155 
1160 {
1161  Attribute::AttributeType Type( void ) const;
1162 public:
1163  AttributeWatch( Node *pOwner, const QString &sID = "");
1164 };
1165 
1168 {
1170 
1171 private:
1172  AttributeWidget *CreateEditorWidget( QWidget *pParent, int iWidth );
1173  QString m_aNames[32];
1174  unsigned int m_iBoolCount;
1175 
1176  unsigned int ParameterCount( void ) const;
1177  QString ParameterName( unsigned int iIndex ) const;
1178  QString ParameterValue( unsigned int iIndex ) const;
1179  void SetParameterValue( const QString &sName, const QString &sValue );
1180 public:
1181  AttributeBoolCollection( Node *pOwner, const QString &sID );
1182  void Clear( void );
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;
1189 };
1191 
1192 }; // end of namespace mudbox
1193 
1194 
AttributeFilename afilename
Definition: node.h:1143
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
unsigned int(APIENTRYP PFNGLXGETAGPOFFSETMESAPROC)(const void *pointer)
Definition: GLee.h:10762
void AddTarget(Attribute &cTarget)
Definition: node.h:659
AttributeVoid avoid
Definition: node.h:386
#define MBDLL_TEMPLATE_DECL
Definition: dllinterface.h:44
float m_fLabelWidth
Definition: node.h:363
AttributeEnumeration aenum
Definition: node.h:1122
QString m_sToolTip
Definition: node.h:362
bool IconMode(void) const
Returns true if the attribute is displayed as buttons or false for combo.
Definition: node.h:1098
An attribute that can hold a number and uses the specified number of digits when displaying on the UI...
Definition: node.h:1057
Simple array class.
Definition: array.h:334
This attribute represents a float value which has a minimum and a maximum value.
Definition: node.h:1020
Very fast, cursory check.
Definition: node.h:784
bool m_bSeparator
Definition: node.h:360
AttributePointer(Node *pOwner=NULL, const QString &sID="")
Definition: node.h:622
Standard enum attribute, 4 bytes.
Definition: node.h:203
void SetPointerValue(Node *pNode, bool bLink=true)
This is valid only for pointer attributes (See AttributePointer).
Definition: node.h:639
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.
Definition: node.h:450
Causes entire dialog to refresh its UI.
Definition: node.h:168
AttributeNumber anumber
Definition: node.h:1067
mudbox::Vector & operator<<(mudbox::Vector &v, const HWVector &r)
Definition: SSE.h:245
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
Definition: node.h:1053
String attribute, can store any UNICODE text.
Definition: node.h:195
The attribute is relinked to another attribute, so source is changed.
Definition: node.h:153
AttributeInstance< float > afloat
This type has to be used instead of the general float type.
Definition: node.h:529
Standard float, 4 bytes.
Definition: node.h:191
bool m_bConst
Definition: node.h:364
This is the base class for most classes in the Mudbox SDK.
Definition: node.h:740
NodeEventType
Possible event types when Node::OnNodeEvent is called.
Definition: node.h:148
Indicates that the editing is finished on the attribute by the user.
Definition: node.h:170
type Min(type a, type b)
Definition: mudbox.h:184
virtual QString AsString(bool bLocalized=false) const
Returns the value of the attribute as a string.
Definition: math.h:601
virtual void SetValue(type *cValue, bool bInternal=false)
Set the value of the attribute to cValue.
Definition: node.h:649
AttributeTextureFilename atexturefilename
Definition: node.h:1153
QString AsString(bool) const
Returns the value of the attribute as a string.
Definition: node.h:631
Color attribute, 4xfloat, See Color.
Definition: node.h:199
void AddTarget(Attribute &cTarget, bool bInternal=false)
Connection management.
Definition: node.h:430
AttributeInstance(const AttributeInstance< type > &o)
Definition: node.h:400
Attribute::AttributeType Type(void) const
Returns the type of the attribute.
Definition: node.h:696
A fake attribute used to watch an attribute in your class which is not a member.
Definition: node.h:1159
int ID(void) const
Returns an ID for the node. The ID is unique in the whole application life.
Definition: node.h:857
QString m_sCategory
Definition: node.h:361
This is valid only for pointer type attributes (See AttributePointer). This is posted when the target...
Definition: node.h:157
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
Definition: node.h:577
Node * Next(void) const
Returns the next node in the chain. Used to enumerate the current nodes. See also First()...
Definition: node.h:854
This attribute is a collection of bools.
Definition: node.h:1167
Represents a special file name attribute that accepts texture files as value. Provides a create new a...
Definition: node.h:1146
Value of an attribute is changed.
Definition: node.h:151
virtual void StartEvent(NodeEventType cType) const
QString m_sID
Definition: node.h:368
int toInt(bool *ok=0, int base=10) const
void UpdateTargets(void)
Definition: node.h:416
virtual void SetFromString(const QString &sValue, bool bInternal=true, bool=false)
Sets the value of the attribute as a string.
Definition: math.h:605
virtual void AddTarget(Attribute &cTarget, bool bInternal=false)
Adds a new outgoing connection for this node to pTarget.
AttributeBoolCollection aboolc
Definition: node.h:1190
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.
Definition: node.h:633
AttributeInstance< QString > astring
This type has to be used instead of the String type.
Definition: node.h:533
#define OPERATORS_NOEXCMARK(type)
Definition: node.h:456
AttributeVoid(Node *pOwner, const QString &sName)
Definition: node.h:382
Category
Set's the category your program should be listed in in the mixer.
void StartEvent(NodeEventType cType) const
Definition: node.h:689
This is a generic attribute which can be used instead of the standard built in types.
Definition: node.h:394
QString m_sNullString
Definition: node.h:713
Standard bool, 1 bytes.
Definition: node.h:193
This structure represents and describes a class.
Definition: node.h:22
virtual void SetValue(type cValue, bool bInternal=false)
Set the value of the attribute to cValue.
Definition: node.h:409
Standard integer, 4 bytes.
Definition: node.h:189
#define PTROPERATORS(type)
Definition: node.h:697
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...
Definition: node.h:399
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.
Definition: node.h:999
DiagnosticLevel
Indicates the level of validity checking that is performed in CheckValidity()
Definition: node.h:781
const type & Value(void) const
Returns the value of the attribute.
Definition: node.h:406
MBDLL_DECL AttributeWidget * CreateNewPtrWidget(QWidget *pParent, int iWidth, Attribute *pAttribute, const ClassDesc *pType)
AttributePointer(Node *pOwner, const QString &sID, bool bInstall)
Definition: node.h:625
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)
Definition: qbytearray.h:533
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.
Definition: node.h:379
AttributeInstance< bool > abool
This type has to be used instead of the general bool type.
Definition: node.h:531
Similar to AttributeInstance but it provides a button on the interface where the user can bro...
Definition: node.h:1126
virtual void SetParameterValue(const QString &sName, const QString &sValue)
Set the value of a parameter.
Pointer attribute, see AttributePointer.
Definition: node.h:197
Attribute * m_pSource
Definition: node.h:356
AttributeInstance< int > aint
This type has to be used instead of the general int type.
Definition: node.h:524
A new attribute is linked to this one, or a link is removed.
Definition: node.h:155
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...
Definition: node.h:397
const GLubyte * c
Definition: GLee.h:5419
void SetIconMode(bool bDisplayAsIcons )
This function controls how the attribute should be displayed on the user interface.
Definition: node.h:1092
Previously requested deferred event.
Definition: node.h:165
QString m_sSelectedFilter
Definition: node.h:1141
Class: ConvolutionKernel.
Definition: array.h:15
int m_iStreamVersion
Definition: node.h:34
bool m_bVisible
Definition: node.h:365
This is an abstract base structure for all attributes.
Definition: node.h:181
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
Definition: qstring.h:781
EventGate aevent
Definition: node.h:1015
AttributePointer(const AttributePointer< type > &cOther)
Definition: node.h:628
GLubyte GLubyte GLubyte a
Definition: GLee.h:5404
virtual QString ParameterValue(unsigned int iIndex) const
Returns the value of parameter with a given index.
Fairly quick check.
Definition: node.h:787
AttributeType
Type of the attribute.
Definition: node.h:184
void Connect(Attribute &cSource, bool bInternal=false)
Connect this attribute to another one.
Vector, 3xfloat, see Vector.
Definition: node.h:201
#define aptr
Definition: node.h:723
bool m_bInstantEdit
Definition: node.h:367
Streams are used to read information from a file, or to write it to a file.
Definition: stream.h:39
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...
Definition: node.h:1071
#define OPERATORS(type)
Definition: node.h:475
Store< Attribute * > m_aTargets
Definition: node.h:357
QString m_sName
Definition: node.h:359
GLdouble s
Definition: GLee.h:1173
const ClassDesc * Next(void) const
Returns the next ClassDesc structure. Used when you want to enumerate all the classes (See also First...
Definition: node.h:58
void SetValidator(validator *pValidator)
Register a function as the validator for this pointer.
Definition: node.h:637
type Max(type a, type b)
Definition: mudbox.h:186
Unknown attribute.
Definition: node.h:187
Node * m_pNode
Definition: node.h:358
#define Q_DECLARE_TR_FUNCTIONS(context)
void Serialize(Stream &s)
Serialize the value of the attribute into a stream.
Definition: stream.h:319
virtual AttributeType Type(void) const
Returns the type of the attribute.
AttributeThisPointer m_pThis
Definition: node.h:943
virtual ~AttributeInstance(void)
Definition: node.h:493
#define MBDLL_DECL
Definition: dllinterface.h:35
DECLARE_CLASS
Definition: node.h:966
UI data in attributes are changed.
Definition: node.h:163
This is valid only for pointer type attributes (See AttributePointer). The target node of the pointer...
Definition: node.h:159
An event triggered.
Definition: node.h:172
AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Definition: node.h:449
This class can be used instead of standard pointers, when the pointer target class is derived from th...
Definition: node.h:601
Status of the attribute is changed (See SetConst()).
Definition: node.h:161
void DeleteTarget(void)
Deletes the object what is referred in this pointer.
Definition: node.h:669