mudbox::AttributeInstance< type > Struct Template Reference

#include <node.h>

Inheritance diagram for mudbox::AttributeInstance< type >:

Inheritance graph
[legend]
List of all members.

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.


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.
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)
void  AddTarget (Attribute &cTarget)
QString  AsString (void) const
void  SetFromString (const QString &sValue)
AttributeWidget CreateEditorWidget (QWidget *pParent, int iWidth)
Attribute::AttributeType  Type (void) const
  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

template<typename type>
mudbox::AttributeInstance< type >::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.

00369 : Attribute( pOwner, sID ) { m_iSize = sizeof(type); };
template<typename type>
mudbox::AttributeInstance< 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.

00371 : Attribute( pOwner, sID ) { m_cValue = cValue; m_iSize = sizeof(type); };
template<typename type>
mudbox::AttributeInstance< 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.

00464 :

Member Function Documentation

template<typename type>
const type& mudbox::AttributeInstance< type >::Value void   )  const [inline]
 

Returns the value of the attribute.

00375 { return m_cValue; };
template<typename type>
virtual void mudbox::AttributeInstance< type >::SetValue type  cValue,
bool  bInternal = false
[inline, virtual]
 

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 mudbox::AttributePointer< type >, and mudbox::AttributePointer< NURBSCurve >.

00379     {
00380         m_cValue = cValue;
00381         UpdateTargets();
00382         if ( !bInternal )
00383             StartEvent( etValueChanged );
00384     };
template<typename type>
void mudbox::AttributeInstance< type >::UpdateTargets void   )  [inline, virtual]
 

Reimplemented from mudbox::Attribute.

00386     {
00387         for ( unsigned int i = 0; i < TargetCount(); i++ )
00388         {
00389             if ( Target(i)->Size() == Size() )
00390                 ((AttributeInstance<type> *)Target(i))->SetValue( m_cValue );
00391             else
00392                 Target(i)->StartEvent( etValueChanged );
00393         };
00394     };
template<typename type>
void mudbox::AttributeInstance< type >::Serialize Stream s  )  [inline, virtual]
 

Reimplemented from mudbox::Attribute.

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

00305 { s == m_cValue; };
template<typename type>
void mudbox::AttributeInstance< type >::AddTarget Attribute cTarget  )  [inline, virtual]
 

Reimplemented from mudbox::Attribute.

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

00399     {
00400         Attribute::AddTarget( cTarget );
00401         if ( cTarget.Size() )
00402         {
00403             AttributeInstance<type> *pT = (AttributeInstance<type> *)&cTarget;
00404             if ( pT->Value() != Value() )
00405                 pT->SetValue( Value() );
00406         };
00407 
00408         StartEvent( etTargetChanged );
00409         cTarget.StartEvent( etSourceChanged );
00410     };
QString mudbox::avector4::AsString void   )  const [inline, virtual]
 

Reimplemented from mudbox::Attribute.

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

00414     {
00415         QString sValue;
00416         const unsigned char *tData = (const unsigned char *)(void *)(&m_cValue);
00417         for ( unsigned int i = 0; i < sizeof(m_cValue); i++ )
00418         {
00419             if ( i ) 
00420                 sValue += " ";
00421             sValue += QString("%1").arg(int(tData[i]));
00422         };
00423         return sValue;
00424     };
void mudbox::avector4::SetFromString const QString &  s  )  [inline, virtual]
 

Reimplemented from mudbox::Attribute.

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

00426     {
00427         unsigned char *tData = (unsigned char *)(void *)(&m_cValue);
00428         for ( int i = 0; i < (int)sizeof(m_cValue); i++ )
00429             tData[i] = sValue.section(' ', i, i).toInt();
00430     };
AttributeWidget * mudbox::avector4::CreateEditorWidget QWidget *  pParent,
int  iWidth
[inline, virtual]
 

Reimplemented from mudbox::Attribute.

Reimplemented in mudbox::AttributeCheckableFloat, mudbox::AttributeFloatRange, mudbox::AttributeEnumeration, mudbox::AttributeFilename, mudbox::AttributeTextureFilename, and mudbox::AttributePointer< type >.

00431 { return Attribute::CreateEditorWidget( pParent, iWidth ); };
Attribute::AttributeType mudbox::avector4::Type void   )  const [inline, virtual]
 

Reimplemented from mudbox::Attribute.

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

00432 { return Attribute::AttributeType(); };
template<typename type>
mudbox::AttributeInstance< type >::OPERATORS type   ) 
 

Reimplemented in mudbox::AttributeNumber, and mudbox::AttributeEnumeration.


Member Data Documentation

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