osg::QVectorFieldValueLabel< VectorTypeT > Class Template Reference

Flyweight label, specialized for Vector fields.

#include <OSGQVectorFieldValueLabel.h>

Inheritance diagram for osg::QVectorFieldValueLabel< VectorTypeT >:

osg::QFieldValueLabelBase

List of all members.

Public Types

typedef VectorTypeT VectorType
typedef VectorTypeT::ValueType ValueType

Public Member Functions

 QVectorFieldValueLabel (QFieldViewBase *pView, UInt32 uiIndex)
virtual ~QVectorFieldValueLabel (void)
virtual void paint (QPainter *pPainer, const QColorGroup &colGrp, const QRect &rect)
virtual QSize sizeHint (void)
virtual QSize minimumSizeHint (void)
virtual void valueChanged (void)
void setIndex (UInt32 uiIndex)
UInt32 getIndex (void) const

Static Public Member Functions

static QFieldValueLabelBasecreate (QFieldViewBase *pView, UInt32 uiIndex)

Protected Member Functions

const QString & getCachedValue (UInt32 uiCoordinate)
const QSize & getCachedSize (void)
QFieldViewBasegetFieldView (void)
const QFieldViewBasegetFieldView (void) const
FieldContainerPtrgetFieldContainer (void)
const FieldContainerPtrgetFieldContainer (void) const
UInt32 getFieldId (void) const
UInt32 getAspect (void) const
FieldgetFieldPtr (void)
const FieldgetFieldPtr (void) const

Private Types

typedef QFieldValueLabelBase Inherited

Private Member Functions

void updateCache (void)

Private Attributes

QString _strCachedValues [VectorType::_iSize]
QSize _cachedSize
bool _bCacheValid


Detailed Description

template<class VectorTypeT>
class osg::QVectorFieldValueLabel< VectorTypeT >

Definition at line 54 of file OSGQVectorFieldValueLabel.h.


Member Typedef Documentation

template<class VectorTypeT>
typedef VectorTypeT osg::QVectorFieldValueLabel< VectorTypeT >::VectorType

Definition at line 58 of file OSGQVectorFieldValueLabel.h.

template<class VectorTypeT>
typedef VectorTypeT::ValueType osg::QVectorFieldValueLabel< VectorTypeT >::ValueType

Definition at line 59 of file OSGQVectorFieldValueLabel.h.

template<class VectorTypeT>
typedef QFieldValueLabelBase osg::QVectorFieldValueLabel< VectorTypeT >::Inherited [private]

Definition at line 83 of file OSGQVectorFieldValueLabel.h.


Constructor & Destructor Documentation

template<class VectorTypeT>
osg::QVectorFieldValueLabel< VectorTypeT >::QVectorFieldValueLabel ( QFieldViewBase pView,
UInt32  uiIndex 
) [inline]

Definition at line 55 of file OSGQVectorFieldValueLabel.inl.

00057     : Inherited   (pView, uiIndex),
00058       _cachedSize (              ),
00059       _bCacheValid(false         )
00060 {
00061 }

template<class VectorTypeT>
osg::QVectorFieldValueLabel< VectorTypeT >::~QVectorFieldValueLabel ( void   )  [inline, virtual]

Definition at line 64 of file OSGQVectorFieldValueLabel.inl.

00065 {
00066 }


Member Function Documentation

template<class VectorTypeT>
QFieldValueLabelBase * osg::QVectorFieldValueLabel< VectorTypeT >::create ( QFieldViewBase pView,
UInt32  uiIndex 
) [inline, static]

Definition at line 70 of file OSGQVectorFieldValueLabel.inl.

00072 {
00073     return new QVectorFieldValueLabel<VectorType>(pView, uiIndex);
00074 }

template<class VectorTypeT>
void osg::QVectorFieldValueLabel< VectorTypeT >::paint ( QPainter *  pPainer,
const QColorGroup &  colGrp,
const QRect &  rect 
) [inline, virtual]

Implements osg::QFieldValueLabelBase.

Definition at line 78 of file OSGQVectorFieldValueLabel.inl.

References osg::QVectorFieldValueLabel< VectorTypeT >::getCachedValue().

