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

osg::QMatrixFieldValueLabel< MatrixTypeT > Class Template Reference

Flyweight label, specialized for Matrix fields.

#include <OSGQMatrixFieldValueLabel.h>

Inheritance diagram for osg::QMatrixFieldValueLabel< MatrixTypeT >:

osg::QFieldValueLabelBase List of all members.

Public Types

typedef MatrixTypeT MatrixType
typedef MatrixTypeT::ValueType ValueType

Public Member Functions

 QMatrixFieldValueLabel (QFieldViewBase *pView, UInt32 uiIndex)
virtual ~QMatrixFieldValueLabel (void)
virtual void paint (QPainter *pPainter, 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 uiRow, UInt32 uiCol)
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 [16]
QSize _cachedSize
bool _bCacheValid

Detailed Description

template<class MatrixTypeT>
class osg::QMatrixFieldValueLabel< MatrixTypeT >

Definition at line 54 of file OSGQMatrixFieldValueLabel.h.


Member Typedef Documentation

template<class MatrixTypeT>
typedef MatrixTypeT osg::QMatrixFieldValueLabel< MatrixTypeT >::MatrixType
 

Definition at line 58 of file OSGQMatrixFieldValueLabel.h.

template<class MatrixTypeT>
typedef MatrixTypeT::ValueType osg::QMatrixFieldValueLabel< MatrixTypeT >::ValueType
 

Definition at line 59 of file OSGQMatrixFieldValueLabel.h.

template<class MatrixTypeT>
typedef QFieldValueLabelBase osg::QMatrixFieldValueLabel< MatrixTypeT >::Inherited [private]
 

Definition at line 81 of file OSGQMatrixFieldValueLabel.h.


Constructor & Destructor Documentation

template<class MatrixTypeT>
osg::QMatrixFieldValueLabel< MatrixTypeT >::QMatrixFieldValueLabel QFieldViewBase pView,
UInt32  uiIndex
 

Definition at line 57 of file OSGQMatrixFieldValueLabel.inl.

00059     : Inherited   (pView, uiIndex),
00060       _cachedSize (              ),
00061       _bCacheValid(false         )
00062 {
00063 }

template<class MatrixTypeT>
osg::QMatrixFieldValueLabel< MatrixTypeT >::~QMatrixFieldValueLabel void   )  [virtual]
 

Definition at line 66 of file OSGQMatrixFieldValueLabel.inl.

00067 {
00068 }


Member Function Documentation

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

Definition at line 72 of file OSGQMatrixFieldValueLabel.inl.

00074 {
00075     return (new QMatrixFieldValueLabel<MatrixType>(pView, uiIndex));
00076 }

template<class MatrixTypeT>
void osg::QMatrixFieldValueLabel< MatrixTypeT >::paint QPainter *  pPainter,
const QColorGroup &  colGrp,
const QRect &  rect
[virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 80 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedValue().

00082 {
00083     QRect drawRect(0, 0, rect.width()/4, rect.height()/4);
00084 
00085     pPainter->save();
00086 
00087     pPainter->setBrush(colGrp.base());
00088 
00089     pPainter->translate(rect.x(), rect.y());
00090 
00091     for(UInt32 row = 0; row < 4; ++row)
00092     {
00093         pPainter->save();
00094 
00095         for(UInt32 col = 0; col < 4; ++col)
00096         {
00097             pPainter->setPen  (colGrp.background());
00098             pPainter->drawRect(drawRect           );
00099             pPainter->setPen  (colGrp.text()      );
00100 
00101             pPainter->drawText (drawRect, AlignVCenter, 
00102                                 getCachedValue(row, col));
00103             pPainter->translate(rect.width()/4, 0       );
00104         }
00105         
00106         pPainter->restore  (                    );
00107         pPainter->translate(0, rect.height() / 4);
00108     }
00109 
00110     pPainter->restore();
00111 }

template<class MatrixTypeT>
QSize osg::QMatrixFieldValueLabel< MatrixTypeT >::sizeHint void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 115 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedSize().

00116 {
00117     return QSize(getCachedSize().width()  + 8,
00118                  getCachedSize().height() + 8 );
00119 }

template<class MatrixTypeT>
QSize osg::QMatrixFieldValueLabel< MatrixTypeT >::minimumSizeHint void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 123 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedSize().

00124 {
00125     return getCachedSize();
00126 }

template<class MatrixTypeT>
void osg::QMatrixFieldValueLabel< MatrixTypeT >::valueChanged void   )  [virtual]
 

Implements osg::QFieldValueLabelBase.

Definition at line 130 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::_bCacheValid.

00131 {
00132     _bCacheValid = false;
00133 }

