KD Chart 2: KDChart::TernaryAxis Class Reference

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# KDChart::TernaryAxis Class Reference

`#include <KDChartTernaryAxis.h>`

Inheritance diagram for KDChart::TernaryAxis:

[legend]
Collaboration diagram for KDChart::TernaryAxis:

[legend]
List of all members.

## Detailed Description

The class for ternary axes.

Definition at line 47 of file KDChartTernaryAxis.h.

## Public Slots
void | update ()
## Signals
void | positionChanged (AbstractArea *)
## Public Member Functions
void | alignToReferencePoint (const RelativePosition &position)
BackgroundAttributes | backgroundAttributes () const
virtual int | bottomOverlap (bool doNotRecalculate=false) const
| This is called at layout time by KDChart:AutoSpacerLayoutItem::sizeHint().
bool | compare (const AbstractAreaBase *other) const
| Returns true if both areas have the same settings.
bool | compare (const AbstractAxis *other) const
| Returns true if both axes have the same settings.
virtual void | connectSignals ()
| Wireing the signal/slot connections.
const AbstractCoordinatePlane * | coordinatePlane () const
| Convenience function, returns the coordinate plane, in which this axis is used.
void | createObserver (AbstractDiagram *diagram)
virtual const QString | customizedLabel (const QString &label) const
| Implement this method if you want to adjust axis labels before they are printed.
void | deleteObserver (AbstractDiagram *diagram)
const AbstractDiagram * | diagram () const
virtual Qt::Orientations | expandingDirections () const
FrameAttributes | frameAttributes () const
virtual QRect | geometry () const
void | getFrameLeadings (int &left, int &top, int &right, int &bottom) const
bool | hasDefaultTitleTextAttributes () const
virtual bool | isEmpty () const
QStringList | labels () const
| Returns a list of strings, that are used as axis labels, as set via setLabels.
virtual int | leftOverlap (bool doNotRecalculate=false) const
| This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
virtual QSize | maximumSize () const
virtual QSize | minimumSize () const
bool | observedBy (AbstractDiagram *diagram) const
virtual void | paint (QPainter *)
virtual void | paintAll (QPainter &)
| Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.
virtual void | paintBackground (QPainter &painter, const QRect &rectangle)
virtual void | paintCtx (PaintContext *)
| Default impl: Paint the complete item using its layouted position and size.
virtual void | paintFrame (QPainter &painter, const QRect &rectangle)
virtual void | paintIntoRect (QPainter &painter, const QRect &rect)
| Draws the background and frame, then calls paint().
QLayout * | parentLayout ()
virtual const Position | position () const
void | removeFromParentLayout ()
QPair< QSizeF, QSizeF > | requiredMargins () const
void | resetTitleTextAttributes ()
virtual int | rightOverlap (bool doNotRecalculate=false) const
| This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
void | setBackgroundAttributes (const BackgroundAttributes &a)
void | setFrameAttributes (const FrameAttributes &a)
virtual void | setGeometry (const QRect &rect)
void | setLabels (const QStringList &list)
| Use this to specify your own set of strings, to be used as axis labels.
void | setParentLayout (QLayout *lay)
virtual void | setParentWidget (QWidget *widget)
| Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed.
virtual void | setPosition (Position p)
void | setShortLabels (const QStringList &list)
| Use this to specify your own set of strings, to be used as axis labels, in case the normal labels are too long.
void | setTextAttributes (const TextAttributes &a)
| Use this to specify the text attributes to be used for axis labels.
void | setTitleText (const QString &text)
void | setTitleTextAttributes (const TextAttributes &a)
QStringList | shortLabels () const
| Returns a list of strings, that are used as axis labels, as set via setShortLabels.
virtual QSize | sizeHint () const
virtual void | sizeHintChanged () const
| Report changed size hint: ask the parent widget to recalculate the layout.
| TernaryAxis (AbstractTernaryDiagram *diagram=0)
TextAttributes | textAttributes () const
| Returns the text attributes to be used for axis labels.
QString | titleText () const
TextAttributes | titleTextAttributes () const
virtual int | topOverlap (bool doNotRecalculate=false) const
| This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
| ~TernaryAxis ()
## Static Public Member Functions
static void | paintBackgroundAttributes (QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes)
static void | paintFrameAttributes (QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes)
## Protected Slots
virtual void | delayedInit ()
| called for initializing after the c'tor has completed
## Protected Member Functions
virtual QRect | areaGeometry () const
QRect | innerRect () const
virtual void | positionHasChanged ()
## Protected Attributes
QWidget * | mParent
QLayout * | mParentLayout

## Constructor & Destructor Documentation

TernaryAxis::TernaryAxis | ( | AbstractTernaryDiagram * | diagram = `0` | ) | `[explicit]`

Definition at line 49 of file KDChartTernaryAxis.cpp.

