AttributeInstance< type > Struct Template Reference

AttributeInstance< type > Struct Template Reference
+ Related help topics:

#include <node.h>

Class Description

template<typename type>
struct mudbox::AttributeInstance< type >

This is a generic attribute which can be used instead of the standard built in types.

The difference between a standard type and this attribute is that this attribute can be viewed and its value can be changed by the user. Attributes can be linked together also so when the value of an attribute is changed, all target attributes value will be changed also. The owner node also can catch events regarding to the attrbibutes, for example when the user changes the value.

Definition at line 394 of file node.h.

+ Inheritance diagram for AttributeInstance< type >:

Public Member Functions

 AttributeInstance (Node *pOwner, const QString &sID)
 Standard constructor. You have to specify the name of the attribute which will be used in the user interface. More...
 
 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. More...
 
 AttributeInstance (const AttributeInstance< type > &o)
 
virtual ~AttributeInstance (void)
 
const typeValue (void) const
 Returns the value of the attribute. More...
 
virtual void SetValue (type cValue, bool bInternal=false)
 Set the value of the attribute to cValue. More...
 
void UpdateTargets (void)
 
void Serialize (Stream &s)
 Serialize the value of the attribute into a stream. More...
 
void AddTarget (Attribute &cTarget, bool bInternal=false)
 Connection management. More...
 
virtual QString AsString (bool bLocalized=false) const
 Returns the value of the attribute as a string. More...
 
virtual void SetFromString (const QString &sValue, bool bInternal=true, bool=false)
 Sets the value of the attribute as a string. More...
 
AttributeWidgetCreateEditorWidget (QWidget *pParent, int iWidth)
 This function creates and returns the address of a QWidget object. More...
 
Attribute::AttributeType Type (void) const
 Returns the type of the attribute. More...
 
 OPERATORS (type)
 
- Public Member Functions inherited from Attribute
unsigned int TargetCount (void) const
 Returns the number of attributes currently linked to this attribute as target. More...
 
AttributeTarget (unsigned int iIndex) const
 Returns the target with the given index. If iIndex is greater than the number of targets, returns 0;. More...
 
AttributeSource (void) const
 Returns the source attribute, or 0 if there is no source. More...
 
bool operator== (const Attribute &cAttribute) const
 This is a special operator, it does NOT compare the value of the attribute. See Node::OnNodeEvent for details. More...
 
bool operator!= (const Attribute &cAttribute) const
 This is a special operator, it does NOT compare the value of the attribute. See Node::OnNodeEvent for details. More...
 
QString ID (void) const
 Returns the unique ID (within this node) of the attribute. More...
 
QString Name (void) const
 Returns the name of the attribute. More...
 
void SetName (const QString &sName)
 Sets the name of the attribute. More...
 
QString Category (void) const
 Returns the category of the attribute. More...
 
void SetCategory (const QString &sCategory, bool bSeparator=false)
 Sets the category of the attribute. This value will be used in the user interface to determine which attribute group to be used. More...
 
bool Separator (void) const
 Returns the separator state of the widget. More...
 
void SetSeparator (bool bSeparator)
 Call this with true to display a separator line below this widget. More...
 
bool Const (void) const
 Gets the constant status of the attribute. Default value is false. If this is set to true the attribute will not be editable by the user on the interface. More...
 
void SetConst (bool bConst)
 Sets the constant status of the attribute. Default value is false. If this is set to true the attribute will not be editable by the user on the interface. More...
 
bool InstantEdit (void) const
 Returns true, if the attribute edition should be instant, i.e. the attribute should change every time the user makes any changes to the widget. Default is false. More...
 
void SetInstantEdit (bool bOn)
 If bOn is true, editing the attribute on the UI will be instant, i.e. More...
 
bool Visible (void) const
 Returns true if the property is visible. More...
 
void SetVisible (bool bVisible)
 Sets the visible status of the property. More...
 
QString ToolTip (void) const
 Gets the tooltip text to be used on the user interface, this is optional. More...
 
void SetToolTip (const QString &sToolTip)
 Sets the tooltip text to be used on the user interface, this is optional. More...
 
unsigned int Size (void) const
 Returns the size of the attribute value in bytes. More...
 
float LabelWidth (void) const
 Returns the width of label relative to the full width of the line. More...
 
void SetLabelWidth (float fLabelWidth)
 Set the width of label. More...
 
int Index (void) const
 Returns the attribute index;. More...
 
void SetIndex (int iIndex)
 Sets the attribute index;. More...
 
NodeOwner (void) const
 Gets the address of the Node which contains this attribute. More...
 
virtual ~Attribute (void)
 
virtual void StartEvent (NodeEventType cType) const
 
void SetOwner (Node *pOwner)
 This function sets the owner of the attribute. More...
 
void LogTargets (void)
 
void LogSource (void)
 
