KDChart::CartesianAxis Class Reference

#include <KDChartCartesianAxis.h>

Inheritance diagram for KDChart::CartesianAxis:

Inheritance graph
[legend]
Collaboration diagram for KDChart::CartesianAxis:

Collaboration graph
[legend]
List of all members.

Detailed Description

The class for cartesian axes.

For being useful, axes need to be assigned to a diagram, see AbstractCartesianDiagram::addAxis and AbstractCartesianDiagram::takeAxis.

See also:
PolarAxis, AbstractCartesianDiagram

Definition at line 48 of file KDChartCartesianAxis.h.

Public Types

enum  Position {
  Bottom,
  Top,
  Right,
  Left
}

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().
 CartesianAxis (AbstractCartesianDiagram *diagram=0)
 C'tor of the class for cartesian axes.
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.
bool compare (const CartesianAxis *other) const
 Returns true if both axes have the same settings.
virtual void connectSignals ()
 Wireing the signal/slot connections.
const AbstractCoordinatePlanecoordinatePlane () 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 AbstractDiagramdiagram () const
virtual Qt::Orientations expandingDirections () const
 pure virtual in QLayoutItem
FrameAttributes frameAttributes () const
virtual QRect geometry () const
 pure virtual in QLayoutItem
void getFrameLeadings (int &left, int &top, int &right, int &bottom) const
bool hasDefaultTitleTextAttributes () const
virtual bool isAbscissa () const
virtual bool isEmpty () const
 pure virtual in QLayoutItem
virtual bool isOrdinate () const
QStringList labels () const
 Returns a list of strings, that are used as axis labels, as set via setLabels.
virtual void layoutPlanes ()
virtual int leftOverlap (bool doNotRecalculate=false) const
 This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
virtual QSize maximumSize () const
 pure virtual in QLayoutItem
virtual QSize minimumSize () const
 pure virtual in QLayoutItem
bool observedBy (AbstractDiagram *diagram) const
virtual void paint (QPainter *)
 reimpl
virtual void paintAll (QPainter &painter)
 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 *)
 reimpl
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 ()
void resetTitleTextAttributes ()
 Reset the title text attributes to the built-in default:.
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 &r)
 pure virtual in QLayoutItem
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
 pure virtual in QLayoutItem
virtual void sizeHintChanged () const
 Report changed size hint: ask the parent widget to recalculate the layout.
TextAttributes textAttributes () const
 Returns the text attributes to be used for axis labels.
int tickLength (bool subUnitTicks=false) const
QString titleText () const
TextAttributes titleTextAttributes () const
 Returns the text attributes that will be used for displaying the title text.
virtual int topOverlap (bool doNotRecalculate=false) const
 This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint().
 ~CartesianAxis ()

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

QWidgetmParent
QLayout * mParentLayout


Member Enumeration Documentation

enum KDChart::CartesianAxis::Position

Enumerator:
Bottom 
Top 
Right 
Left 

Definition at line 56 of file KDChartCartesianAxis.h.

00056                       {
00057             Bottom,
00058             Top,
00059             Right,
00060             Left
00061         };


Constructor & Destructor Documentation

CartesianAxis::CartesianAxis ( AbstractCartesianDiagram diagram = 0  )  [explicit]

C'tor of the class for cartesian axes.

Note:
If using a zero parent for the constructor, you need to call your diagram's addAxis function to add your axis to the diagram. Otherwise, there is no need to call addAxis, since the constructor does that automatically for you, if you pass a diagram as parameter.
See also:
AbstractCartesianDiagram::addAxis

Definition at line 52 of file KDChartCartesianAxis.cpp.

00053     : AbstractAxis ( new Private( diagram, this ), diagram )
00054 {
00055     init();
00056 }

CartesianAxis::~CartesianAxis (  ) 

Definition at line 58 of file KDChartCartesianAxis.cpp.

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

00059 {
00060     // when we remove the first axis it will unregister itself and
00061     // propagate the next one to the primary, thus the while loop
00062     while ( d->mDiagram ) {
00063         AbstractCartesianDiagram *cd = qobject_cast<AbstractCartesianDiagram*>( d->mDiagram );
00064         cd->takeAxis( this );
00065     }
00066     Q_FOREACH( AbstractDiagram *diagram, d->secondaryDiagrams ) {
00067         AbstractCartesianDiagram *cd = qobject_cast<AbstractCartesianDiagram*>( diagram );
00068         cd->takeAxis( this );
00069     }
00070 }


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(), paint(), KDChart::AbstractArea::paintAll(), and 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 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 }

bool CartesianAxis::compare ( const CartesianAxis other  )  const

Returns true if both axes have the same settings.

Definition at line 78 of file KDChartCartesianAxis.cpp.

References position(), titleText(), and titleTextAttributes().

00079 {
00080     if( other == this ) return true;
00081     if( ! other ){
00082         //qDebug() << "CartesianAxis::compare() cannot compare to Null pointer";
00083         return false;
00084     }
00085     /*
00086     qDebug() << (position()            == other->position());
00087     qDebug() << (titleText()           == other->titleText());
00088     qDebug() << (titleTextAttributes() == other->titleTextAttributes());
00089     */
00090     return  ( static_cast<const AbstractAxis*>(this)->compare( other ) ) &&
00091             ( position()            == other->position() ) &&
00092             ( titleText()           == other->titleText() ) &&
00093             ( titleTextAttributes() == other->titleTextAttributes() );
00094 }

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 maximumSize(), and 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(), paintCtx(), KDChart::TernaryAxis::TernaryAxis(), and ~CartesianAxis().

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

Qt::Orientations CartesianAxis::expandingDirections (  )  const [virtual]

pure virtual in QLayoutItem

Definition at line 991 of file KDChartCartesianAxis.cpp.

References Bottom, Left, position(), Right, and Top.

00992 {
00993     Qt::Orientations ret;
00994     switch ( position() )
00995     {
00996     case Bottom:
00997     case Top:
00998         ret = Qt::Horizontal;
00999         break;
01000     case Left:
01001     case Right:
01002         ret = Qt::Vertical;
01003         break;
01004     default:
01005         Q_ASSERT( false ); // all positions need to be handeld
01006         break;
01007     };
01008     return ret;
01009 }

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 CartesianAxis::geometry (  )  const [virtual]

pure virtual in QLayoutItem

Implements KDChart::AbstractAxis.

Definition at line 1234 of file KDChartCartesianAxis.cpp.

References d.

Referenced by paintCtx().

01235 {
01236     return d->geometry;
01237 }

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 CartesianAxis::hasDefaultTitleTextAttributes (  )  const

Definition at line 133 of file KDChartCartesianAxis.cpp.

References d.

Referenced by titleTextAttributes().

00134 {
00135     return d->useDefaultTextAttributes;
00136 }

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 CartesianAxis::isAbscissa (  )  const [virtual]

Definition at line 164 of file KDChartCartesianAxis.cpp.

References Bottom, position(), and Top.

Referenced by paintCtx(), and tickLength().

00165 {
00166     return position() == Bottom || position() == Top;
00167 }

