Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osg::QPointFieldValueLabel< PointTypeT > Class Template Reference

Flyweight label, specialized for Point (e.g. Pnt3f) fields.

#include <OSGQPointFieldValueLabel.h>

Inheritance diagram for osg::QPointFieldValueLabel< PointTypeT >:

osg::QFieldValueLabelBase List of all members.

Public Types

typedef PointTypeT PointType
typedef PointTypeT::ValueType ValueType

Public Member Functions

 QPointFieldValueLabel (QFieldViewBase *pView, UInt32 uiIndex)
virtual ~QPointFieldValueLabel (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 [PointType::_iSize]
QSize _cachedSize
bool _bCacheValid

Detailed Description

template<class PointTypeT>
class osg::QPointFieldValueLabel< PointTypeT >

Definition at line 53 of file OSGQPointFieldValueLabel.h.


Member Typedef Documentation

template<class PointTypeT>
typedef PointTypeT osg::QPointFieldValueLabel< PointTypeT >::PointType
 

Definition at line 57 of file OSGQPointFieldValueLabel.h.

template<class PointTypeT>
typedef PointTypeT::ValueType osg::QPointFieldValueLabel< PointTypeT >::ValueType
 

Definition at line 58 of file OSGQPointFieldValueLabel.h.

template<class PointTypeT>
typedef QFieldValueLabelBase osg::QPointFieldValueLabel< PointTypeT >::Inherited [private]
 

Definition at line 82 of file OSGQPointFieldValueLabel.h.


Constructor & Destructor Documentation

template<class PointTypeT>
osg::QPointFieldValueLabel< PointTypeT >::QPointFieldValueLabel QFieldViewBase pView,
UInt32  uiIndex
 

Definition at line 55 of file OSGQPointFieldValueLabel.inl.

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

template<class PointTypeT>
osg::QPointFieldValueLabel< PointTypeT >::~QPointFieldValueLabel void   )  [virtual]
 

Definition at line 64 of file OSGQPointFieldValueLabel.inl.

00065 {
00066 }


Member Function Documentation

template<class PointTypeT>
QFieldValueLabelBase * osg::QPointFieldValueLabel< PointTypeT >::create QFieldViewBase pView,
UInt32  uiIndex
[static]
 

Definition at line 70 of file OSGQPointFieldValueLabel.inl.

00072 {
00073     return new QPointFieldValueLabel<PointTypeT>(pView, uiIndex);
00074 }

template<class PointTypeT>
void osg::QPointFieldValueLabel< PointTypeT >::paint QPainter *  pPainer,
const QColorGroup &  colGrp,
const QRect &  rect
[virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 78 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::getCachedValue().

00080 {
00081     QRect drawRect(0, 0, rect.width()/PointType::_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 < PointType::_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()/PointType::_iSize, 0);
00098     }
00099 
00100     pPainter->restore();
00101 }

template<class PointTypeT>
QSize osg::QPointFieldValueLabel< PointTypeT >::sizeHint void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 105 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::getCachedSize().

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

template<class PointTypeT>
QSize osg::QPointFieldValueLabel< PointTypeT >::minimumSizeHint void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 113 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::getCachedSize().

00114 {
00115     return getCachedSize();
00116 }

template<class PointTypeT>
void osg::QPointFieldValueLabel< PointTypeT >::valueChanged void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 120 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::_bCacheValid.

00121 {
00122     _bCacheValid = false;
00123 }

template<class PointTypeT>
const QString & osg::QPointFieldValueLabel< PointTypeT >::getCachedValue UInt32  uiCoordinate  )  [protected]
 

Definition at line 127 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::_strCachedValues, and osg::QPointFieldValueLabel< PointTypeT >::updateCache().

Referenced by osg::QPointFieldValueLabel< PointTypeT >::paint().

00128 {
00129     updateCache();
00130 
00131     return _strCachedValues[uiCoordinate];
00132 }

template<class PointTypeT>
const QSize & osg::QPointFieldValueLabel< PointTypeT >::getCachedSize void   )  [protected]
 