template<class MatrixTypeT>
const QString & osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedValue UInt32  uiRow,
UInt32  uiCol
[protected]
 

Definition at line 137 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::_strCachedValues, and osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache().

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::paint().

00138 {
00139     updateCache();
00140 
00141     return _strCachedValues[4 * uiRow + uiCol];
00142 }

template<class MatrixTypeT>
const QSize & osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedSize void   )  [protected]
 

Definition at line 146 of file OSGQMatrixFieldValueLabel.inl.

References osg::QMatrixFieldValueLabel< MatrixTypeT >::_cachedSize, and osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache().

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::minimumSizeHint(), and osg::QMatrixFieldValueLabel< MatrixTypeT >::sizeHint().

00147 {
00148     updateCache();
00149 
00150     return _cachedSize;
00151 }

template<class MatrixTypeT>
void osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache void   )  [private]
 

Definition at line 155 of file OSGQMatrixFieldValueLabel.inl.

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

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedSize(), and osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedValue().

00156 {
00157     typedef TypeTraits<ValueType> TTraits;
00158 
00159     if(_bCacheValid)
00160         return;
00161 
00162     if(getIndex() >= getFieldPtr()->getSize())
00163     {
00164         SWARNING << "QMatrixFieldValueLabel<>::updateCache(): "
00165                  << "getIndex >= getFieldPtr()->getSize()" << endLog;
00166 
00167         for(UInt32 i = 0; i < 16; ++i)
00168         {
00169             _strCachedValues[i] = "";
00170         }
00171 
00172         _cachedSize.setWidth (4 * 10                                );
00173         _cachedSize.setHeight(getFieldView()->fontMetrics().height());
00174         
00175         _bCacheValid = true;
00176 
00177         return;
00178     }
00179 
00180     Int32 widthOfCol [4] = { 0, 0, 0, 0 };
00181 
00182     if(getFieldPtr()->getCardinality() == FieldType::SINGLE_FIELD)
00183     {
00184         SField<MatrixType> *pSF =
00185             dynamic_cast<SField<MatrixType> *>(getFieldPtr());
00186 
00187         for(UInt32 row = 0; row < 4; ++row)
00188         {
00189             for(UInt32 col = 0; col < 4; ++col)
00190             {
00191                 _strCachedValues[4 * row + col] =
00192                     TTraits::putToString(
00193                         pSF->getValue().getValues()[4 * col + row]
00194                                         ).c_str();
00195 
00196                 widthOfCol[col] = osgMax(widthOfCol[col], 
00197                                          getFieldView()->fontMetrics().width(
00198                                              _strCachedValues[4 * row + col]));
00199             }
00200         }
00201     }
00202     else
00203     {
00204         MField<MatrixType> *pMF =
00205             dynamic_cast<MField<MatrixType> *>(getFieldPtr());
00206 
00207        for(UInt32 row = 0; row < 4; ++row)
00208         {
00209             for(UInt32 col = 0; col < 4; ++col)
00210             {
00211                 _strCachedValues[4 * row + col] =
00212                     TTraits::putToString(
00213                         (*pMF)[getIndex()].getValues()[4 * col + row]
00214                                         ).c_str();
00215 
00216                 widthOfCol[col] = osgMax(widthOfCol[col], 
00217                                          getFieldView()->fontMetrics().width(
00218                                              _strCachedValues[4 * row + col]));
00219             }
00220         } 
00221     }
00222 
00223     _cachedSize.setWidth (    widthOfCol[0] + widthOfCol[1] +
00224                               widthOfCol[2] + widthOfCol[3]         );
00225     _cachedSize.setHeight(4 * getFieldView()->fontMetrics().height());
00226     
00227     _bCacheValid = true;
00228 }

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 MatrixTypeT>
QString osg::QMatrixFieldValueLabel< MatrixTypeT >::_strCachedValues[16] [private]
 

Definition at line 85 of file OSGQMatrixFieldValueLabel.h.

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedValue(), and osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache().

template<class MatrixTypeT>
QSize osg::QMatrixFieldValueLabel< MatrixTypeT >::_cachedSize [private]
 

Definition at line 86 of file OSGQMatrixFieldValueLabel.h.

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::getCachedSize(), and osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache().

template<class MatrixTypeT>
bool osg::QMatrixFieldValueLabel< MatrixTypeT >::_bCacheValid [private]
 

Definition at line 87 of file OSGQMatrixFieldValueLabel.h.

Referenced by osg::QMatrixFieldValueLabel< MatrixTypeT >::updateCache(), and osg::QMatrixFieldValueLabel< MatrixTypeT >::valueChanged().


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