bool CartesianAxis::isEmpty (  )  const [virtual]

pure virtual in QLayoutItem

Definition at line 986 of file KDChartCartesianAxis.cpp.

Referenced by paintCtx().

00987 {
00988     return false; // if the axis exists, it has some (perhaps default) content
00989 }

bool CartesianAxis::isOrdinate (  )  const [virtual]

Definition at line 169 of file KDChartCartesianAxis.cpp.

References Left, position(), and Right.

Referenced by paintCtx().

00170 {
00171     return position() == Left || position() == Right;
00172 }

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(), maximumSize(), KDChart::TernaryAxis::paintCtx(), and paintCtx().

00282 {
00283     return d->hardLabels;
00284 }

void CartesianAxis::layoutPlanes (  )  [virtual]

Definition at line 150 of file KDChartCartesianAxis.cpp.

References d, and KDChart::AbstractCoordinatePlane::layoutPlanes().

Referenced by resetTitleTextAttributes(), setPosition(), setTitleText(), and setTitleTextAttributes().

00151 {
00152     //qDebug() << "CartesianAxis::layoutPlanes()";
00153     if( ! d->diagram() || ! d->diagram()->coordinatePlane() ) {
00154         //qDebug() << "CartesianAxis::layoutPlanes(): Sorry, found no plane.";
00155         return;
00156     }
00157     AbstractCoordinatePlane* plane = d->diagram()->coordinatePlane();
00158     if( plane ){
00159         plane->layoutPlanes();
00160         //qDebug() << "CartesianAxis::layoutPlanes() OK";
00161     }
00162 }

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 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 CartesianAxis::maximumSize (  )  const [virtual]

pure virtual in QLayoutItem

Definition at line 1038 of file KDChartCartesianAxis.cpp.

References Bottom, KDChart::AbstractArea::bottomOverlap(), calculateOverlap(), KDChart::AbstractAxis::customizedLabel(), d, KDChart::AbstractCoordinatePlane::gridDimensionsList(), KDChart::TextAttributes::isVisible(), KDChart::AbstractAxis::labels(), Left, KDChart::AbstractArea::leftOverlap(), KDChartEnums::MeasureOrientationMinimum, KDChart::GlobalMeasureScaling::paintDevice(), KDChart::AbstractCoordinatePlane::parent(), position(), KDChart::TextLayoutItem::realFont(), referenceDiagramIsBarDiagram(), Right, KDChart::AbstractArea::rightOverlap(), KDChart::TextLayoutItem::setText(), KDChart::TextLayoutItem::sizeHint(), KDChart::AbstractAxis::textAttributes(), tickLength(), titleText(), Top, and KDChart::AbstractArea::topOverlap().

Referenced by minimumSize(), and sizeHint().

01039 {
01040     QSize result;
01041     if ( !d->diagram() )
01042         return result;
01043 
01044     const TextAttributes labelTA = textAttributes();
01045     const bool drawLabels = labelTA.isVisible();
01046 
01047     const TextAttributes titleTA( d->titleTextAttributesWithAdjustedRotation() );
01048     const bool drawTitle = titleTA.isVisible() && ! titleText().isEmpty();
01049 
01050     AbstractCoordinatePlane* plane = d->diagram()->coordinatePlane();
01051     //qDebug() << this<<"::maximumSize() uses plane geometry" << plane->geometry();
01052     QObject* refArea = plane->parent();
01053     TextLayoutItem labelItem( QString::null, labelTA, refArea,
01054                               KDChartEnums::MeasureOrientationMinimum, Qt::AlignLeft );
01055     TextLayoutItem titleItem( titleText(), titleTA, refArea,
01056                               KDChartEnums::MeasureOrientationMinimum, Qt::AlignHCenter | Qt::AlignVCenter );
01057     const qreal labelGap =
01058         drawLabels
01059         ? (QFontMetricsF( labelItem.realFont(), GlobalMeasureScaling::paintDevice() ).height() / 3.0)
01060         : 0.0;
01061     const qreal titleGap =
01062         drawTitle
01063         ? (QFontMetricsF( titleItem.realFont(), GlobalMeasureScaling::paintDevice() ).height() / 3.0)
01064         : 0.0;
01065 
01066     switch ( position() )
01067     {
01068     case Bottom:
01069     case Top: {
01070         const bool isBarDiagram = referenceDiagramIsBarDiagram(d->diagram());
01071         int leftOverlap = 0;
01072         int rightOverlap = 0;
01073 
01074         qreal w = 10.0;
01075         qreal h = 0.0;
01076         if( drawLabels ){
01077             // if there're no label strings, we take the biggest needed number as height
01078             if ( labels().count() ){
01079                 // find the longest label text:
01080                 const int first=0;
01081                 const int last=labels().count()-1;
01082                 const QStringList labelsList( labels() );
01083                 for ( int i = first; i <= last; ++i )
01084                 {
01085                     labelItem.setText( customizedLabel(labelsList[ i ]) );
01086                     const QSize siz = labelItem.sizeHint();
01087                     h = qMax( h, static_cast<qreal>(siz.height()) );
01088                     calculateOverlap( i, first, last, siz.width(), isBarDiagram,
01089                                       leftOverlap, rightOverlap );
01090 
01091                 }
01092             }else{
01093                 QStringList headerLabels = d->diagram()->itemRowLabels();
01094                 const int headerLabelsCount = headerLabels.count();
01095                 if( headerLabelsCount ){
01096                     const bool useFastCalcAlgorithm 
01097                         = (strcmp( metaObject()->className(), "KDChart::CartesianAxis" ) == 0);
01098                     const int first=0;
01099                     const int last=headerLabelsCount-1;
01100                     for ( int i = first;
01101                           i <= last;
01102                           i = (useFastCalcAlgorithm && i < last) ? last : (i+1) )
01103                     {
01104                         labelItem.setText( customizedLabel(headerLabels[ i ]) );
01105                         const QSize siz = labelItem.sizeHint();
01106                         h = qMax( h, static_cast<qreal>(siz.height()) );
01107                         calculateOverlap( i, first, last, siz.width(), isBarDiagram,
01108                                           leftOverlap, rightOverlap );
01109                     }
01110                 }else{
01111                     labelItem.setText(
01112                             customizedLabel(
01113                                     QString::number( plane->gridDimensionsList().first().end, 'f', 0 )));
01114                     const QSize siz = labelItem.sizeHint();
01115                     h = siz.height();
01116                     calculateOverlap( 0, 0, 0, siz.width(), isBarDiagram,
01117                                       leftOverlap, rightOverlap );
01118                 }
01119             }
01120             // we leave a little gap between axis labels and bottom (or top, resp.) side of axis
01121             h += labelGap;
01122         }
01123         // space for a possible title:
01124         if ( drawTitle ) {
01125             // we add the title height and leave a little gap between axis labels and axis title
01126             h += titleItem.sizeHint().height() + titleGap;
01127             w = titleItem.sizeHint().width() + 2.0;
01128         }
01129         // space for the ticks
01130         h += qAbs( tickLength() ) * 3.0;
01131         result = QSize ( static_cast<int>( w ), static_cast<int>( h ) );
01132 
01133 
01134         // If necessary adjust the widths
01135         // of the left (or right, resp.) side neighboring columns:
01136         d->amountOfLeftOverlap = leftOverlap;
01137         d->amountOfRightOverlap = rightOverlap;
01138         /* Unused code for a push-model:
01139         if( leftOverlap || rightOverlap ){
01140             QTimer::singleShot(200, const_cast<CartesianAxis*>(this),
01141                                SLOT(adjustLeftRightGridColumnWidths()));
01142         }
01143         */
01144     }
01145         break;
01146     case Left:
01147     case Right: {
01148         int topOverlap = 0;
01149         int bottomOverlap = 0;
01150 
01151         qreal w = 0.0;
01152         qreal h = 10.0;
01153         if( drawLabels ){
01154             // if there're no label strings, we take the biggest needed number as width
01155             if ( labels().count() == 0 )
01156             {
01157                 labelItem.setText(
01158                         customizedLabel(
01159                                 QString::number( plane->gridDimensionsList().last().end, 'f', 0 )));
01160                 const QSize siz = labelItem.sizeHint();
01161                 w = siz.width();
01162                 calculateOverlap( 0, 0, 0, siz.height(), false,// bar diagram flag is ignored for Ordinates
01163                                   topOverlap, bottomOverlap );
01164             }else{
01165                 // find the longest label text:
01166                 const int first=0;
01167                 const int last=labels().count()-1;
01168                 const QStringList labelsList( labels() );
01169                 for ( int i = first; i <= last; ++i )
01170                 {
01171                     labelItem.setText( customizedLabel(labelsList[ i ]) );
01172                     const QSize siz = labelItem.sizeHint();
01173                     qreal lw = siz.width();
01174                     w = qMax( w, lw );
01175                     calculateOverlap( 0, 0, 0, siz.height(), false,// bar diagram flag is ignored for Ordinates
01176                                       topOverlap, bottomOverlap );
01177                 }
01178             }
01179             // we leave a little gap between axis labels and left (or right, resp.) side of axis
01180             w += labelGap;
01181         }
01182         // space for a possible title:
01183         if ( drawTitle ) {
01184             // we add the title height and leave a little gap between axis labels and axis title
01185             w += titleItem.sizeHint().width() + titleGap;
01186             h = titleItem.sizeHint().height() + 2.0;
01187             //qDebug() << "left/right axis title item size-hint:" << titleItem.sizeHint();
01188         }
01189         // space for the ticks
01190         w += qAbs( tickLength() ) * 3.0;
01191 
01192         result = QSize ( static_cast<int>( w ), static_cast<int>( h ) );
01193         //qDebug() << "left/right axis width:" << result << "   w:" << w;
01194 
01195 
01196         // If necessary adjust the heights
01197         // of the top (or bottom, resp.) side neighboring rows:
01198         d->amountOfTopOverlap = topOverlap;
01199         d->amountOfBottomOverlap = bottomOverlap;
01200         /* Unused code for a push-model:
01201         if( topOverlap || bottomOverlap ){
01202             QTimer::singleShot(200, const_cast<CartesianAxis*>(this),
01203                                SLOT(adjustTopBottomGridRowHeights()));
01204         }
01205         */
01206     }
01207         break;
01208     default:
01209         Q_ASSERT( false ); // all positions need to be handled
01210         break;
01211     };
01212 //qDebug() << "*******************" << result;
01213     //result=QSize(0,0);
01214     return result;
01215 }