References KDChart::AbstractAxis::diagram(), KDChartEnums::PositionSouth, resetTitleTextAttributes(), setPosition(), and PrerenderedLabel::setText().

    00050     : AbstractAxis( diagram )
    00051     , m_position( KDChartEnums::PositionUnknown )
    00052     , m_label( new PrerenderedLabel )
    00053     , m_fifty( new PrerenderedLabel )
    00054 {
    00055     resetTitleTextAttributes();
    00056     setPosition( KDChartEnums::PositionSouth ); // arbitrary
    00057     m_fifty->setText( QObject::tr( "50%" ) ); // const
    00058     // FIXME is this consistent with other diagram/axis/plane implementations?
    00059     diagram->addAxis( this );
    00060 }

TernaryAxis::~TernaryAxis | ( |  | ) |

Definition at line 62 of file KDChartTernaryAxis.cpp.

    00063 {
    00064     delete m_label; m_label = 0;
    00065     delete m_label; m_fifty = 0;
    00066 }

## Member Function Documentation

void AbstractAreaBase::alignToReferencePoint | ( | const RelativePosition & | position | ) | `[inherited]`

Definition at line 90 of file KDChartAbstractAreaBase.cpp.

    00091 {
    00092     Q_UNUSED( position );
    00093     // PENDING(kalle) FIXME
    00094     qWarning( "Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )" );
    00095 }

QRect AbstractArea::areaGeometry | ( |  | ) | const`[protected, virtual, inherited]`

Implements KDChart::AbstractAreaBase.

Definition at line 150 of file KDChartAbstractArea.cpp.

Referenced by KDChart::CartesianCoordinatePlane::drawingArea(), KDChart::TernaryCoordinatePlane::layoutDiagrams(), KDChart::PolarCoordinatePlane::layoutDiagrams(), KDChart::TernaryCoordinatePlane::paint(), KDChart::CartesianAxis::paint(), KDChart::AbstractArea::paintAll(), and KDChart::CartesianAxis::paintCtx().

    00151 {
    00152     return geometry();
    00153 }

BackgroundAttributes AbstractAreaBase::backgroundAttributes | ( |  | ) | const`[inherited]`

Definition at line 120 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::AbstractAreaBase::compare(), and updateCommonBrush().

    00121 {
    00122     return d->backgroundAttributes;
    00123 }

int AbstractArea::bottomOverlap | ( | bool | doNotRecalculate = `false` | ) | const`[virtual, inherited]`

This is called at layout time by KDChart:AutoSpacerLayoutItem::sizeHint().

The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the bottom edge of the area.

Note:
  The default implementation is not using any caching, it might make sense to implement a more sophisticated solution for derived classes that have complex work to do in sizeHint(). All we have here is a primitive flag to be set by the caller if it is sure that no sizeHint() needs to be called.

Definition at line 101 of file KDChartAbstractArea.cpp.

References d.

Referenced by KDChart::CartesianAxis::maximumSize().

    00102 {
    00103     // Re-calculate the sizes,
    00104     // so we also get the amountOf..Overlap members set newly:
    00105     if( ! doNotRecalculate )
    00106         sizeHint();
    00107     return d->amountOfBottomOverlap;
    00108 }

bool AbstractAreaBase::compare | ( | const AbstractAreaBase * | other | ) | const`[inherited]`

Returns true if both areas have the same settings.

Definition at line 75 of file KDChartAbstractAreaBase.cpp.

References KDChart::AbstractAreaBase::backgroundAttributes(), and KDChart::AbstractAreaBase::frameAttributes().

    00076 {
    00077     if( other == this ) return true;
    00078     if( ! other ){
    00079         //qDebug() << "CartesianAxis::compare() cannot compare to Null pointer";
    00080         return false;
    00081     }
    00082     /*
    00083     qDebug() << "AbstractAreaBase:" << (frameAttributes() == other->frameAttributes())
    00084         << (backgroundAttributes() == other->backgroundAttributes()) << "\n";
    00085     */
    00086     return  (frameAttributes()      == other->frameAttributes()) &&
    00087             (backgroundAttributes() == other->backgroundAttributes());
    00088 }

bool AbstractAxis::compare | ( | const AbstractAxis * | other | ) | const`[inherited]`

Returns true if both axes have the same settings.

Definition at line 142 of file KDChartAbstractAxis.cpp.

References KDChart::AbstractAxis::labels(), KDChart::AbstractAxis::shortLabels(), and KDChart::AbstractAxis::textAttributes().

    00143 {
    00144     if( other == this ) return true;
    00145     if( ! other ){
    00146         //qDebug() << "CartesianAxis::compare() cannot compare to Null pointer";
    00147         return false;
    00148     }
    00149     /*
    00150     qDebug() << (textAttributes() == other->textAttributes());
    00151     qDebug() << (labels()         == other->labels());
    00152     qDebug() << (shortLabels()    == other->shortLabels());
    00153     */
    00154     return  ( static_cast<const AbstractAreaBase*>(this)->compare( other ) ) &&
    00155             (textAttributes() == other->textAttributes()) &&
    00156             (labels()         == other->labels()) &&
    00157             (shortLabels()    == other->shortLabels());
    00158 }

void AbstractAxis::connectSignals | ( |  | ) | `[virtual, inherited]`

Wireing the signal/slot connections.

This method gets called automatically, each time, when you assign the axis to a diagram, either by passing a diagram* to the c'tor, or by calling the diagram's setAxis method, resp.

