KD Chart 2: PrerenderedLabel class Reference

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

# PrerenderedLabel Class Reference

`#include <KDChartTextLabelCache.h>`

Inheritance diagram for PrerenderedLabel:

[legend]
Collaboration diagram for PrerenderedLabel:
[legend]
List of all members.

## Detailed Description

CachedLabel 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 69 of file KDChartTextLabelCache.h.

## Public Member Functions
double | angle () const
const QBrush & | brush () const
const QFont & | font () const
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)
void | setBrush (const QBrush &brush)
void | setFont (const QFont &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)
const QString & | text () const
| ~PrerenderedLabel ()
## Protected Member Functions
void | invalidate () const
| invalidate() needs to be called if any of the properties that determine the visual appearance of the prerendered element change.

## Constructor & Destructor Documentation

PrerenderedLabel::PrerenderedLabel | ( |  | ) |

| Definition at line 55 of file KDChartTextLabelCache.cpp.
    00056     : PrerenderedElement()
    00057     , m_dirty( true )
    00058     , m_font( qApp->font() )
    00059     , m_brush( Qt::black )
    00060     , m_pen( Qt::black ) // do not use anything invisible
    00061     , m_angle( 0.0 )
    00062 {
    00063 }

PrerenderedLabel::~PrerenderedLabel | ( |  | ) |

| Definition at line 65 of file KDChartTextLabelCache.cpp. References DUMP_CACHE_STATS.
    00066 {
    00067     DUMP_CACHE_STATS;
    00068 }

## Member Function Documentation

double PrerenderedLabel::angle | ( |  | ) | const

| Definition at line 114 of file KDChartTextLabelCache.cpp.
    00115 {
    00116     return m_angle;
    00117 }

const QBrush & PrerenderedLabel::brush | ( |  | ) | const

| Definition at line 103 of file KDChartTextLabelCache.cpp.
    00104 {
    00105     return m_brush;
    00106 }

const QFont & PrerenderedLabel::font | ( |  | ) | const

| Definition at line 81 of file KDChartTextLabelCache.cpp.
    00082 {
    00083     return m_font;
    00084 }

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

| invalidate() needs to be called if any of the properties that determine the visual appearance of the prerendered element change. It can be called for a const object, as objects may need to force recalculation of the pixmap. Implements PrerenderedElement. Definition at line 70 of file KDChartTextLabelCache.cpp. Referenced by setAngle(), setBrush(), setFont(), and setText().
    00071 {
    00072     m_dirty = true;
    00073 }

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 119 of file KDChartTextLabelCache.cpp. References INC_HIT_COUNT, and INC_MISS_COUNT.
    00120 {
    00121     if ( m_dirty ) {
    00122         INC_MISS_COUNT;
    00123         paint();
    00124     } else {
    00125         INC_HIT_COUNT;
    00126     }
    00127     return m_pixmap;
    00128 }

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

| Get the position of the element. Definition at line 40 of file KDChartTextLabelCache.cpp.
    00041 {
    00042     return m_position;
    00043 }

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

| Get the reference point of the element. Definition at line 50 of file KDChartTextLabelCache.cpp. Referenced by referencePointLocation().
    00051 {
    00052     return m_referencePoint;
    00053 }

QPointF PrerenderedLabel::referencePointLocation | ( |  | ) | const

| Definition at line 233 of file KDChartTextLabelCache.cpp. References PrerenderedElement::referencePoint().
    00234 {
    00235     return referencePointLocation( referencePoint() );
    00236 }

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

| Return the location of the reference point relatively to the pixmap's origin. Implements PrerenderedElement. Definition at line 238 of file KDChartTextLabelCache.cpp. References INC_HIT_COUNT, and INC_MISS_COUNT.
    00239 {
    00240     if ( m_dirty ) {
    00241         INC_MISS_COUNT;
    00242         paint();
    00243     } else {
    00244         INC_HIT_COUNT;
    00245     }
    00246
    00247     switch( position ) {
    00248     case KDChartEnums::PositionCenter:
    00249         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector + 0.5 * m_textAscendVector;
    00250     case KDChartEnums::PositionNorthWest:
    00251         return m_referenceBottomLeft + m_textAscendVector;
    00252     case KDChartEnums::PositionNorth:
    00253         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector + m_textAscendVector;
    00254     case KDChartEnums::PositionNorthEast:
    00255         return m_referenceBottomLeft + m_textBaseLineVector + m_textAscendVector;
    00256     case KDChartEnums::PositionEast:
    00257         return m_referenceBottomLeft + 0.5 * m_textAscendVector;
    00258     case KDChartEnums::PositionSouthEast:
    00259         return m_referenceBottomLeft + m_textBaseLineVector;
    00260     case KDChartEnums::PositionSouth:
    00261         return m_referenceBottomLeft + 0.5 * m_textBaseLineVector;
    00262     case KDChartEnums::PositionSouthWest:
    00263         return m_referenceBottomLeft;
    00264     case KDChartEnums::PositionWest:
    00265         return m_referenceBottomLeft + m_textBaseLineVector + 0.5 * m_textAscendVector;
    00266
    00267     case KDChartEnums::PositionUnknown: // intentional fall-through
    00268     case KDChartEnums::PositionFloating: // intentional fall-through
    00269     default:
    00270         return QPointF();
    00271     }
    00272 }

void PrerenderedLabel::setAngle | ( | double | angle | ) |

| Definition at line 108 of file KDChartTextLabelCache.cpp. References invalidate().
    00109 {
    00110     m_angle = angle;
    00111     invalidate();
    00112 }

void PrerenderedLabel::setBrush | ( | const QBrush & | brush | ) |

| Definition at line 97 of file KDChartTextLabelCache.cpp. References invalidate().
    00098 {
    00099     m_brush = brush;
    00100     invalidate();
    00101 }

void PrerenderedLabel::setFont | ( | const QFont & | font | ) |

| Definition at line 75 of file KDChartTextLabelCache.cpp. References invalidate().
    00076 {
    00077     m_font = font;
    00078     invalidate();
    00079 }

void PrerenderedLabel::setPen | ( | const QPen & |  | ) |

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

| Set the position of the element. Definition at line 35 of file KDChartTextLabelCache.cpp.
    00036 {   // this does not invalidate the element
    00037     m_position = position;
    00038 }

void PrerenderedElement::setReferencePoint | ( | KDChartEnums::PositionValue |  | ) | `[inherited]`

| Set the reference point of the element. Every element has nine possible reference points (all compass directions, plus the center. Definition at line 45 of file KDChartTextLabelCache.cpp.
    00046 {   // this does not invalidate the element
    00047     m_referencePoint = point;
    00048 }

void PrerenderedLabel::setText | ( | const QString & | text | ) |

| Definition at line 86 of file KDChartTextLabelCache.cpp. References invalidate().
    00087 {
    00088     m_text = text;
    00089     invalidate();
    00090 }

const QString & PrerenderedLabel::text | ( |  | ) | const

| Definition at line 92 of file KDChartTextLabelCache.cpp.
    00093 {
    00094     return m_text;
    00095 }

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

- KDChartTextLabelCache.h
- KDChartTextLabelCache.cpp