QSize CartesianAxis::minimumSize (  )  const [virtual]

pure virtual in QLayoutItem

Definition at line 1217 of file KDChartCartesianAxis.cpp.

References maximumSize().

01218 {
01219     return maximumSize();
01220 }

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 CartesianAxis::paint ( QPainter *   )  [virtual]

reimpl

Implements KDChart::AbstractLayoutItem.

Definition at line 193 of file KDChartCartesianAxis.cpp.

References KDChart::AbstractArea::areaGeometry(), d, paintCtx(), KDChart::PaintContext::setCoordinatePlane(), KDChart::PaintContext::setPainter(), and KDChart::PaintContext::setRectangle().

00194 {
00195     if( ! d->diagram() || ! d->diagram()->coordinatePlane() ) return;
00196     PaintContext ctx;
00197     ctx.setPainter ( painter );
00198     ctx.setCoordinatePlane( d->diagram()->coordinatePlane() );
00199     const QRect rect( areaGeometry() );
00200 
00201     //qDebug() << "CartesianAxis::paint( QPainter* painter )  " << " areaGeometry()():" << rect << " sizeHint():" << sizeHint();
00202 
00203     ctx.setRectangle(
00204         QRectF (
00205             //QPointF(0, 0),
00206             QPointF(rect.left(), rect.top()),
00207             QSizeF(rect.width(), rect.height() ) ) );
00208     // enabling clipping so that we're not drawing outside
00209     QRegion clipRegion( rect.adjusted( -1, -1, 1, 1 ) );
00210     painter->save();
00211     painter->setClipRegion( clipRegion );
00212     paintCtx( &ctx );
00213     painter->restore();
00214     //qDebug() << "KDChart::CartesianAxis::paint() done.";
00215 }

void AbstractArea::paintAll ( QPainter &  painter  )  [virtual, inherited]

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

Reimplemented from KDChart::AbstractLayoutItem.

Reimplemented in KDChart::TernaryAxis.

Definition at line 123 of file KDChartAbstractArea.cpp.

References KDChart::AbstractArea::areaGeometry(), d, KDChart::AbstractAreaBase::innerRect(), KDChart::AbstractLayoutItem::paint(), KDChart::AbstractAreaBase::paintBackground(), and KDChart::AbstractAreaBase::paintFrame().

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

00124 {
00125     // Paint the background and frame
00126     const QRect overlappingArea( geometry().adjusted(
00127             -d->amountOfLeftOverlap,
00128             -d->amountOfTopOverlap,
00129             d->amountOfRightOverlap,
00130             d->amountOfBottomOverlap ) );
00131     paintBackground( painter, overlappingArea );
00132     paintFrame(      painter, overlappingArea );
00133 
00134     // temporarily adjust the widget size, to be sure all content gets calculated
00135     // to fit into the inner rectangle
00136     const QRect oldGeometry( areaGeometry()  );
00137     QRect inner( innerRect() );
00138     inner.moveTo(
00139         oldGeometry.left() + inner.left(),
00140         oldGeometry.top()  + inner.top() );
00141     const bool needAdjustGeometry = oldGeometry != inner;
00142     if( needAdjustGeometry )
00143         setGeometry( inner );
00144     paint( &painter );
00145     if( needAdjustGeometry )
00146         setGeometry( oldGeometry );
00147     //qDebug() << "AbstractAreaWidget::paintAll() done.";
00148 }

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 CartesianAxis::paintCtx ( PaintContext  )  [virtual]

reimpl

Reimplemented from KDChart::AbstractLayoutItem.

Definition at line 374 of file KDChartCartesianAxis.cpp.

