#include <KDChartTextLabelCache.h>
Inheritance diagram for PrerenderedLabel:
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. | |
|
|
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 } |
|
|
Definition at line 65 of file KDChartTextLabelCache.cpp. References DUMP_CACHE_STATS.
00066 {
00067 DUMP_CACHE_STATS;
00068 }
|
|
|
Definition at line 114 of file KDChartTextLabelCache.cpp.
00115 {
00116 return m_angle;
00117 }
|
|
|
Definition at line 103 of file KDChartTextLabelCache.cpp.
00104 {
00105 return m_brush;
00106 }
|
|
|
Definition at line 81 of file KDChartTextLabelCache.cpp.
00082 {
00083 return m_font;
00084 }
|
|
|
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 }
|
|
|
|
|
|
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 }
|
|
|
Get the position of the element.
Definition at line 40 of file KDChartTextLabelCache.cpp.
00041 {
00042 return m_position;
00043 }
|
|
|
Get the reference point of the element.
Definition at line 50 of file KDChartTextLabelCache.cpp. Referenced by referencePointLocation().
00051 {
00052 return m_referencePoint;
00053 }
|
|
|
Definition at line 233 of file KDChartTextLabelCache.cpp. References PrerenderedElement::referencePoint().
00234 {
00235 return referencePointLocation( referencePoint() );
00236 }
|
|
|
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 }
|
|
|
Definition at line 108 of file KDChartTextLabelCache.cpp. References invalidate().
00109 {
00110 m_angle = angle;
00111 invalidate();
00112 }
|
|
|
Definition at line 97 of file KDChartTextLabelCache.cpp. References invalidate().
00098 {
00099 m_brush = brush;
00100 invalidate();
00101 }
|
|
|
Definition at line 75 of file KDChartTextLabelCache.cpp. References invalidate().
00076 {
00077 m_font = font;
00078 invalidate();
00079 }
|
|
|
|
|
|
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 }
|
|
|
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 }
|
|
|
Definition at line 86 of file KDChartTextLabelCache.cpp. References invalidate().
00087 {
00088 m_text = text;
00089 invalidate();
00090 }
|
|
|
Definition at line 92 of file KDChartTextLabelCache.cpp.
00093 {
00094 return m_text;
00095 }
|
1.3.6