PrerenderedLabel Class Reference

#include <KDChartTextLabelCache.h>

Inheritance diagram for PrerenderedLabel:

Inheritance graph
[legend]
Collaboration diagram for PrerenderedLabel:

Collaboration graph
[legend]

List of all members.


Detailed Description

PrerenderedLabel is an internal KDChart class that simplifies creation and caching of cached text labels.

It provides referenze points to anchor the text to other elements. Reference points use the positions defined in KDChartEnums.

Usage:

    double angle = 90.0;
    CachedLabel label;
    label.paint( font, tr("Label"), angle );
    

Definition at line 104 of file KDChartTextLabelCache.h.


Public Member Functions

double angle () const
 
Returns:
the label's angle in degrees

const QBrush & brush () const
 
Returns:
the label's brush

const QFont & font () const
 
Returns:
the label's font.

const QPen & pen () const
const QPixmap & pixmap () const
 Returns the rendered element.
const QPointF & position () const
 Get the position of the element.
 PrerenderedLabel ()
KDChartEnums::PositionValue referencePoint () const
 Get the reference point of the element.
QPointF referencePointLocation () const
QPointF referencePointLocation (KDChartEnums::PositionValue position) const
 Return the location of the reference point relatively to the pixmap's origin.
void setAngle (double angle)
 Sets the angle of the label to angle degrees.
void setBrush (const QBrush &brush)
 Sets the label's brush to brush.
void setFont (const QFont &font)
 Sets the label's font to font.
void setPen (const QPen &)
void setPosition (const QPointF &position)
 Set the position of the element.
void setReferencePoint (KDChartEnums::PositionValue)
 Set the reference point of the element.
void setText (const QString &text)
 Sets the label's text to text.
const QString & text () const
 
Returns:
the label's text

 ~PrerenderedLabel ()

Protected Member Functions

void invalidate () const
 Invalidates the preredendered data, forces re-rendering.

Constructor & Destructor Documentation

PrerenderedLabel::PrerenderedLabel (  ) 

Definition at line 83 of file KDChartTextLabelCache.cpp.