00080 {
00081     QRect drawRect(0, 0, rect.width()/VectorType::_iSize, rect.height());
00082 
00083     pPainter->save();
00084 
00085     pPainter->setBrush(colGrp.base());
00086 
00087     pPainter->translate(rect.x(), rect.y());
00088 
00089     for(UInt32 i=0; i < VectorType::_iSize; ++i)
00090     {
00091         pPainter->setPen  (colGrp.background());
00092         pPainter->drawRect(drawRect           );
00093         pPainter->setPen  (colGrp.text()      );  
00094 
00095         pPainter->drawText(drawRect, AlignVCenter, getCachedValue(i));
00096 
00097         pPainter->translate(rect.width()/VectorType::_iSize, 0);
00098     }
00099 
00100     pPainter->restore();
00101 }

template<class VectorTypeT>
QSize osg::QVectorFieldValueLabel< VectorTypeT >::sizeHint ( void   )  [inline, virtual]

Implements osg::QFieldValueLabelBase.

Definition at line 105 of file OSGQVectorFieldValueLabel.inl.

References osg::QVectorFieldValueLabel< VectorTypeT >::getCachedSize().

00106 {
00107     return QSize(getCachedSize().width()  + 8,
00108                  getCachedSize().height() + 8 );
00109 }

template<class VectorTypeT>
QSize osg::QVectorFieldValueLabel< VectorTypeT >::minimumSizeHint ( void   )  [inline, virtual]

Implements osg::QFieldValueLabelBase.

Definition at line 113 of file OSGQVectorFieldValueLabel.inl.

References osg::QVectorFieldValueLabel< VectorTypeT >::getCachedSize().

00114 {
00115     return getCachedSize();
00116 }

template<class VectorTypeT>
void osg::QVectorFieldValueLabel< VectorTypeT >::valueChanged ( void   )  [inline, virtual]

Implements osg::QFieldValueLabelBase.

Definition at line 120 of file OSGQVectorFieldValueLabel.inl.

References osg::QVectorFieldValueLabel< VectorTypeT >::_bCacheValid.

00121 {
00122     _bCacheValid = false;
00123 }

template<class VectorTypeT>
const QString & osg::QVectorFieldValueLabel< VectorTypeT >::getCachedValue ( UInt32  uiCoordinate  )  [inline, protected]

template<class VectorTypeT>
const QSize & osg::QVectorFieldValueLabel< VectorTypeT >::getCachedSize ( void   )  [inline, protected]

template<class VectorTypeT>
void osg::QVectorFieldValueLabel< VectorTypeT >::updateCache ( void   )  [inline, private]

Definition at line 145 of file OSGQVectorFieldValueLabel.inl.

References osg::QVectorFieldValueLabel< VectorTypeT >::_bCacheValid, osg::QVectorFieldValueLabel< VectorTypeT >::_cachedSize, osg::QVectorFieldValueLabel< VectorTypeT >::_strCachedValues, osg::endLog(), osg::Field::getCardinality(), osg::QFieldValueLabelBase::getFieldPtr(), osg::QFieldValueLabelBase::getFieldView(), osg::QFieldValueLabelBase::getIndex(), osg::SField< FieldTypeT, fieldNameSpace >::getValue(), osg::FieldType::SINGLE_FIELD, and SWARNING.

Referenced by osg::QVectorFieldValueLabel< VectorTypeT >::getCachedSize(), and osg::QVectorFieldValueLabel< VectorTypeT >::getCachedValue().