If overwriting this method in derived classes, make sure to call this base method AbstractAxis::connectSignals(), so your axis gets connected to the diagram's built-in signals.

See also:
  AbstractCartesianDiagram::addAxis()

Definition at line 211 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::update().

Referenced by KDChart::AbstractAxis::createObserver().

    00212 {
    00213     if( d->observer ){
    00214         connect( d->observer, SIGNAL( diagramDataChanged( AbstractDiagram *) ),
    00215                 this, SLOT( update() ) );
    00216     }
    00217 }

const AbstractCoordinatePlane * AbstractAxis::coordinatePlane | ( |  | ) | const`[inherited]`

Convenience function, returns the coordinate plane, in which this axis is used.

If the axis is not used in a coordinate plane, the return value is Zero.

Definition at line 324 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::CartesianCoordinatePlane::sharedAxisMasterPlane().

    00325 {
    00326     if( d->diagram() )
    00327         return d->diagram()->coordinatePlane();
    00328     return 0;
    00329 }

void AbstractAxis::createObserver | ( | AbstractDiagram * | diagram | ) | `[inherited]`

Definition at line 177 of file KDChartAbstractAxis.cpp.

References KDChart::AbstractAxis::connectSignals(), d, and KDChart::AbstractAxis::diagram().

    00178 {
    00179     if( d->setDiagram( diagram ) )
    00180         connectSignals();
    00181 }

const QString AbstractAxis::customizedLabel | ( | const QString & | label | ) | const`[virtual, inherited]`

Implement this method if you want to adjust axis labels before they are printed.

KD Chart is calling this method immediately before drawing the text, this means: What you return here will be drawn without further modifications.

Parameters:

  | label | The text of the label as KD Chart has calculated it automatically (or as it was taken from a QStringList provided by you, resp.)

Returns:
  The text to be drawn. By default this is the same as `label`.

Definition at line 161 of file KDChartAbstractAxis.cpp.

Referenced by KDChart::CartesianAxis::maximumSize(), and KDChart::CartesianAxis::paintCtx().

    00162 {
    00163     return label;
    00164 }

void AbstractAxis::delayedInit | ( |  | ) | `[protected, virtual, slot, inherited]`

called for initializing after the c'tor has completed

Definition at line 134 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::AbstractAxis().

    00135 {
    00136     // We call setDiagram() here, because the c'tor of Private
    00137     // only has stored the pointers, but it did not call setDiagram().
    00138     if( d )
    00139         d->setDiagram( 0, true /* delayedInit */ );
    00140 }

void AbstractAxis::deleteObserver | ( | AbstractDiagram * | diagram | ) | `[inherited]`

Definition at line 193 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::diagram().

Referenced by KDChart::AbstractCartesianDiagram::takeAxis(), and KDChart::AbstractCartesianDiagram::~AbstractCartesianDiagram().

    00194 {
    00195     d->unsetDiagram( diagram );
    00196 }

const AbstractDiagram * KDChart::AbstractAxis::diagram | ( |  | ) | const`[inherited]`

Definition at line 331 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::createObserver(), KDChart::AbstractAxis::deleteObserver(), KDChart::AbstractAxis::observedBy(), KDChart::CartesianAxis::paintCtx(), TernaryAxis(), and KDChart::CartesianAxis::~CartesianAxis().

    00332 {
    00333     return d->diagram();
    00334 }

Qt::Orientations TernaryAxis::expandingDirections | ( |  | ) | const`[virtual]`

Definition at line 130 of file KDChartTernaryAxis.cpp.

    00131 {
    00132     return Qt::Vertical | Qt::Horizontal;
    00133 }

FrameAttributes AbstractAreaBase::frameAttributes | ( |  | ) | const`[inherited]`

Definition at line 106 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::Legend::clone(), KDChart::AbstractAreaBase::compare(), and updateCommonBrush().

    00107 {
    00108     return d->frameAttributes;
    00109 }

QRect TernaryAxis::geometry | ( |  | ) | const`[virtual]`

Implements KDChart::AbstractAxis.

Definition at line 104 of file KDChartTernaryAxis.cpp.

    00105 {
    00106     return m_geometry;
    00107 }

void AbstractAreaBase::getFrameLeadings | ( | int & | left,
|  | int & | top,
|  | int & | right,
|  | int & | bottom |
| ) |  |  | const`[inherited]`

Definition at line 212 of file KDChartAbstractAreaBase.cpp.

References d.

Referenced by KDChart::AbstractAreaBase::innerRect(), and KDChart::AbstractAreaWidget::paintAll().

    00213 {
    00214     if( d && d->frameAttributes.isVisible() ){
    00215         const int padding = qMax( d->frameAttributes.padding(), 0 );
    00216         left   = padding;
    00217         top    = padding;
    00218         right  = padding;
    00219         bottom = padding;
    00220     }else{
    00221         left   = 0;
    00222         top    = 0;
    00223         right  = 0;
    00224         bottom = 0;
    00225     }
    00226 }

bool TernaryAxis::hasDefaultTitleTextAttributes | ( |  | ) | const