00085     : PrerenderedElement()
00086     , m_dirty( true )
00087     , m_font( qApp->font() )
00088     , m_brush( Qt::black )
00089     , m_pen( Qt::black ) // do not use anything invisible
00090     , m_angle( 0.0 )
00091 {

PrerenderedLabel::~PrerenderedLabel (  ) 

Definition at line 93 of file KDChartTextLabelCache.cpp.

References DUMP_CACHE_STATS.

00095 {
00096     DUMP_CACHE_STATS;


Member Function Documentation

double PrerenderedLabel::angle (  )  const

Returns:
the label's angle in degrees

Definition at line 169 of file KDChartTextLabelCache.cpp.

00171 {
00172     return m_angle;

const QBrush & PrerenderedLabel::brush (  )  const

Returns:
the label's brush

Definition at line 152 of file KDChartTextLabelCache.cpp.

00154 {
00155     return m_brush;

const QFont & PrerenderedLabel::font (  )  const

Returns:
the label's font.

Definition at line 118 of file KDChartTextLabelCache.cpp.

00120 {
00121     return m_font;

void PrerenderedLabel::invalidate (  )  const [protected, virtual]

Invalidates the preredendered data, forces re-rendering.

Implements PrerenderedElement.

Definition at line 101 of file KDChartTextLabelCache.cpp.

00103 {
00104     m_dirty = true;

const QPen& PrerenderedLabel::pen (  )  const

const QPixmap & PrerenderedLabel::pixmap (  )  const [virtual]

Returns the rendered element.

If any of the properties have change, the element will be regenerated.

Implements PrerenderedElement.

Definition at line 174 of file KDChartTextLabelCache.cpp.

References INC_HIT_COUNT, and INC_MISS_COUNT.

Referenced by KDChart::TernaryAxis::paintCtx(), and KDChart::TernaryAxis::requiredMargins().

00176 {
00177     if ( m_dirty ) {
00178         INC_MISS_COUNT;
00179         paint();
00180     } else {
00181         INC_HIT_COUNT;
00182     }
00183     return m_pixmap;

const QPointF & PrerenderedElement::position (  )  const [inherited]

Get the position of the element.

Definition at line 68 of file KDChartTextLabelCache.cpp.

Referenced by KDChart::TernaryAxis::paintCtx().

00070 {
00071     return m_position;

KDChartEnums::PositionValue PrerenderedElement::referencePoint (  )  const [inherited]

Get the reference point of the element.

Definition at line 78 of file KDChartTextLabelCache.cpp.

Referenced by referencePointLocation().

00080 {
00081     return m_referencePoint;

QPointF PrerenderedLabel::referencePointLocation (  )  const

Definition at line 288 of file KDChartTextLabelCache.cpp.

References PrerenderedElement::referencePoint().

00290 {
00291     return referencePointLocation( referencePoint() );

QPointF PrerenderedLabel::referencePointLocation ( KDChartEnums::PositionValue   )  const [virtual]

Return the location of the reference point relatively to the pixmap's origin.

Implements PrerenderedElement.

Definition at line 293 of file KDChartTextLabelCache.cpp.

References INC_HIT_COUNT, INC_MISS_COUNT, KDChartEnums::PositionCenter, KDChartEnums::PositionEast, KDChartEnums::PositionFloating, KDChartEnums::PositionNorth, KDChartEnums::PositionNorthEast, KDChartEnums::PositionNorthWest, KDChartEnums::PositionSouth, KDChartEnums::PositionSouthEast, KDChartEnums::PositionSouthWest, and KDChartEnums::PositionUnknown.

Referenced by KDChart::TernaryAxis::paintCtx(), and KDChart::TernaryAxis::requiredMargins().

00295 {
00296     if ( m_dirty ) {
00297         INC_MISS_COUNT;
00298         paint();
00299     } else {
00300         INC_HIT_COUNT;
00301     }
00302 
00303     switch( position ) {
00304     case KDChartEnums::PositionCenter:
00305         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector + 0.5 * m_textAscendVector;
00306     case KDChartEnums::PositionNorthWest:
00307         return m_referenceBottomLeft + m_textAscendVector;
00308     case KDChartEnums::PositionNorth:
00309         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector + m_textAscendVector;
00310     case KDChartEnums::PositionNorthEast:
00311         return m_referenceBottomLeft + m_textBaseLineVector + m_textAscendVector;
00312     case KDChartEnums::PositionEast:
00313         return m_referenceBottomLeft + 0.5 * m_textAscendVector;
00314     case KDChartEnums::PositionSouthEast:
00315         return m_referenceBottomLeft + m_textBaseLineVector;
00316     case KDChartEnums::PositionSouth:
00317         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector;
00318     case KDChartEnums::PositionSouthWest:
00319         return m_referenceBottomLeft;
00320     case KDChartEnums::PositionWest:
00321         return m_referenceBottomLeft + m_textBaseLineVector + 0.5 * m_textAscendVector;
00322 
00323     case KDChartEnums::PositionUnknown: // intentional fall-through
00324     case KDChartEnums::PositionFloating: // intentional fall-through
00325     default:
00326         return QPointF();
00327     }

void PrerenderedLabel::setAngle ( double  angle  ) 

Sets the angle of the label to angle degrees.

Definition at line 160 of file KDChartTextLabelCache.cpp.

00162 {
00163     m_angle = angle;
00164     invalidate();

void PrerenderedLabel::setBrush ( const QBrush &  brush  ) 

Sets the label's brush to brush.

Definition at line 143 of file KDChartTextLabelCache.cpp.

00145 {
00146     m_brush = brush;
00147     invalidate();

void PrerenderedLabel::setFont ( const QFont &  font  ) 

Sets the label's font to font.

Definition at line 109 of file KDChartTextLabelCache.cpp.

00111 {
00112     m_font = font;
00113     invalidate();

void PrerenderedLabel::setPen ( const QPen &   ) 

void PrerenderedElement::setPosition ( const QPointF &  position  )  [inherited]

Set the position of the element.

Definition at line 63 of file KDChartTextLabelCache.cpp.

00065 {   // this does not invalidate the element
00066     m_position = position;

void PrerenderedElement::setReferencePoint ( KDChartEnums::PositionValue  point  )  [inherited]

Set the reference point of the element.

Every element has nine possible reference points (all compass directions, plus the center.

Definition at line 73 of file KDChartTextLabelCache.cpp.

00075 {   // this does not invalidate the element
00076     m_referencePoint = point;

void PrerenderedLabel::setText ( const QString &  text  ) 

Sets the label's text to text.

Definition at line 126 of file KDChartTextLabelCache.cpp.

Referenced by KDChart::TernaryAxis::setPosition(), KDChart::TernaryAxis::setTitleText(), and KDChart::TernaryAxis::TernaryAxis().

00128 {
00129     m_text = text;
00130     invalidate();

const QString & PrerenderedLabel::text (  )  const

Returns:
the label's text

Definition at line 135 of file KDChartTextLabelCache.cpp.

Referenced by KDChart::TernaryAxis::titleText().

00137 {
00138     return m_text;


The documentation for this class was generated from the following files:
Generated on Thu Mar 4 23:24:52 2010 for KD Chart 2 by  doxygen 1.5.4