References KDChart::AbstractArea::areaGeometry(), Bottom, calculateNextLabel(), KDChart::PaintContext::coordinatePlane(), KDChart::AbstractAxis::customizedLabel(), d, KDChart::AbstractAxis::diagram(), KDChart::TextLayoutItem::geometry(), geometry(), KDChart::TextLayoutItem::intersects(), isAbscissa(), isEmpty(), isOrdinate(), KDChart::TextAttributes::isVisible(), KDChart::AbstractAxis::labels(), Left, KDChart::AbstractCoordinatePlane::Logarithmic, KDChartEnums::MeasureOrientationMinimum, KDChart::TextLayoutItem::paint(), KDChart::GlobalMeasureScaling::paintDevice(), KDChart::PaintContext::painter(), KDChart::TextAttributes::pen(), position(), KDChart::TextLayoutItem::realFont(), referenceDiagramIsBarDiagram(), Right, KDChart::TextLayoutItem::setGeometry(), KDChart::TextLayoutItem::setText(), KDChart::AbstractAxis::shortLabels(), KDChart::TextLayoutItem::sizeHint(), KDChart::TextLayoutItem::text(), KDChart::AbstractAxis::textAttributes(), tickLength(), titleText(), Top, KDChart::AbstractDiagram::unitPrefix(), and KDChart::AbstractDiagram::unitSuffix().

Referenced by paint().