Definition at line 201 of file KDChartTernaryAxis.cpp.

    00202 {
    00203     TextAttributes a;
    00204     return m_titleAttributes == a;
    00205 }

QRect AbstractAreaBase::innerRect | ( |  | ) | const`[protected, inherited]`

Definition at line 228 of file KDChartAbstractAreaBase.cpp.

References KDChart::AbstractAreaBase::areaGeometry(), and KDChart::AbstractAreaBase::getFrameLeadings().

Referenced by KDChart::TextArea::paintAll(), and KDChart::AbstractArea::paintAll().

    00229 {
    00230     int left;
    00231     int top;
    00232     int right;
    00233     int bottom;
    00234     getFrameLeadings( left, top, right, bottom );
    00235     return
    00236         QRect( QPoint(0,0), areaGeometry().size() )
    00237             .adjusted( left, top, -right, -bottom );
    00238 }

bool TernaryAxis::isEmpty | ( |  | ) | const`[virtual]`

Definition at line 98 of file KDChartTernaryAxis.cpp.

    00099 {
    00100     // todo: what's this method for?
    00101     return false;
    00102 }

QStringList AbstractAxis::labels | ( |  | ) | const`[inherited]`

Returns a list of strings, that are used as axis labels, as set via setLabels.

See also:
  setLabels

Definition at line 281 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::compare(), KDChart::CartesianAxis::maximumSize(), paintCtx(), and KDChart::CartesianAxis::paintCtx().

    00282 {
    00283     return d->hardLabels;
    00284 }

int AbstractArea::leftOverlap | ( | bool | doNotRecalculate = `false` | ) | const`[virtual, inherited]`

This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().

The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the left edge of the area.

Note:
  The default implementation is not using any caching, it might make sense to implement a more sophisticated solution for derived classes that have complex work to do in sizeHint(). All we have here is a primitive flag to be set by the caller if it is sure that no sizeHint() needs to be called.

Definition at line 77 of file KDChartAbstractArea.cpp.

References d.

Referenced by KDChart::CartesianAxis::maximumSize().

    00078 {
    00079     // Re-calculate the sizes,
    00080     // so we also get the amountOf..Overlap members set newly:
    00081     if( ! doNotRecalculate )
    00082         sizeHint();
    00083     return d->amountOfLeftOverlap;
    00084 }

QSize TernaryAxis::maximumSize | ( |  | ) | const`[virtual]`

Definition at line 120 of file KDChartTernaryAxis.cpp.

    00121 {
    00122     return QSize( 300, 200 );
    00123 }

QSize TernaryAxis::minimumSize | ( |  | ) | const`[virtual]`

Definition at line 114 of file KDChartTernaryAxis.cpp.

    00115 {
    00116     // todo: return realistic sizes
    00117     return QSize( 100, 100 );
    00118 }

bool KDChart::AbstractAxis::observedBy | ( | AbstractDiagram * | diagram | ) | const`[inherited]`

Definition at line 336 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::diagram().

    00337 {
    00338     return d->hasDiagram( diagram );
    00339 }

void TernaryAxis::paint | ( | QPainter * |  | ) | `[virtual]`

Implements KDChart::AbstractLayoutItem.

Definition at line 73 of file KDChartTernaryAxis.cpp.

    00074 {
    00075     // not used
    00076 }

void TernaryAxis::paintAll | ( | QPainter & |  | ) | `[virtual]`

Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.

Reimplemented from KDChart::AbstractArea.

Definition at line 68 of file KDChartTernaryAxis.cpp.

    00069 {
    00070     // not used
    00071 }

void AbstractAreaBase::paintBackground | ( | QPainter & | painter,
|  | const QRect & | rectangle |
| ) |  |  | `[virtual, inherited]`

Definition at line 196 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::paintBackgroundAttributes().

Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().

    00197 {
    00198     Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintBackground()",
    00199                 "Private class was not initialized!" );
    00200     paintBackgroundAttributes( painter, rect, d->backgroundAttributes );
    00201 }

void AbstractAreaBase::paintBackgroundAttributes | ( | QPainter & | painter,
|  | const QRect & | rectangle,
|  | const KDChart::BackgroundAttributes & | attributes |
| ) |  |  | `[static, inherited]`

Definition at line 127 of file KDChartAbstractAreaBase.cpp.

References KDChart::BackgroundAttributes::BackgroundPixmapModeCentered, KDChart::BackgroundAttributes::BackgroundPixmapModeNone, KDChart::BackgroundAttributes::BackgroundPixmapModeScaled, KDChart::BackgroundAttributes::BackgroundPixmapModeStretched, KDChart::BackgroundAttributes::brush(), KDChart::BackgroundAttributes::isVisible(), KDChart::BackgroundAttributes::pixmap(), and KDChart::BackgroundAttributes::pixmapMode().

