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

osg::QGenericFieldValueLabel Class Reference

Flyweight label, that uses the text representation of the fields.

#include <OSGQFieldValueLabel.h>

Inheritance diagram for osg::QGenericFieldValueLabel:

osg::QFieldValueLabelBase osg::QTypedFieldValueLabel< FieldContentsTypeT > List of all members.

Public Member Functions

 QGenericFieldValueLabel (QFieldViewBase *pView, UInt32 uiIndex)
virtual ~QGenericFieldValueLabel (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 (void)
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 _strCachedVal
QSize _cachedSize
bool _bCacheValid

Detailed Description

Definition at line 106 of file OSGQFieldValueLabel.h.


Member Typedef Documentation

typedef QFieldValueLabelBase osg::QGenericFieldValueLabel::Inherited [private]
 

Reimplemented in osg::QTypedFieldValueLabel< FieldContentsTypeT >.

Definition at line 129 of file OSGQFieldValueLabel.h.


Constructor & Destructor Documentation

QGenericFieldValueLabel::QGenericFieldValueLabel QFieldViewBase pView,
UInt32  uiIndex
 

Constructor

Definition at line 95 of file OSGQFieldValueLabel.cpp.

Referenced by create().

00097     : Inherited    (pView, uiIndex),
00098       _strCachedVal(              ),
00099       _cachedSize  (              ),
00100       _bCacheValid (false         )
00101 {
00102 }

QGenericFieldValueLabel::~QGenericFieldValueLabel void   )  [virtual]
 

Destructor

Definition at line 116 of file OSGQFieldValueLabel.cpp.

00117 {
00118 }


Member Function Documentation

QFieldValueLabelBase * QGenericFieldValueLabel::create QFieldViewBase pView,
UInt32  uiIndex
[static]
 

Create function, which is registered at the QFieldLabelFactory.

Definition at line 108 of file OSGQFieldValueLabel.cpp.

References QGenericFieldValueLabel().

00109 {
00110     return new QGenericFieldValueLabel(pView, uiIndex);
00111 }

void QGenericFieldValueLabel::paint QPainter *  pPainter,
const QColorGroup &  colGrp,
const QRect &  rect
[virtual]
 

Draws the text representation of a field value.

Implements osg::QFieldValueLabelBase.

Definition at line 124 of file OSGQFieldValueLabel.cpp.

References getCachedValue(), and sizeHint().

00126 {
00127     if(!rect.isValid())
00128         return;
00129 
00130     pPainter->save();
00131 
00132     pPainter->setPen  (colGrp.text());
00133     pPainter->setBrush(colGrp.base());
00134 
00135     if( (rect.width() < sizeHint().width())   || 
00136         (rect.height() < sizeHint().height())   )
00137     {
00138         pPainter->drawRect(rect);
00139 
00140         pPainter->drawText(rect, AlignVCenter, getCachedValue());
00141     }
00142     else
00143     {
00144         QRect rectText(rect.x()    +4, rect.y()     +4, 
00145                        rect.width()-8, rect.height()-8 );
00146 
00147         pPainter->drawRect(rect);
00148 
00149         pPainter->drawText(rectText, AlignVCenter, getCachedValue());
00150     }
00151 
00152     pPainter->restore();
00153 }

QSize QGenericFieldValueLabel::sizeHint void   )  [virtual]
 

Get the best size for this label.

Implements osg::QFieldValueLabelBase.

Definition at line 159 of file OSGQFieldValueLabel.cpp.

References getCachedSize().

Referenced by paint().

00160 {
00161     return QSize(getCachedSize().width()  + 8,
00162                  getCachedSize().height() + 8);
00163 }

QSize QGenericFieldValueLabel::minimumSizeHint void   )  [virtual]
 

Get the minimal size for this label.

Implements osg::QFieldValueLabelBase.

Definition at line 169 of file OSGQFieldValueLabel.cpp.

References getCachedSize().

00170 {
00171     return getCachedSize();
00172 }

void QGenericFieldValueLabel::valueChanged void   )  [virtual]
 

Tell the label, that the shown field's value has changed.

Implements osg::QFieldValueLabelBase.

Definition at line 178 of file OSGQFieldValueLabel.cpp.

References _bCacheValid.

00179 {
00180     _bCacheValid = false;
00181 }

const QString & QGenericFieldValueLabel::getCachedValue void   )  [protected]
 

Definition at line 184 of file OSGQFieldValueLabel.cpp.

References _strCachedVal, and updateCache().

Referenced by paint().

00185 {
00186     updateCache();
00187 
00188     return _strCachedVal;
00189 }

const QSize & QGenericFieldValueLabel::getCachedSize void   )  [protected]
 

Definition at line 192 of file OSGQFieldValueLabel.cpp.

References _cachedSize, and updateCache().

Referenced by minimumSizeHint(), and sizeHint().

00193 {
00194     updateCache();
00195 
00196     return _cachedSize;
00197 }

void QGenericFieldValueLabel::updateCache void   )  [private]
 

If necessary the cached text representation of the field's value is updated.

Definition at line 204 of file OSGQFieldValueLabel.cpp.

References _bCacheValid, _cachedSize, _strCachedVal, osg::QFieldValueLabelBase::getFieldPtr(), osg::QFieldValueLabelBase::getFieldView(), osg::QFieldValueLabelBase::getIndex(), osg::Field::getSize(), and osg::Field::getValueByStr().

Referenced by getCachedSize(), and getCachedValue().

00205 {
00206     if(_bCacheValid)
00207         return;
00208 
00209     if(getIndex() >= getFieldPtr()->getSize())
00210     {
00211         _strCachedVal = "";
00212         _cachedSize   = QSize(10, getFieldView()->fontMetrics().height());
00213         _bCacheValid  = true;
00214 
00215         return;
00216     }
00217 
00218     std::string strTemp;
00219 
00220     getFieldPtr()->getValueByStr(strTemp, getIndex());
00221     
00222     _strCachedVal = strTemp.c_str();
00223     
00224     _cachedSize   = QSize(getFieldView()->fontMetrics().width (_strCachedVal),
00225                           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 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 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 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

QString osg::QGenericFieldValueLabel::_strCachedVal [private]
 

Definition at line 133 of file OSGQFieldValueLabel.h.

Referenced by getCachedValue(), and updateCache().

QSize osg::QGenericFieldValueLabel::_cachedSize [private]
 

Definition at line 134 of file OSGQFieldValueLabel.h.

Referenced by getCachedSize(), and updateCache().

bool osg::QGenericFieldValueLabel::_bCacheValid [private]
 

Definition at line 135 of file OSGQFieldValueLabel.h.

Referenced by updateCache(), and valueChanged().


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