00375 {
00376 
00377     Q_ASSERT_X ( d->diagram(), "CartesianAxis::paint",
00378                  "Function call not allowed: The axis is not assigned to any diagram." );
00379 
00380     CartesianCoordinatePlane* plane = dynamic_cast<CartesianCoordinatePlane*>(context->coordinatePlane());
00381     Q_ASSERT_X ( plane, "CartesianAxis::paint",
00382                  "Bad function call: PaintContext::coodinatePlane() NOT a cartesian plane." );
00383 
00384     // note: Not having any data model assigned is no bug
00385     //       but we can not draw an axis then either.
00386     if( ! d->diagram()->model() )
00387         return;
00388 
00389 
00390     /*
00391      * let us paint the labels at a
00392      * smaller resolution
00393      * Same mini pixel value as for
00394      * Cartesian Grid
00395      */
00396     //const qreal MinimumPixelsBetweenRulers = 1.0;
00397     DataDimensionsList dimensions( plane->gridDimensionsList() );
00398     //qDebug("CartesianAxis::paintCtx() gets DataDimensionsList.first():   start: %f   end: %f   stepWidth: %f", dimensions.first().start, dimensions.first().end, dimensions.first().stepWidth);
00399 
00400     // test for programming errors: critical
00401     Q_ASSERT_X ( dimensions.count() == 2, "CartesianAxis::paint",
00402                  "Error: plane->gridDimensionsList() did not return exactly two dimensions." );
00403     DataDimension dimX =
00404             AbstractGrid::adjustedLowerUpperRange( dimensions.first(), true, true );
00405     const DataDimension dimY =
00406             AbstractGrid::adjustedLowerUpperRange( dimensions.last(), true, true );
00407     const DataDimension& dim = (isAbscissa() ? dimX : dimY);
00408 
00409     /*
00410     if(isAbscissa())
00411         qDebug() << "         " << "Abscissa:" << dimX.start <<".."<<dimX.end <<"  step"<<dimX.stepWidth;
00412     else
00413         qDebug() << "         " << "Ordinate:" << dimY.start <<".."<<dimY.end <<"  step"<<dimY.stepWidth;
00414     */
00415 
00416 
00417     /*
00418      * let us paint the labels at a
00419      * smaller resolution
00420      * Same mini pixel value as for
00421      * Cartesian Grid
00422      */
00423     const qreal MinimumPixelsBetweenRulers = qMin(  dimX.stepWidth,  dimY.stepWidth );//1.0;
00424 
00425     // preparations:
00426     // - calculate the range that will be displayed:
00427     const qreal absRange = qAbs( dim.distance() );
00428 
00429     qreal numberOfUnitRulers;
00430     if ( isAbscissa() ) {
00431         if( dimX.isCalculated )
00432             numberOfUnitRulers = absRange / qAbs( dimX.stepWidth ) + 1.0;
00433         else
00434             numberOfUnitRulers = d->diagram()->model()->rowCount() - 1.0;
00435     }else{
00436         numberOfUnitRulers = absRange / qAbs( dimY.stepWidth ) + 1.0;
00437 
00438     }
00439 
00440     //    qDebug() << "absRange" << absRange << "dimY.stepWidth:" << dimY.stepWidth << "numberOfUnitRulers:" << numberOfUnitRulers;
00441 
00442     qreal numberOfSubUnitRulers;
00443     if ( isAbscissa() ){
00444         if( dimX.isCalculated )
00445             numberOfSubUnitRulers = absRange / qAbs( dimX.subStepWidth ) + 1.0;
00446         else
00447             numberOfSubUnitRulers = dimX.subStepWidth>0 ? absRange / qAbs( dimX.subStepWidth ) + 1.0 : 0.0;
00448     }else{
00449         numberOfSubUnitRulers = absRange / qAbs( dimY.subStepWidth ) + 1.0;
00450     }
00451 
00452     // - calculate the absolute range in screen pixels:
00453     const QPointF p1 = plane->translate( QPointF(dimX.start, dimY.start) );
00454     const QPointF p2 = plane->translate( QPointF(dimX.end,   dimY.end) );
00455 
00456     double screenRange;
00457     if ( isAbscissa() )
00458     {
00459         screenRange = qAbs ( p1.x() - p2.x() );
00460     } else {
00461         screenRange = qAbs ( p1.y() - p2.y() );
00462     }
00463 
00464     const bool useItemCountLabels = isAbscissa() && ! dimX.isCalculated;
00465 
00466     const bool drawUnitRulers = screenRange / ( numberOfUnitRulers / dimX.stepWidth ) > MinimumPixelsBetweenRulers;
00467     const bool drawSubUnitRulers =
00468         (numberOfSubUnitRulers != 0.0) &&
00469         (screenRange / numberOfSubUnitRulers > MinimumPixelsBetweenRulers);
00470 
00471     const TextAttributes labelTA = textAttributes();
00472     const bool drawLabels = labelTA.isVisible();
00473 
00474     // - find the reference point at which to start drawing and the increment (line distance);
00475     QPointF rulerRef;
00476     const QRect areaGeoRect( areaGeometry() );
00477     const QRect geoRect( geometry() );
00478     QRectF rulerRect;
00479     double rulerWidth;
00480     double rulerHeight;
00481 
00482     QPainter* const ptr = context->painter();
00483 
00484     //for debugging: if( isAbscissa() )ptr->drawRect(areaGeoRect.adjusted(0,0,-1,-1));
00485     //qDebug() << "         " << (isAbscissa() ? "Abscissa":"Ordinate") << "axis painting with geometry" << areaGeoRect;
00486 
00487     // FIXME references are of course different for all locations:
00488     rulerWidth = areaGeoRect.width();
00489     rulerHeight =  areaGeoRect.height();
00490     switch( position() )
00491     {
00492     case Top:
00493         rulerRef.setX( areaGeoRect.topLeft().x() );
00494         rulerRef.setY( areaGeoRect.topLeft().y() + rulerHeight );
00495         break;
00496     case Bottom:
00497         rulerRef.setX( areaGeoRect.bottomLeft().x() );
00498         rulerRef.setY( areaGeoRect.bottomLeft().y() - rulerHeight );
00499         break;
00500     case Right:
00501         rulerRef.setX( areaGeoRect.bottomRight().x() - rulerWidth );
00502         rulerRef.setY( areaGeoRect.bottomRight().y() );
00503         break;
00504     case Left:
00505         rulerRef.setX( areaGeoRect.bottomLeft().x() + rulerWidth );
00506         rulerRef.setY( areaGeoRect.bottomLeft().y() );
00507         break;
00508     }
00509 
00510     // set up the lines to paint:
00511 
00512     // set up a map of integer positions,
00513 
00514     // - starting with the fourth
00515     // - the the halfs
00516     // - then the tens
00517     // this will override all halfs and fourth that hit a higher-order ruler
00518     // MAKE SURE TO START AT (0, 0)!
00519 
00520     // set up a reference point,  a step vector and a unit vector for the drawing:
00521 
00522     const qreal minValueY = dimY.start;
00523     const qreal maxValueY = dimY.end;
00524     const qreal minValueX = dimX.start;
00525     const qreal maxValueX = dimX.end;
00526     const bool isLogarithmicX = (dimX.calcMode == AbstractCoordinatePlane::Logarithmic );
00527     const bool isLogarithmicY = (dimY.calcMode == AbstractCoordinatePlane::Logarithmic );
00528 //#define AXES_PAINTING_DEBUG 1
00529 #ifdef AXES_PAINTING_DEBUG
00530     qDebug() << "CartesianAxis::paint: reference values:" << endl
00531              << "-- range x/y: " << dimX.distance() << "/" << dimY.distance() << endl
00532              << "-- absRange: " << absRange << endl
00533              << "-- numberOfUnitRulers: " << numberOfUnitRulers << endl
00534              << "-- screenRange: " << screenRange << endl
00535              << "-- drawUnitRulers: " << drawUnitRulers << endl
00536              << "-- drawLabels: " << drawLabels << endl
00537              << "-- ruler reference point:: " << rulerRef << endl
00538              << "-- minValueX: " << minValueX << "   maxValueX: " << maxValueX << endl
00539              << "-- minValueY: " << minValueY << "   maxValueY: " << maxValueY << endl
00540         ;
00541 #endif
00542 
00543     // solving issue #4075 in a quick way:
00544     ptr->setPen ( labelTA.pen() ); // perhaps we want to add a setter method later?
00545 
00546     //ptr->setPen ( Qt::black );
00547 
00548     const QObject* referenceArea = plane->parent();
00549 
00550     // that QVector contains all drawn x-ticks (so no subticks are drawn there also)
00551     QVector< int > drawnXTicks;
00552     // and that does the same for the y-ticks
00553     QVector< int > drawnYTicks;
00554 
00555     /*
00556      * Find out if it is a bar diagram
00557      * bar diagrams display their data per column
00558      * we need to handle the last label another way
00559      * 1 - Last label == QString null ( Header Labels )
00560      * 2 - Display labels and ticks in the middle of the column
00561      */
00562 
00563     const bool isBarDiagram = referenceDiagramIsBarDiagram(d->diagram());
00564 
00565     // this draws the unit rulers
00566     if ( drawUnitRulers ) {
00567         const QStringList labelsList(      labels() );
00568         const QStringList shortLabelsList( shortLabels() );
00569         const int hardLabelsCount  = labelsList.count();
00570         const int shortLabelsCount = shortLabelsList.count();
00571         bool useShortLabels = false;
00572 
00573 
00574         bool useConfiguredStepsLabels = false;
00575         QStringList headerLabels;
00576         if( useItemCountLabels ){
00577             //qDebug() << (isOrdinate() ? "is Ordinate" : "is Abscissa");
00578             headerLabels =
00579                 isOrdinate()
00580                 ? d->diagram()->datasetLabels()
00581                 : d->diagram()->itemRowLabels();
00582             // check if configured stepWidth
00583             useConfiguredStepsLabels = isAbscissa() &&
00584                     dimX.stepWidth &&
00585                     (( (headerLabels.count() - 1)/ dimX.stepWidth ) != numberOfUnitRulers);
00586             if( useConfiguredStepsLabels ) {
00587                 numberOfUnitRulers = ( headerLabels.count() - 1 )/ dimX.stepWidth;
00588                 // we need to register data values for the steps
00589                 // in case it is configured by the user
00590                 QStringList configuredStepsLabels;
00591                 double value = headerLabels.isEmpty() ? 0.0 : headerLabels.first().toDouble();
00592                 configuredStepsLabels << QString::number( value );
00593                 for (  int i = 0; i < numberOfUnitRulers; i++ ) {
00594                     //qDebug() << value;
00595                     value += dimX.stepWidth;
00596                     configuredStepsLabels.append( QString::number( value ) );
00597                 }
00598                 headerLabels = configuredStepsLabels;
00599             }
00600 
00601             if (  isBarDiagram )
00602                 headerLabels.append( QString::null );
00603         }
00604 
00605 
00606         const int headerLabelsCount = headerLabels.count();
00607         //qDebug() << "headerLabelsCount" << headerLabelsCount;
00608 
00609         TextLayoutItem* labelItem =
00610             drawLabels
00611             ? new TextLayoutItem( QString::number( minValueY ),
00612                                   labelTA,
00613                                   referenceArea,
00614                                   KDChartEnums::MeasureOrientationMinimum,
00615                                   Qt::AlignLeft )
00616             : 0;
00617         TextLayoutItem* labelItem2 =
00618             drawLabels
00619             ? new TextLayoutItem( QString::number( minValueY ),
00620                                   labelTA,
00621                                   referenceArea,
00622                                   KDChartEnums::MeasureOrientationMinimum,
00623                                   Qt::AlignLeft )
00624             : 0;
00625         const QFontMetricsF met(
00626             drawLabels
00627             ? labelItem->realFont()
00628             : QFontMetricsF( QApplication::font(), GlobalMeasureScaling::paintDevice() ) );
00629         const qreal halfFontHeight = met.height() * 0.5;
00630 
00631         if ( isAbscissa() ) {
00632 
00633             // If we have a labels list AND a short labels list, we first find out,
00634             // if there is enough space for the labels: if not, use the short labels.
00635             if( drawLabels && hardLabelsCount > 0 && shortLabelsCount > 0 ){
00636                 bool labelsAreOverlapping = false;
00637                 int iLabel = 0;
00638                 qreal i = minValueX;
00639                 while ( i < maxValueX && !labelsAreOverlapping )
00640                 {
00641                     if ( dimX.stepWidth != 1.0 && ! dim.isCalculated )
00642                     {
00643                         labelItem->setText(  customizedLabel(QString::number( i, 'f', 0 )) );
00644                         labelItem2->setText( customizedLabel(QString::number( i + dimX.stepWidth, 'f', 0 )) );
00645                     } else {
00646 
00647                         int index = iLabel;
00648                         labelItem->setText(  customizedLabel(labelsList[ index < hardLabelsCount ? index : 0 ]) );
00649                         labelItem2->setText( customizedLabel(labelsList[ index < hardLabelsCount - 1 ? index + 1 : 0]) );
00650                     }
00651                     QPointF firstPos( i, 0.0 );
00652                     firstPos = plane->translate( firstPos );
00653 
00654                     QPointF secondPos( i + dimX.stepWidth, 0.0 );
00655                     secondPos = plane->translate( secondPos );
00656 
00657                     labelsAreOverlapping = labelItem->intersects( *labelItem2, firstPos, secondPos );
00658                     if ( iLabel++ > hardLabelsCount - 1 )
00659                         iLabel = 0;
00660                     if ( isLogarithmicX )
00661                         i *= 10.0;
00662                     else
00663                         i += dimX.stepWidth;
00664 
00665                 }
00666 
00667                 useShortLabels = labelsAreOverlapping;
00668             }
00669 
00670             qreal labelDiff = dimX.stepWidth;
00671             //      qDebug() << "initial labelDiff " << labelDiff;
00672             if ( drawLabels )
00673             {
00674 
00675                 qreal i = minValueX;
00676                 int iLabel = 0;
00677                 const int precision = ( QString::number( labelDiff  ).section( QLatin1Char('.'), 1,  2 ) ).length();
00678 
00679                 while ( i + labelDiff < maxValueX )
00680                 {
00681 
00682                     //qDebug() << "drawLabels" << drawLabels << "  hardLabelsCount" << hardLabelsCount
00683                     //        << "  dimX.stepWidth" << dimX.stepWidth << "  dim.isCalculated" << dim.isCalculated;
00684                     if ( !drawLabels || hardLabelsCount < 1 || ( dimX.stepWidth != 1.0 && ! dim.isCalculated ) )
00685                     {
00686                         // Check intersects for the header label - we need to pass the full string
00687                         // here and not only the i value.
00688                         if( useConfiguredStepsLabels ){
00689                             labelItem->setText( customizedLabel(headerLabels[ iLabel   ]) );
00690                             labelItem2->setText(customizedLabel(headerLabels[ iLabel+1 ]) );
00691                         }else{
00692                             //qDebug() << "i + labelDiff " << i + labelDiff;
00693                             labelItem->setText( customizedLabel(headerLabelsCount > i && i >= 0 ? 
00694                                     headerLabels[static_cast<int>(i)] :
00695                                     QString::number( i, 'f', precision )) );
00696                             //           qDebug() << "1 - labelItem->text() " << labelItem->text();
00697                             //qDebug() << "labelDiff" << labelDiff
00698                             //        << "  index" << i+labelDiff << "  count" << headerLabelsCount;
00699                             labelItem2->setText( customizedLabel(headerLabelsCount > i + labelDiff && i + labelDiff >= 0 ? 
00700                                     headerLabels[static_cast<int>(i+labelDiff)] :
00701                                     QString::number( i + labelDiff, 'f', precision )) );
00702                             //qDebug() << "2 - labelItem->text() " << labelItem->text();
00703                             //qDebug() << "labelItem2->text() " << labelItem2->text();
00704                         }
00705                     } else {
00706                         const int idx = (iLabel < hardLabelsCount    ) ? iLabel     : 0;
00707                         const int idx2= (iLabel < hardLabelsCount - 1) ? iLabel + 1 : 0;
00708                         const int shortIdx =  (iLabel < shortLabelsCount    ) ? iLabel     : 0;
00709                         const int shortIdx2 = (iLabel < shortLabelsCount - 1) ? iLabel + 1 : 0;
00710                         labelItem->setText(  customizedLabel(
00711                                 useShortLabels ? shortLabelsList[ shortIdx ] : labelsList[ idx ] ) );
00712                         labelItem2->setText( customizedLabel(
00713                                 useShortLabels ? shortLabelsList[ shortIdx2 ] : labelsList[ idx2 ] ) );
00714                     }
00715 
00716                     QPointF firstPos( i, 0.0 );
00717                     firstPos = plane->translate( firstPos );
00718 
00719                     QPointF secondPos( i + labelDiff, 0.0 );
00720                     secondPos = plane->translate( secondPos );
00721 
00722 
00723                     if ( labelItem->intersects( *labelItem2, firstPos, secondPos ) )
00724                     {
00725                         i = minValueX;
00726 
00727                         // fix for issue #4179:
00728                         labelDiff *= 10.0;
00729                         // old code:
00730                         // labelDiff += labelDiff;
00731 
00732                         iLabel = 0;
00733                     }
00734                     else
00735                     {
00736                         i += labelDiff;
00737                     }
00738 
00739                     ++iLabel;
00740                     if ( (iLabel > hardLabelsCount - 1) && !useConfiguredStepsLabels )
00741                     {
00742                         iLabel = 0;
00743                     }
00744                 }
00745             }
00746 
00747             int idxLabel = 0;
00748             qreal iLabelF = minValueX;
00749             //qDebug() << iLabelF;
00750             qreal i = minValueX;
00751             qreal labelStep = 0.0;
00752             //    qDebug() << "dimX.stepWidth:" << dimX.stepWidth  << "labelDiff:" << labelDiff;
00753             //dimX.stepWidth = 0.5;
00754             while( i <= maxValueX ) {
00755                 // Line charts: we want the first tick to begin at 0.0 not at 0.5 otherwise labels and
00756                 // values does not fit each others
00757                 QPointF topPoint ( i + ( isBarDiagram ? 0.5 : 0.0 ), 0.0 );
00758                 QPointF bottomPoint ( topPoint );
00759                 topPoint = plane->translate( topPoint );
00760                 bottomPoint = plane->translate( bottomPoint );
00761                 topPoint.setY( rulerRef.y() + tickLength() );
00762                 bottomPoint.setY( rulerRef.y() );
00763 
00764                 const qreal translatedValue = topPoint.x();
00765                 const bool bIsVisibleLabel =
00766                         ( translatedValue >= geoRect.left() && translatedValue <= geoRect.right() );
00767 
00768                 // fix for issue #4179:
00769                 bool painttick = bIsVisibleLabel && labelStep <= 0;;
00770                 // old code:
00771                 // bool painttick = true;
00772 
00773                 //Dont paint more ticks than we need
00774                 //when diagram type is Bar
00775                 if (  isBarDiagram && i == maxValueX )
00776                     painttick = false;
00777 
00778                 if ( bIsVisibleLabel && painttick )
00779                     ptr->drawLine( topPoint, bottomPoint );
00780 
00781                 drawnXTicks.append( static_cast<int>( topPoint.x() ) );
00782                 if( drawLabels ) {
00783                     if( bIsVisibleLabel ){
00784                         if ( isLogarithmicX )
00785                             labelItem->setText( customizedLabel(QString::number( i, 'f', 0 )) );
00786                         /* We dont need that
00787                         * it causes header labels to be skipped even if there is enough
00788                         * space for them to displayed.
00789                         * Commenting for now - I need to test more in details - Let me know if I am wrong here.
00790                         */
00791                         /*
00792                         else if( (dimX.stepWidth != 1.0) && ! dimX.isCalculated ) {
00793                         labelItem->setText( customizedLabel(QString::number( i, 'f', 0 )) );
00794                         }
00795                         */
00796                         else {
00797                             const int idx = idxLabel + static_cast<int>(minValueX);
00798                             labelItem->setText(
00799                                     customizedLabel(
00800                                           hardLabelsCount
00801                                     ? ( useShortLabels    ? shortLabelsList[ idx ] : labelsList[ idx ] )
00802                                 : ( headerLabelsCount ? headerLabels[ idx ] : QString::number( iLabelF ))));
00803                             //qDebug() << "x - labelItem->text() " << labelItem->text() << headerLabelsCount;
00804                         }
00805                         // No need to call labelItem->setParentWidget(), since we are using
00806                         // the layout item temporarily only.
00807                         if( labelStep <= 0 ) {
00808                             const PainterSaver p( ptr );
00809                             const QSize size( labelItem->sizeHint() );
00810                             labelItem->setGeometry(
00811                                 QRect(
00812                                     QPoint(
00813                                         static_cast<int>( topPoint.x() - size.width() / 2 ),
00814                                         static_cast<int>( topPoint.y() +
00815                                                         ( position() == Bottom
00816                                                             ? halfFontHeight
00817                                                             : ((halfFontHeight + size.height()) * -1.0) ) ) ),
00818                                     size ) );
00819 
00820                             QRect labelGeo = labelItem->geometry();
00821                             // if our item would only half fit, we disable clipping for that one
00822                             if( labelGeo.left() < geoRect.left() && labelGeo.right() > geoRect.left() )
00823                                 ptr->setClipping( false );
00824                             if( labelGeo.left() < geoRect.right() && labelGeo.right() > geoRect.right() )
00825                                 ptr->setClipping( false );
00826 
00827                             labelItem->setGeometry( labelGeo );
00828 
00829                             labelStep = labelDiff - dimX.stepWidth;
00830                             labelItem->paint( ptr );
00831 
00832                             // do not call customizedLabel() again:
00833                             labelItem2->setText( labelItem->text() );
00834 
00835                         } else {
00836                             labelStep -= dimX.stepWidth;
00837                         }
00838                     }
00839 
00840                     if( hardLabelsCount ) {
00841                         if( useShortLabels && idxLabel >= shortLabelsCount - 1 )
00842                             idxLabel = 0;
00843                         else if( !useShortLabels && idxLabel >= hardLabelsCount - 1 )
00844                             idxLabel = 0;
00845                         else{
00846                             idxLabel += static_cast<int>(dimX.stepWidth);
00847                             //qDebug() << "dimX.stepWidth:" << dimX.stepWidth << "  idxLabel:" << idxLabel;
00848                         }
00849                     } else if( headerLabelsCount ) {
00850                         if( idxLabel >= headerLabelsCount - 1 ) {
00851                             idxLabel = 0;
00852                         }else
00853                             ++idxLabel;
00854                     } else {
00855                         iLabelF += dimX.stepWidth;
00856                     }
00857                 }
00858                 if ( isLogarithmicX )
00859                 {
00860                     i *= 10.0;
00861                     if( i == 0.0 )
00862                         i = 1.0;//std::numeric_limits< double >::epsilon();
00863                 }
00864                 else
00865                 {
00866                     i += dimX.stepWidth;
00867                 }
00868             }
00869         } else {
00870             const PainterSaver p( ptr );
00871             const double maxLimit = maxValueY;
00872             const double steg = dimY.stepWidth;
00873             int maxLabelsWidth = 0;
00874             qreal labelValue;
00875             if( drawLabels && position() == Right ){
00876                 // Find the widest label, so we to know how much we need to right-shift
00877                 // our labels, to get them drawn right aligned:
00878                 labelValue = minValueY;
00879                 while ( labelValue <= maxLimit ) {
00880                     const QString labelText = diagram()->unitPrefix( static_cast< int >( labelValue ), Qt::Vertical, true ) + 
00881                                               QString::number( labelValue ) +
00882                                               diagram()->unitSuffix( static_cast< int >( labelValue ), Qt::Vertical, true );
00883                     labelItem->setText( customizedLabel( labelText ) );
00884                     maxLabelsWidth = qMax( maxLabelsWidth, labelItem->sizeHint().width() );
00885 
00886                     calculateNextLabel( labelValue, steg, isLogarithmicY );
00887                 }
00888             }
00889 
00890             ptr->setClipping( false );
00891             labelValue = minValueY;
00892             qreal step = steg;
00893             bool nextLabel = false;
00894             //qDebug("minValueY: %f   maxLimit: %f   steg: %f", minValueY, maxLimit, steg);
00895 
00896             if( drawLabels )
00897             {
00898                 // first calculate the steps depending on labels colision
00899                 while( labelValue <= maxLimit ) {
00900                     QPointF leftPoint = plane->translate( QPointF( 0, labelValue ) );
00901                     const qreal translatedValue = leftPoint.y();
00902                     //qDebug() << "geoRect:" << geoRect << "   geoRect.top()" << geoRect.top()
00903                     //<< "geoRect.bottom()" << geoRect.bottom() << "  translatedValue:" << translatedValue;
00904                     if( translatedValue > geoRect.top() && translatedValue <= geoRect.bottom() ){
00905                         const QString labelText = diagram()->unitPrefix( static_cast< int >( labelValue ), Qt::Vertical, true ) +
00906                                                   QString::number( labelValue ) +
00907                                                   diagram()->unitSuffix( static_cast< int >( labelValue ), Qt::Vertical, true );
00908                         const QString label2Text = diagram()->unitPrefix( static_cast< int >( labelValue + step ), Qt::Vertical, true ) +
00909                                                    QString::number( labelValue + step ) +
00910                                                    diagram()->unitSuffix( static_cast< int >( labelValue + step ), Qt::Vertical, true );
00911                         labelItem->setText(  customizedLabel( labelText ) );
00912                         labelItem2->setText( customizedLabel( QString::number( labelValue + step ) ) );
00913                         QPointF nextPoint = plane->translate(  QPointF( 0,  labelValue + step ) );
00914                         if ( labelItem->intersects( *labelItem2, leftPoint, nextPoint ) )
00915                         {
00916                             step += steg;
00917                             nextLabel = false;
00918                         }else{
00919                             nextLabel = true;
00920                         }
00921                     }else{
00922                         nextLabel = true;
00923                     }
00924 
00925                     if ( nextLabel || isLogarithmicY )
00926                         calculateNextLabel( labelValue, step, isLogarithmicY );
00927                     else
00928                         labelValue = minValueY;
00929                 }
00930 
00931                 // Second - Paint the labels
00932                 labelValue = minValueY;
00933                 //qDebug() << "axis labels starting at" << labelValue << "step width" << step;
00934                 while( labelValue <= maxLimit ) {
00935                     //qDebug() << "value now" << labelValue;
00936                     const QString labelText = diagram()->unitPrefix( static_cast< int >( labelValue ), Qt::Vertical, true ) + 
00937                                               QString::number( labelValue ) + 
00938                                               diagram()->unitSuffix( static_cast< int >( labelValue ), Qt::Vertical, true );
00939                     labelItem->setText( customizedLabel( labelText ) );
00940                     QPointF leftPoint = plane->translate( QPointF( 0, labelValue ) );
00941                     QPointF rightPoint ( 0.0, labelValue );
00942                     rightPoint = plane->translate( rightPoint );
00943                     leftPoint.setX( rulerRef.x() + tickLength() );
00944                     rightPoint.setX( rulerRef.x() );
00945 
00946                     const qreal translatedValue = rightPoint.y();
00947                     const bool bIsVisibleLabel =
00948                             ( translatedValue >= geoRect.top() && translatedValue <= geoRect.bottom() );
00949 
00950                     if( bIsVisibleLabel ){
00951                         ptr->drawLine( leftPoint, rightPoint );
00952                         drawnYTicks.append( static_cast<int>( leftPoint.y() ) );
00953                         const QSize labelSize( labelItem->sizeHint() );
00954                         leftPoint.setX( leftPoint.x() );
00955                         const int x =
00956                             static_cast<int>( leftPoint.x() + met.height() * ( position() == Left ? -0.5 : 0.5) )
00957                             - ( position() == Left ? labelSize.width() : (labelSize.width() - maxLabelsWidth) );
00958                         const int y =
00959                             static_cast<int>( leftPoint.y() - ( met.ascent() + met.descent() ) * 0.6 );
00960                         labelItem->setGeometry( QRect( QPoint( x, y ), labelSize ) );
00961                         labelItem->paint( ptr );
00962                     }
00963 
00964                     calculateNextLabel( labelValue, step, isLogarithmicY );
00965                 }
00966             }
00967         }
00968         delete labelItem;
00969         delete labelItem2;
00970     }
00971 
00972     // this draws the subunit rulers
00973     if ( drawSubUnitRulers ) {
00974         d->drawSubUnitRulers( ptr, plane, dim, rulerRef, isAbscissa() ? drawnXTicks : drawnYTicks );
00975     }
00976 
00977     if( ! titleText().isEmpty() ){
00978         d->drawTitleText( ptr, plane, areaGeoRect );
00979     }
00980 
00981     //qDebug() << "KDChart::CartesianAxis::paintCtx() done.";
00982 }

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 CartesianAxis::Position CartesianAxis::position (  )  const [virtual]