Referenced by KDChart::AbstractAreaBase::paintBackground().

    00129 {
    00130     if( !attributes.isVisible() ) return;
    00131
    00132     /* first draw the brush (may contain a pixmap)*/
    00133     if( Qt::NoBrush != attributes.brush().style() ) {
    00134         KDChart::PainterSaver painterSaver( &painter );
    00135         painter.setPen( Qt::NoPen );
    00136         const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) );
    00137         painter.setBrushOrigin( newTopLeft );
    00138         painter.setBrush( attributes.brush() );
    00139         painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) );
    00140     }
    00141     /* next draw the backPixmap over the brush */
    00142     if( !attributes.pixmap().isNull() &&
    00143         attributes.pixmapMode() != BackgroundAttributes::BackgroundPixmapModeNone ) {
    00144         QPointF ol = rect.topLeft();
    00145         if( BackgroundAttributes::BackgroundPixmapModeCentered == attributes.pixmapMode() )
    00146         {
    00147             ol.setX( rect.center().x() - attributes.pixmap().width() / 2 );
    00148             ol.setY( rect.center().y() - attributes.pixmap().height()/ 2 );
    00149             painter.drawPixmap( ol, attributes.pixmap() );
    00150         } else {
    00151             QMatrix m;
    00152             double zW = (double)rect.width()  / (double)attributes.pixmap().width();
    00153             double zH = (double)rect.height() / (double)attributes.pixmap().height();
    00154             switch( attributes.pixmapMode() ) {
    00155             case BackgroundAttributes::BackgroundPixmapModeScaled:
    00156             {
    00157                 double z;
    00158                 z = qMin( zW, zH );
    00159                 m.scale( z, z );
    00160             }
    00161             break;
    00162             case BackgroundAttributes::BackgroundPixmapModeStretched:
    00163                 m.scale( zW, zH );
    00164                 break;
    00165             default:
    00166                 ; // Cannot happen, previously checked
    00167             }
    00168             QPixmap pm = attributes.pixmap().transformed( m );
    00169             ol.setX( rect.center().x() - pm.width() / 2 );
    00170             ol.setY( rect.center().y() - pm.height()/ 2 );
    00171             painter.drawPixmap( ol, pm );
    00172         }
    00173     }
    00174 }

void TernaryAxis::paintCtx | ( | PaintContext * |  | ) | `[virtual]`

Default impl: Paint the complete item using its layouted position and size.

Reimplemented from KDChart::AbstractLayoutItem.

Definition at line 78 of file KDChartTernaryAxis.cpp.

References KDChart::PaintContext::coordinatePlane(), KDChart::AbstractAxis::labels(), KDChart::PaintContext::painter(), PrerenderedLabel::pixmap(), PrerenderedElement::position(), KDChart::PaintContext::rectangle(), PrerenderedLabel::referencePointLocation(), and KDChart::TernaryCoordinatePlane::translate().

    00079 {
    00080     QPainter* p = paintContext->painter();
    00081     TernaryCoordinatePlane* plane =
    00082         (TernaryCoordinatePlane*) paintContext->coordinatePlane();
    00083     // QObject* refArea = plane->parent();
    00084     QRectF drawArea = paintContext->rectangle();
    00085     QRectF titleArea;
    00086
    00087     // paint the axis label (across the triangle, that one):
    00088     QList<PrerenderedLabel*> labels;
    00089     labels << m_label << m_fifty;
    00090     Q_FOREACH( PrerenderedLabel* label, labels ) {
    00091         const QPixmap& pixmap = label->pixmap();
    00092         QPointF point = plane->translate( label->position() )
    00093                         - label->referencePointLocation();
    00094         p->drawPixmap( point, pixmap );
    00095     }
    00096 }

void AbstractAreaBase::paintFrame | ( | QPainter & | painter,
|  | const QRect & | rectangle |
| ) |  |  | `[virtual, inherited]`

Definition at line 204 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::paintFrameAttributes().

Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().

    00205 {
    00206     Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintFrame()",
    00207                 "Private class was not initialized!" );
    00208     paintFrameAttributes( painter, rect, d->frameAttributes );
    00209 }

void AbstractAreaBase::paintFrameAttributes | ( | QPainter & | painter,
|  | const QRect & | rectangle,
|  | const KDChart::FrameAttributes & | attributes |
| ) |  |  | `[static, inherited]`

Definition at line 177 of file KDChartAbstractAreaBase.cpp.

References KDChart::FrameAttributes::isVisible(), and KDChart::FrameAttributes::pen().

Referenced by KDChart::AbstractAreaBase::paintFrame().

    00179 {
    00180
    00181     if( !attributes.isVisible() ) return;
    00182
    00183     // Note: We set the brush to NoBrush explicitely here.
    00184     //       Otherwise we might get a filled rectangle, so any
    00185     //       previously drawn background would be overwritten by that area.
    00186
    00187     const QPen   oldPen(   painter.pen() );
    00188     const QBrush oldBrush( painter.brush() );
    00189     painter.setPen(   attributes.pen() );
    00190     painter.setBrush( Qt::NoBrush );
    00191     painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) );
    00192     painter.setBrush( oldBrush );
    00193     painter.setPen(   oldPen );
    00194 }

void AbstractArea::paintIntoRect | ( | QPainter & | painter,
|  | const QRect & | rect |
| ) |  |  | `[virtual, inherited]`

Draws the background and frame, then calls paint().

In most cases there is no need to overwrite this method in a derived class, but you would overwrite AbstractLayoutItem::paint() instead.

Definition at line 111 of file KDChartAbstractArea.cpp.

References KDChart::AbstractArea::paintAll().

    00112 {
    00113     const QRect oldGeometry( geometry() );
    00114     if( oldGeometry != rect )
    00115         setGeometry( rect );
    00116     painter.translate( rect.left(), rect.top() );
    00117     paintAll( painter );
    00118     painter.translate( -rect.left(), -rect.top() );
    00119     if( oldGeometry != rect )
    00120         setGeometry( oldGeometry );
    00121 }

QLayout* KDChart::AbstractLayoutItem::parentLayout | ( |  | ) | `[inherited]`

Definition at line 76 of file KDChartLayoutItems.h.

    00077         {
    00078             return mParentLayout;
    00079         }

const Position TernaryAxis::position | ( |  | ) | const`[virtual]`

Definition at line 135 of file KDChartTernaryAxis.cpp.

Referenced by requiredMargins(), and setPosition().

    00136 {
    00137     return m_position;
    00138 }

void KDChart::AbstractArea::positionChanged | ( | AbstractArea * |  | ) | `[signal, inherited]`

Referenced by KDChart::AbstractArea::positionHasChanged().

void AbstractArea::positionHasChanged | ( |  | ) | `[protected, virtual, inherited]`

Reimplemented from KDChart::AbstractAreaBase.

Definition at line 155 of file KDChartAbstractArea.cpp.

References KDChart::AbstractArea::positionChanged().

    00156 {
    00157     emit positionChanged( this );
    00158 }

void KDChart::AbstractLayoutItem::removeFromParentLayout | ( |  | ) | `[inherited]`

Definition at line 80 of file KDChartLayoutItems.h.

Referenced by KDChart::Chart::takeCoordinatePlane().

    00081         {
    00082             if( mParentLayout ){
    00083                 if( widget() )
    00084                     mParentLayout->removeWidget( widget() );
    00085                 else
    00086                     mParentLayout->removeItem( this );
    00087             }
    00088         }

QPair< QSizeF, QSizeF > TernaryAxis::requiredMargins | ( |  | ) | const

Definition at line 260 of file KDChartTernaryAxis.cpp.

References PrerenderedLabel::pixmap(), position(), KDChartEnums::PositionEast, KDChartEnums::PositionSouth, KDChartEnums::PositionWest, and PrerenderedLabel::referencePointLocation().

Referenced by KDChart::TernaryCoordinatePlane::layoutDiagrams().

    00261 {
    00262     QSizeF topleft( 0.0, 0.0 );
    00263     QSizeF bottomRight( 0.0, 0.0 );
    00264
    00265     switch( position().value() ) {
    00266     case KDChartEnums::PositionSouth:
    00267         // the label of the south axis is, in fact, up north.
    00268         topleft.setHeight( m_label->pixmap().height() );
    00269         bottomRight.setHeight( m_fifty->pixmap().height() );
    00270         break;
    00271     case KDChartEnums::PositionWest:
    00272         bottomRight.setWidth( m_label->pixmap().width()
    00273                               - m_label->referencePointLocation().x() );
    00274         bottomRight.setHeight( m_label->pixmap().height()
    00275                                - m_label->referencePointLocation().y() );
    00276         break;
    00277     case KDChartEnums::PositionEast:
    00278         topleft.setWidth( m_label->pixmap().width()
    00279                           - ( m_label->pixmap().width()
    00280                               - m_label->referencePointLocation().x() ) );
    00281         bottomRight.setHeight( m_label->pixmap().height()
    00282                                - ( m_label->pixmap().height()
    00283                                    - m_label->referencePointLocation().y() ) );
    00284         break;
    00285     default:
    00286         qDebug() << "TernaryAxis::requiredMargins: unknown location";
    00287     }
    00288 //     qDebug() << "TernaryAxis::requiredMargins:" << topleft << bottomRight;
    00289     return QPair<QSizeF, QSizeF>( topleft, bottomRight );
    00290 }

void TernaryAxis::resetTitleTextAttributes | ( |  | ) |

Definition at line 194 of file KDChartTernaryAxis.cpp.

Referenced by TernaryAxis().

    00195 {
    00196     TextAttributes a;
    00197     m_titleAttributes = a;
    00198     updatePrerenderedLabels();
    00199 }

int AbstractArea::rightOverlap | ( | bool | doNotRecalculate = `false` | ) | const`[virtual, inherited]`

This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().

The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the right edge of the area.

Note:
  The default implementation is not using any caching, it might make sense to implement a more sophisticated solution for derived classes that have complex work to do in sizeHint(). All we have here is a primitive flag to be set by the caller if it is sure that no sizeHint() needs to be called.

Definition at line 85 of file KDChartAbstractArea.cpp.

References d.

Referenced by KDChart::CartesianAxis::maximumSize().

    00086 {
    00087     // Re-calculate the sizes,
    00088     // so we also get the amountOf..Overlap members set newly:
    00089     if( ! doNotRecalculate )
    00090         sizeHint();
    00091     return d->amountOfRightOverlap;
    00092 }

void AbstractAreaBase::setBackgroundAttributes | ( | const BackgroundAttributes & | a | ) | `[inherited]`

Definition at line 111 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::positionHasChanged().

    00112 {
    00113     if( d->backgroundAttributes == a )
    00114         return;
    00115
    00116     d->backgroundAttributes = a;
    00117     positionHasChanged();
    00118 }

void AbstractAreaBase::setFrameAttributes | ( | const FrameAttributes & | a | ) | `[inherited]`

Definition at line 97 of file KDChartAbstractAreaBase.cpp.

References d, and KDChart::AbstractAreaBase::positionHasChanged().

Referenced by KDChart::Legend::clone().

    00098 {
    00099     if( d->frameAttributes == a )
    00100         return;
    00101
    00102     d->frameAttributes = a;
    00103     positionHasChanged();
    00104 }

void TernaryAxis::setGeometry | ( | const QRect & | rect | ) | `[virtual]`

Implements KDChart::AbstractAxis.

Definition at line 109 of file KDChartTernaryAxis.cpp.

    00110 {
    00111     m_geometry = rect;
    00112 }

void AbstractAxis::setLabels | ( | const QStringList & | list | ) | `[inherited]`

Use this to specify your own set of strings, to be used as axis labels.

Labels specified via setLabels take precedence: If a non-empty list is passed, KD Chart will use these strings as axis labels, instead of calculating them.

If you a smaller number of strings than the number of labels drawn at this axis, KD Chart will iterate over the list, repeating the strings, until all labels are drawn. As an example you could specify the seven days of the week as abscissa labels, which would be repeatedly used then.

By passing an empty QStringList you can reset the default behaviour.

See also:
  labels, setShortLabels

Definition at line 267 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::update().

    00268 {
    00269     if( d->hardLabels == list )
    00270         return;
    00271
    00272     d->hardLabels = list;
    00273     update();
    00274 }

void KDChart::AbstractLayoutItem::setParentLayout | ( | QLayout * | lay | ) | `[inherited]`

Definition at line 72 of file KDChartLayoutItems.h.

    00073         {
    00074             mParentLayout = lay;
    00075         }

void KDChart::AbstractLayoutItem::setParentWidget | ( | QWidget * | widget | ) | `[virtual, inherited]`

Inform the item about its widget: This enables the item, to trigger that widget's update, whenever the size of the item's contents has changed.

Thus, you need to call setParentWidget on every item, that has a non-fixed size.

Definition at line 64 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent.

Referenced by KDChart::HeaderFooter::setParent(), and KDChart::AbstractCartesianDiagram::takeAxis().

    00065 {
    00066     mParent = widget;
    00067 }

void TernaryAxis::setPosition | ( | Position | p | ) | `[virtual]`

Definition at line 140 of file KDChartTernaryAxis.cpp.

References position(), KDChartEnums::PositionEast, KDChartEnums::PositionSouth, KDChartEnums::PositionWest, PrerenderedLabel::setText(), and KDChart::Position::value().

Referenced by TernaryAxis().

    00141 {
    00142     if ( p == position() ) return;
    00143
    00144     if ( p != KDChartEnums::PositionWest
    00145          && p != KDChartEnums::PositionEast
    00146          && p != KDChartEnums::PositionSouth )
    00147     {
    00148         qDebug() << "TernaryAxis::setPosition: only south, east and west are supported "
    00149             "positions for ternary axes.";
    00150         return;
    00151     }
    00152
    00153     if ( m_title.isEmpty() )
    00154         switch( p.value() ) {
    00155         case KDChartEnums::PositionSouth:
    00156             m_label->setText( tr( "A" ) );
    00157             break;
    00158         case KDChartEnums::PositionWest:
    00159             m_label->setText( tr( "C" ) );
    00160             break;
    00161         case KDChartEnums::PositionEast:
    00162             m_label->setText( tr( "B" ) );
    00163             break;
    00164         default:
    00165             break;
    00166         }
    00167
    00168     m_position = p;
    00169     updatePrerenderedLabels(); // position has changed
    00170 }

void AbstractAxis::setShortLabels | ( | const QStringList & | list | ) | `[inherited]`

Use this to specify your own set of strings, to be used as axis labels, in case the normal labels are too long.

Note:
  Setting done via setShortLabels will be ignored, if you did not pass a non-empty string list via setLabels too!

By passing an empty QStringList you can reset the default behaviour.

See also:
  shortLabels, setLabels

Definition at line 297 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::update().

    00298 {
    00299     if( d->hardShortLabels == list )
    00300         return;
    00301
    00302     d->hardShortLabels = list;
    00303     update();
    00304 }

void AbstractAxis::setTextAttributes | ( | const TextAttributes & | a | ) | `[inherited]`

Use this to specify the text attributes to be used for axis labels.

By default, the reference area will be set at painting time. It will be the then-valid coordinate plane's parent widget, so normally, it will be the KDChart::Chart. Thus the labels of all of your axes in all of your diagrams within that Chart will be drawn in same font size, by default.

See also:
  textAttributes, setLabels

Definition at line 231 of file KDChartAbstractAxis.cpp.

References d, and KDChart::AbstractAxis::update().

    00232 {
    00233     if( d->textAttributes == a )
    00234         return;
    00235
    00236     d->textAttributes = a;
    00237     update();
    00238 }

void TernaryAxis::setTitleText | ( | const QString & | text | ) |

Definition at line 172 of file KDChartTernaryAxis.cpp.

References PrerenderedLabel::setText().

    00173 {
    00174     m_title = text; // do not remove
    00175     m_label->setText( text );
    00176 }

void TernaryAxis::setTitleTextAttributes | ( | const TextAttributes & | a | ) |

Definition at line 183 of file KDChartTernaryAxis.cpp.

    00184 {
    00185     m_titleAttributes = a;
    00186     updatePrerenderedLabels();
    00187 }

QStringList AbstractAxis::shortLabels | ( |  | ) | const`[inherited]`

Returns a list of strings, that are used as axis labels, as set via setShortLabels.

Note:
  Setting done via setShortLabels will be ignored, if you did not pass a non-empty string list via setLabels too!

See also:
  setShortLabels

Definition at line 314 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::compare(), and KDChart::CartesianAxis::paintCtx().

    00315 {
    00316     return d->hardShortLabels;
    00317 }

QSize TernaryAxis::sizeHint | ( |  | ) | const`[virtual]`

Definition at line 125 of file KDChartTernaryAxis.cpp.

    00126 {
    00127     return QSize( 150, 100 );
    00128 }

void KDChart::AbstractLayoutItem::sizeHintChanged | ( |  | ) | const`[virtual, inherited]`

Report changed size hint: ask the parent widget to recalculate the layout.

Definition at line 86 of file KDChartLayoutItems.cpp.

References KDChart::AbstractLayoutItem::mParent.

Referenced by KDChart::TextLayoutItem::sizeHint().

    00087 {
    00088     // This is exactly like what QWidget::updateGeometry does.
    00089 //  qDebug("KDChart::AbstractLayoutItem::sizeHintChanged() called");
    00090     if( mParent ) {
    00091         if ( mParent->layout() )
    00092             mParent->layout()->invalidate();
    00093         else
    00094             QApplication::postEvent( mParent, new QEvent( QEvent::LayoutRequest ) );
    00095     }
    00096 }

TextAttributes AbstractAxis::textAttributes | ( |  | ) | const`[inherited]`

Returns the text attributes to be used for axis labels.

See also:
  setTextAttributes

Definition at line 245 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::compare(), KDChart::CartesianAxis::maximumSize(), KDChart::CartesianAxis::paintCtx(), and KDChart::CartesianAxis::titleTextAttributes().

    00246 {
    00247     return d->textAttributes;
    00248 }

QString TernaryAxis::titleText | ( |  | ) | const

Definition at line 178 of file KDChartTernaryAxis.cpp.

References PrerenderedLabel::text().

    00179 {
    00180     return m_label->text();
    00181 }

TextAttributes TernaryAxis::titleTextAttributes | ( |  | ) | const

Definition at line 189 of file KDChartTernaryAxis.cpp.

    00190 {
    00191     return m_titleAttributes;
    00192 }

int AbstractArea::topOverlap | ( | bool | doNotRecalculate = `false` | ) | const`[virtual, inherited]`

This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().

The method triggers AbstractArea::sizeHint() to find out the amount of overlap at the top edge of the area.

Note:
  The default implementation is not using any caching, it might make sense to implement a more sophisticated solution for derived classes that have complex work to do in sizeHint(). All we have here is a primitive flag to be set by the caller if it is sure that no sizeHint() needs to be called.

Definition at line 93 of file KDChartAbstractArea.cpp.

References d.

Referenced by KDChart::CartesianAxis::maximumSize().

    00094 {
    00095     // Re-calculate the sizes,
    00096     // so we also get the amountOf..Overlap members set newly:
    00097     if( ! doNotRecalculate )
    00098         sizeHint();
    00099     return d->amountOfTopOverlap;
    00100 }

void KDChart::AbstractAxis::update | ( |  | ) | `[slot, inherited]`

Definition at line 341 of file KDChartAbstractAxis.cpp.

References d.

Referenced by KDChart::AbstractAxis::connectSignals(), KDChart::AbstractAxis::setLabels(), KDChart::AbstractAxis::setShortLabels(), and KDChart::AbstractAxis::setTextAttributes().

    00342 {
    00343     if( d->diagram() )
    00344         d->diagram()->update();
    00345 }

## Member Data Documentation

QWidget* KDChart::AbstractLayoutItem::mParent`[protected, inherited]`

Definition at line 90 of file KDChartLayoutItems.h.

Referenced by KDChart::AbstractLayoutItem::setParentWidget(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::setTextAttributes(), and KDChart::AbstractLayoutItem::sizeHintChanged().

QLayout* KDChart::AbstractLayoutItem::mParentLayout`[protected, inherited]`

Definition at line 91 of file KDChartLayoutItems.h.

Referenced by KDChart::AutoSpacerLayoutItem::paint().

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

- KDChartTernaryAxis.h
- KDChartTernaryAxis.cpp