00146 {
00147     typedef TypeTraits<ValueType> TTraits;
00148 
00149     if(_bCacheValid)
00150         return;
00151 
00152     _cachedSize.setWidth (0                                     );
00153     _cachedSize.setHeight(getFieldView()->fontMetrics().height());
00154 
00155     if(getIndex() >= getFieldPtr()->getSize())
00156     {
00157         SWARNING << "QVectorFieldValueLabel<>::updateCache(): "
00158                  << "getIndex >= getFieldPtr()->getSize()" << endLog;
00159 
00160         for(UInt32 i = 0; i < VectorType::_iSize; ++i)
00161         {
00162             _strCachedValues[i] = "";
00163             _cachedSize.setWidth(_cachedSize.width() + 10);
00164         }
00165         
00166         _bCacheValid = true;
00167 
00168         return;
00169     }    
00170 
00171     if(getFieldPtr()->getCardinality() == FieldType::SINGLE_FIELD)
00172     {
00173         SField<VectorType> *pSF = 
00174             dynamic_cast<SField<VectorType> *>(getFieldPtr());
00175 
00176         for(UInt32 i=0; i < VectorType::_iSize; ++i)
00177         {
00178             _strCachedValues[i] = 
00179                 TTraits::putToString(
00180                     pSF->getValue().getValues()[i]).c_str();
00181             
00182             _cachedSize.setWidth(_cachedSize.width() + 
00183                                  getFieldView()->fontMetrics().width(
00184                                      _strCachedValues[i]));
00185         }
00186     }
00187     else
00188     {
00189         MField<VectorType> *pMF =
00190             dynamic_cast<MField<VectorType> *>(getFieldPtr());
00191 
00192         for(UInt32 i=0; i < VectorType::_iSize; ++i)
00193         {
00194             _strCachedValues[i] =
00195                 TTraits::putToString(
00196                     (*pMF)[getIndex()].getValues()[i]).c_str();
00197             
00198             _cachedSize.setWidth(_cachedSize.width() + 
00199                                  getFieldView()->fontMetrics().width(
00200                                      _strCachedValues[i]));
00201         }
00202     }
00203 
00204     _bCacheValid = true;
00205 }

void QFieldValueLabelBase::setIndex ( UInt32  uiIndex  )  [inherited]

Definition at line 81 of file OSGQFieldValueLabel.cpp.

References osg::QFieldValueLabelBase::_uiIndex, and osg::QFieldValueLabelBase::valueChanged().

Referenced by osg::QMFieldView::acquireLabel().

00082 {
00083     _uiIndex = uiIndex;
00084 
00085     valueChanged();
00086 }

UInt32 osg::QFieldValueLabelBase::getIndex ( void   )  const [inline, inherited]

QFieldViewBase * osg::QFieldValueLabelBase::getFieldView ( void   )  [inline, protected, inherited]

const QFieldViewBase * osg::QFieldValueLabelBase::getFieldView ( void   )  const [inline, protected, inherited]

Definition at line 58 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView.

00059 {
00060     return _pView;
00061 }

FieldContainerPtr & osg::QFieldValueLabelBase::getFieldContainer ( void   )  [inline, protected, inherited]

Definition at line 64 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView, and osg::QFieldViewBase::getFieldContainer().

00065 {
00066     return _pView->getFieldContainer();
00067 }

const FieldContainerPtr & osg::QFieldValueLabelBase::getFieldContainer ( void   )  const [inline, protected, inherited]

Definition at line 70 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView, and osg::QFieldViewBase::getFieldContainer().

00071 {
00072     return _pView->getFieldContainer();
00073 }

UInt32 osg::QFieldValueLabelBase::getFieldId ( void   )  const [inline, protected, inherited]

Definition at line 76 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView, and osg::QFieldViewBase::getFieldId().

00077 {
00078     return _pView->getFieldId();
00079 }

UInt32 osg::QFieldValueLabelBase::getAspect ( void   )  const [inline, protected, inherited]

Definition at line 82 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView, and osg::QFieldViewBase::getAspect().

00083 {
00084     return _pView->getAspect();
00085 }

Field * osg::QFieldValueLabelBase::getFieldPtr ( void   )  [inline, protected, inherited]

const Field * osg::QFieldValueLabelBase::getFieldPtr ( void   )  const [inline, protected, inherited]

Definition at line 94 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView, and osg::QFieldViewBase::getFieldPtr().

00095 {
00096     return _pView->getFieldPtr();
00097 }


Member Data Documentation

template<class VectorTypeT>
QString osg::QVectorFieldValueLabel< VectorTypeT >::_strCachedValues[VectorType::_iSize] [private]

template<class VectorTypeT>
QSize osg::QVectorFieldValueLabel< VectorTypeT >::_cachedSize [private]

template<class VectorTypeT>
bool osg::QVectorFieldValueLabel< VectorTypeT >::_bCacheValid [private]


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

Generated on Mon Mar 17 12:26:47 2008 for OpenSG by  doxygen 1.5.5