Definition at line 145 of file KDChartCartesianAxis.cpp.

References d.

Referenced by compare(), expandingDirections(), isAbscissa(), isOrdinate(), maximumSize(), paintCtx(), and tickLength().

00146 {
00147     return d->position;
00148 }

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         }

void CartesianAxis::resetTitleTextAttributes (  ) 

Reset the title text attributes to the built-in default:.

Same font and pen as AbstractAxis::textAttributes() and 1.5 times their size.

Definition at line 127 of file KDChartCartesianAxis.cpp.

References d, and layoutPlanes().

00128 {
00129     d->useDefaultTextAttributes = true;
00130     layoutPlanes();
00131 }

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 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 CartesianAxis::setGeometry ( const QRect &  r  )  [virtual]

pure virtual in QLayoutItem

Implements KDChart::AbstractAxis.

Definition at line 1227 of file KDChartCartesianAxis.cpp.

References d.

01228 {
01229 //    qDebug() << "KDChart::CartesianAxis::setGeometry(" << r << ") called"
01230 //             << (isAbscissa() ? "for Abscissa":"for Ordinate") << "axis";
01231     d->geometry = r;
01232 }

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 CartesianAxis::setPosition ( Position  p  )  [virtual]

Definition at line 139 of file KDChartCartesianAxis.cpp.