void CheckValidity (void)
 
void ClearTargets (void)
 Removes all outgoing connections from the attribute. More...
 
void ClearSource (void)
 Removes the incoming connection for this attribute. More...
 
void Connect (Attribute &cSource, bool bInternal=false)
 Connect this attribute to another one. More...
 
virtual const ClassDescTargetType (void) const
 This is valid only for pointer attributes (See AttributePointer). Returns the type of the pointer. More...
 
virtual void SetPointerValue (Node *pValue, bool bLink=true)
 This is valid only for pointer attributes (See AttributePointer). More...
 
virtual NodePointerValue (void) const
 This is valid only for pointer attributes (See AttributePointer). More...
 
virtual bool ValidatePointerValue (const Node *pValue)
 Validate a possible value for the pointer, returns true if the value is acceptable. More...
 
virtual unsigned int ParameterCount (void) const
 
virtual QString ParameterName (unsigned int iIndex) const
 Returns the name of a parameter with a given index. More...
 
virtual QString ParameterValue (unsigned int iIndex) const
 Returns the value of parameter with a given index. More...
 
virtual void SetParameterValue (const QString &sName, const QString &sValue)
 Set the value of a parameter. More...
 

Public Attributes

type m_cValue
 

Protected Member Functions

 AttributeInstance (Node *pOwner, const QString &sName, bool bInstall)
 Protected constructor, do not use it. You have to specify the name of the attribute which will be used in the user interface. More...
 
- Protected Member Functions inherited from Attribute
 Attribute (Node *pOwner, const QString &sID)
 
 Attribute (Node *pOwner, bool bInstall)
 
void Uninstall (void)
 

Additional Inherited Members

- Public Types inherited from Attribute
enum  AttributeType {
  typeUnknown, typeInt, typeFloat, typeBool,
  typeString, typePointer, typeColor, typeVector,
  typeEnum, typeWatch
}
 Type of the attribute. More...
 
- Protected Attributes inherited from Attribute
int m_iSize
 
Attributem_pSource
 
Attributem_pNext
 
Store< Attribute * > m_aTargets
 
Nodem_pNode
 
QString m_sName
 
bool m_bSeparator
 
QString m_sCategory
 
QString m_sToolTip
 
float m_fLabelWidth
 
bool m_bConst
 
bool m_bVisible
 
int m_iIndex
 
bool m_bInstantEdit
 
QString m_sID
 

Constructor & Destructor Documentation

AttributeInstance ( Node pOwner,
const QString sID 
)
inline

Standard constructor. You have to specify the name of the attribute which will be used in the user interface.

Definition at line 397 of file node.h.

397 : Attribute( pOwner, sID ) { m_iSize = sizeof(type); };
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
Attribute(Node *pOwner, const QString &sID)
AttributeInstance ( Node pOwner,
const QString sID,
const type cValue 
)
inline

Using this constructor you can also specify the initial value of the attribute with its name.

Definition at line 399 of file node.h.

399 : Attribute( pOwner, sID ) { m_cValue = cValue; m_iSize = sizeof(type); };
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
Attribute(Node *pOwner, const QString &sID)
AttributeInstance ( const AttributeInstance< type > &  o)
inline

Definition at line 400 of file node.h.

400 : Attribute( 0, "" ) { SetValue( o.Value(), true ); m_iSize = sizeof(type); };
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
virtual void SetValue(type cValue, bool bInternal=false)
Set the value of the attribute to cValue.
Definition: node.h:409
Attribute(Node *pOwner, const QString &sID)
~AttributeInstance ( void  )
virtual

Definition at line 493 of file node.h.

494 {
495  // no-op
496  // Implementation used to create vtable on GCC compilers.
497 }
AttributeInstance ( Node pOwner,
const QString sName,
bool  bInstall 
)
inlineprotected

Protected constructor, do not use it. You have to specify the name of the attribute which will be used in the user interface.

Definition at line 484 of file node.h.

484 : Attribute( pOwner, bInstall ) { m_sName = sName; m_iSize = sizeof(type); };
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
Attribute(Node *pOwner, const QString &sID)
QString m_sName
Definition: node.h:359

Member Function Documentation

const type& Value ( void  ) const
inline

Returns the value of the attribute.

Definition at line 406 of file node.h.

406 { return m_cValue; };
virtual void SetValue ( type  cValue,
bool  bInternal = false 
)
inlinevirtual

Set the value of the attribute to cValue.

Parameters
bInternalif this is false the owner node will receive an event about the value change (See NodeEventType::etValueChanged).

Reimplemented in AttributePointer< type >, and AttributePointer< NURBSCurve >.

Definition at line 409 of file node.h.

410  {
411  m_cValue = cValue;
412  UpdateTargets();
413  if ( !bInternal )
415  };
Value of an attribute is changed.
Definition: node.h:151
virtual void StartEvent(NodeEventType cType) const
void UpdateTargets(void)
Definition: node.h:416
void UpdateTargets ( void  )
inlinevirtual