Definition at line 136 of file OSGQPointFieldValueLabel.inl.

References osg::QPointFieldValueLabel< PointTypeT >::_cachedSize, and osg::QPointFieldValueLabel< PointTypeT >::updateCache().

Referenced by osg::QPointFieldValueLabel< PointTypeT >::minimumSizeHint(), and osg::QPointFieldValueLabel< PointTypeT >::sizeHint().

00137 {
00138     updateCache();
00139 
00140     return _cachedSize;
00141 }

template<class PointTypeT>
void osg::QPointFieldValueLabel< PointTypeT >::updateCache void   )  [private]
 

Definition at line 145 of file OSGQPointFieldValueLabel.inl.

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

Referenced by osg::QPointFieldValueLabel< PointTypeT >::getCachedSize(), and osg::QPointFieldValueLabel< PointTypeT >::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 << "QPointFieldValueLabel<>::updateCache(): "
00158                  << "getIndex >= getFieldPtr()->getSize()" << endLog;
00159 
00160         for(UInt32 i = 0; i < PointType::_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<PointType> *pSF =
00174             dynamic_cast<SField<PointType> *>(getFieldPtr());
00175 
00176         for(UInt32 i=0; i < PointType::_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<PointType> *pMF =
00190             dynamic_cast<MField<PointType> *>(getFieldPtr());
00191 
00192         for(UInt32 i=0; i < PointType::_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]
 

Definition at line 46 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_uiIndex.

Referenced by osg::QMFieldView::acquireLabel(), osg::QMFieldView::deleteAllLabels(), osg::QMFieldView::LabelInfo::getIndex(), osg::QMFieldView::redrawChanged(), osg::QMFieldView::releaseLabel(), osg::QVectorFieldValueLabel< VectorTypeT >::updateCache(), osg::QPointFieldValueLabel< PointTypeT >::updateCache(), osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache(), and osg::QGenericFieldValueLabel::updateCache().

00047 {
00048     return _uiIndex;
00049 }

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

Definition at line 52 of file OSGQFieldValueLabel.inl.

References osg::QFieldValueLabelBase::_pView.

Referenced by osg::QVectorFieldValueLabel< VectorTypeT >::updateCache(), osg::QPointFieldValueLabel< PointTypeT >::updateCache(), osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache(), and osg::QGenericFieldValueLabel::updateCache().

00053 {
00054     return _pView;
00055 }

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]
 

Definition at line 88 of file OSGQFieldValueLabel.inl.

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

Referenced by osg::QVectorFieldValueLabel< VectorTypeT >::updateCache(), osg::QPointFieldValueLabel< PointTypeT >::updateCache(), osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache(), and osg::QGenericFieldValueLabel::updateCache().

00089 {
00090     return _pView->getFieldPtr();
00091 }

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 PointTypeT>
QString osg::QPointFieldValueLabel< PointTypeT >::_strCachedValues[PointType::_iSize] [private]
 

Definition at line 86 of file OSGQPointFieldValueLabel.h.

Referenced by osg::QPointFieldValueLabel< PointTypeT >::getCachedValue(), and osg::QPointFieldValueLabel< PointTypeT >::updateCache().

template<class PointTypeT>
QSize osg::QPointFieldValueLabel< PointTypeT >::_cachedSize [private]
 

Definition at line 87 of file OSGQPointFieldValueLabel.h.

Referenced by osg::QPointFieldValueLabel< PointTypeT >::getCachedSize(), and osg::QPointFieldValueLabel< PointTypeT >::updateCache().

template<class PointTypeT>
bool osg::QPointFieldValueLabel< PointTypeT >::_bCacheValid [private]
 

Definition at line 88 of file OSGQPointFieldValueLabel.h.

Referenced by osg::QPointFieldValueLabel< PointTypeT >::updateCache(), and osg::QPointFieldValueLabel< PointTypeT >::valueChanged().


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:31:16 2005 for OpenSG by  doxygen 1.4.3