References d, and layoutPlanes().

00140 {
00141     d->position = p;
00142     layoutPlanes();
00143 }

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 CartesianAxis::setTitleText ( const QString &  text  ) 

Definition at line 97 of file KDChartCartesianAxis.cpp.

References d, and layoutPlanes().

00098 {
00099     d->titleText = text;
00100     layoutPlanes();
00101 }

void CartesianAxis::setTitleTextAttributes ( const TextAttributes a  ) 

Definition at line 108 of file KDChartCartesianAxis.cpp.

References d, and layoutPlanes().

00109 {
00110     d->titleTextAttributes = a;
00111     d->useDefaultTextAttributes = false;
00112     layoutPlanes();
00113 }

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 paintCtx().

00315 {
00316     return d->hardShortLabels;
00317 }

QSize CartesianAxis::sizeHint (  )  const [virtual]

pure virtual in QLayoutItem

Definition at line 1222 of file KDChartCartesianAxis.cpp.

References maximumSize().

01223 {
01224     return maximumSize();
01225 }

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(), maximumSize(), paintCtx(), and titleTextAttributes().

00246 {
00247     return d->textAttributes;
00248 }

int CartesianAxis::tickLength ( bool  subUnitTicks = false  )  const

Definition at line 1239 of file KDChartCartesianAxis.cpp.