Update the values of all the connected target attributes with the current value. Used internally only, do not call this directly.

Reimplemented from Attribute.

Definition at line 416 of file node.h.

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
424  };
425  };
unsigned int TargetCount(void) const
Returns the number of attributes currently linked to this attribute as target.
Attribute * Target(unsigned int iIndex) const
Returns the target with the given index. If iIndex is greater than the number of targets, returns 0;.
Value of an attribute is changed.
Definition: node.h:151
virtual void StartEvent(NodeEventType cType) const
virtual void SetValue(type cValue, bool bInternal=false)
Set the value of the attribute to cValue.
Definition: node.h:409
unsigned int Size(void) const
Returns the size of the attribute value in bytes.
void Serialize ( Stream s)
inlinevirtual

Serialize the value of the attribute into a stream.

Reimplemented from Attribute.

Reimplemented in AttributePointer< NURBSCurve >.

Definition at line 319 of file stream.h.

319 { s == m_cValue; };
GLdouble s
Definition: GLee.h:1173
void AddTarget ( Attribute cTarget,
bool  bInternal = false 
)
inlinevirtual

Connection management.

Parameters
bInternalif this is false the target's node will receive an event about the value changing in the target

Reimplemented from Attribute.

Definition at line 430 of file node.h.

431  {
432  Attribute::AddTarget( cTarget );
433  if ( cTarget.Size() )
434  {
435  AttributeInstance<type> *pT = (AttributeInstance<type> *)&cTarget;
436  if ( pT->Value() != Value() )
437  pT->SetValue( Value(), bInternal );
438  };
439 
441  cTarget.StartEvent( etSourceChanged );
442  };
The attribute is relinked to another attribute, so source is changed.
Definition: node.h:153
virtual void StartEvent(NodeEventType cType) const
virtual void AddTarget(Attribute &cTarget, bool bInternal=false)
Adds a new outgoing connection for this node to pTarget.
const type & Value(void) const
Returns the value of the attribute.
Definition: node.h:406
A new attribute is linked to this one, or a link is removed.
Definition: node.h:155
QString AsString ( bool  bLocalized = false) const
inlinevirtual

Returns the value of the attribute as a string.

See also SetFromString.

Parameters
bLocalizedif this is true the string representation of the value is assumed to be localized (translated)

Reimplemented from Attribute.

Reimplemented in AttributeCheckableFloat, AttributePointer< type >, and AttributePointer< NURBSCurve >.

Definition at line 601 of file math.h.

602 { return QString("%1 %2 %3").arg(m_cValue.x).arg(m_cValue.y).arg(m_cValue.z); };
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
void SetFromString ( const QString sValue,
bool  bInternal = true,
bool  bLocalized = false 
)
inlinevirtual

Sets the value of the attribute as a string.

See also AsString.

Parameters
bInternalif this is false the owner node will receive an event about the value change (See NodeEventType::etValueChanged).
bLocalizedif this is true the string representation of the value is assumed to be localized (translated)

Reimplemented from Attribute.

Reimplemented in AttributeCheckableFloat, AttributePointer< type >, and AttributePointer< NURBSCurve >.

Definition at line 605 of file math.h.

606 {
607  m_cValue.x = s.section( ' ', 0,0 ).toFloat();
608  m_cValue.y = s.section( ' ', 1,1 ).toFloat();
609  m_cValue.z = s.section( ' ', 2,2 ).toFloat();
610 };
GLdouble s
Definition: GLee.h:1173
AttributeWidget * CreateEditorWidget ( QWidget pParent,
int  iWidth 
)
inlinevirtual

This function creates and returns the address of a QWidget object.

The object then can be used in the interface to give the user control over the attribute value. Mudbox calls this function for every attribute in a node when it displays a properties dialog box for it. You must override it if you implement a new kind of attribute and want a special interface.

Reimplemented from Attribute.

Reimplemented in AttributeTextureFilename, and AttributeFilename.

Definition at line 449 of file node.h.

449 { return Attribute::CreateEditorWidget( pParent, iWidth ); };
virtual AttributeWidget * CreateEditorWidget(QWidget *pParent, int iWidth)
This function creates and returns the address of a QWidget object.
Attribute::AttributeType Type ( void  ) const
inlinevirtual

Returns the type of the attribute.

Reimplemented from Attribute.

Reimplemented in AttributePointer< NURBSCurve >.

Definition at line 450 of file node.h.

450 { return Attribute::AttributeType(); };
AttributeType
Type of the attribute.
Definition: node.h:184
OPERATORS ( type  )

Member Data Documentation

type m_cValue

Definition at line 484 of file node.h.


The documentation for this struct was generated from the following files: