- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | Protected Member Functions

# AttributeInstance< type > Struct Template Reference

This reference page is linked to from the following overview topics: Attributes.

Search for all occurrences

## Detailed 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 381 of file node.h.

`#include <node.h>`

Inheritance diagram for AttributeInstance< type >:
[legend]

List of all members.

## 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.
| 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.
| AttributeInstance (const AttributeInstance< type > &o)
const type & | Value (void) const
| Returns the value of the attribute.
virtual void | SetValue (type cValue, bool bInternal=false)
| Set the value of the attribute to cValue.
void | UpdateTargets (void)
void | Serialize (Stream &s)
| Serialize the value of the attribute into a stream.
void | AddTarget (Attribute &cTarget)
| Adds a new outgoing connection for this node to pTarget.
QString | AsString (bool bLocalized=false) const
| Returns the value of the attribute as a string.
void | SetFromString (const QString &sValue, bool bInternal=true, bool=false)
| Sets the value of the attribute as a string.
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.
| OPERATORS (type)
## 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.

## 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 384 of file node.h.

    : Attribute( pOwner, sID ) { m_iSize = sizeof(type); };

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 386 of file node.h.

    : Attribute( pOwner, sID ) { m_cValue = cValue; m_iSize = sizeof(type); };

AttributeInstance | ( | const AttributeInstance< type > & | o | ) | `[inline]`

Definition at line 387 of file node.h.

    : Attribute( 0, "" ) { SetValue( o.Value(), true ); m_iSize = sizeof(type); };

AttributeInstance | ( | Node * | pOwner,
|  | const QString & | sName,
|  | bool | bInstall
| ) |  | `[inline, protected]`

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 481 of file node.h.

    :

## Member Function Documentation

const type& Value | ( | void |  | ) | const `[inline]`

Search for all occurrences

Returns the value of the attribute.

Definition at line 391 of file node.h.

    { return m_cValue; };

virtual void SetValue | ( | type | cValue,
|  | bool | bInternal = `false`
| ) |  | `[inline, virtual]`

Search for all occurrences

Set the value of the attribute to cValue.

Parameters:

  bInternal | if 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 394 of file node.h.

        {
            m_cValue = cValue;
            UpdateTargets();
            if ( !bInternal )
                StartEvent( etValueChanged );
        };

void UpdateTargets | ( | void |  | ) | `[inline, virtual]`

Search for all occurrences

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 401 of file node.h.

        {
            for ( unsigned int i = 0; i < TargetCount(); i++ )
            {
                if ( Target(i)->Size() == Size() )
                    ((AttributeInstance<type> *)Target(i))->SetValue( m_cValue );
                else
                    Target(i)->StartEvent( etValueChanged );
            };
        };

void Serialize | ( | Stream & | s | ) | `[inline, virtual]`

Search for all occurrences

Serialize the value of the attribute into a stream.

Reimplemented from Attribute.

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

Definition at line 306 of file stream.h.

    { s == m_cValue; };

void AddTarget | ( | Attribute & | cTarget | ) | `[inline, virtual]`

Search for all occurrences

Adds a new outgoing connection for this node to pTarget.

Reimplemented from Attribute.

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

Definition at line 414 of file node.h.

        {
            Attribute::AddTarget( cTarget );
            if ( cTarget.Size() )
            {
                AttributeInstance<type> *pT = (AttributeInstance<type> *)&cTarget;
                if ( pT->Value() != Value() )
                    pT->SetValue( Value() );
            };

            StartEvent( etTargetChanged );
            cTarget.StartEvent( etSourceChanged );
        };

QString AsString | ( | bool | bLocalized = `false` | ) | const `[inline, virtual]`

Search for all occurrences

Returns the value of the attribute as a string.

See also SetFromString.

Parameters:

  bLocalized | if 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 429 of file node.h.

        {
            bLocalized;
            QString sValue;
            const unsigned char *tData = (const unsigned char *)(void *)(&m_cValue);
            for ( unsigned int i = 0; i < sizeof(m_cValue); i++ )
            {
                if ( i )
                    sValue += " ";
                sValue += QString("%1").arg(int(tData[i]));
            };
            return sValue;
        };

void SetFromString | ( | const QString & | sValue,
|  | bool | bInternal = `true`,
|  | bool | bLocalized = `false`
| ) |  | `[inline, virtual]`

Search for all occurrences

Sets the value of the attribute as a string.

See also AsString.

Parameters:

  bInternal | if this is false the owner node will receive an event about the value change (See NodeEventType::etValueChanged).
  bLocalized | if 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 442 of file node.h.

        {
            type cValue;
            unsigned char *tData = (unsigned char *)(void *)(&cValue);
            for ( int i = 0; i < (int)sizeof(cValue); i++ )
                tData[i] = sValue.section(' ', i, i).toInt();
            SetValue( cValue, bInternal );
        };

AttributeWidget * CreateEditorWidget | ( | QWidget * | pParent,
|  | int | iWidth
| ) |  | `[inline, virtual]`

Search for all occurrences

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 AttributeCheckableFloat, AttributeCheckableFloatArray, AttributeFloatRange, AttributeEnumeration, AttributeFilename, AttributeTextureFilename, and AttributeLocale.

Definition at line 450 of file node.h.

    { return Attribute::CreateEditorWidget( pParent, iWidth ); };

Attribute::AttributeType Type | ( | void |  | ) | const `[inline, virtual]`

Search for all occurrences

Returns the type of the attribute.

Reimplemented from Attribute.

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

Definition at line 451 of file node.h.

    { return Attribute::AttributeType(); };

OPERATORS | ( | type |  | ) |

Search for all occurrences

Reimplemented in AttributeNumber, and AttributeEnumeration.

## Member Data Documentation

type m_cValue

Search for all occurrences

Definition at line 481 of file node.h.

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

- Mudbox/node.h
- Mudbox/math.h
- Mudbox/stream.h