References isAbscissa(), Left, position(), and Top.

Referenced by maximumSize(), and paintCtx().

01240 {
01241     int result = 0;
01242 
01243     if ( isAbscissa() ) {
01244         result = position() == Top ? -4 : 3;
01245     } else {
01246         result = position() == Left ? -4 : 3;
01247     }
01248 
01249     if ( subUnitTicks )
01250         result = result < 0 ? result + 1 : result - 1;
01251 
01252     return result;
01253 }

QString CartesianAxis::titleText (  )  const

Definition at line 103 of file KDChartCartesianAxis.cpp.

References d.

Referenced by compare(), maximumSize(), and paintCtx().

00104 {
00105     return d->titleText;
00106 }

TextAttributes CartesianAxis::titleTextAttributes (  )  const

Returns the text attributes that will be used for displaying the title text.

This is either the text attributes as specified by setTitleTextAttributes, or (if setTitleTextAttributes() was not called) the default text attributes.

See also:
resetTitleTextAttributes, hasDefaultTitleTextAttributes

Definition at line 115 of file KDChartCartesianAxis.cpp.

References d, KDChart::TextAttributes::fontSize(), hasDefaultTitleTextAttributes(), KDChart::TextAttributes::setFontSize(), and KDChart::AbstractAxis::textAttributes().

Referenced by compare().

00116 {
00117     if( hasDefaultTitleTextAttributes() ){
00118         TextAttributes ta( textAttributes() );
00119         Measure me( ta.fontSize() );
00120         me.setValue( me.value() * 1.5 );
00121         ta.setFontSize( me );
00122         return ta;
00123     }
00124     return d->titleTextAttributes;
00125 }

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 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:
Generated on Mon Sep 17 16:18:12 2007 for KD Chart 2 by  doxygen 1.5.1