#include <KDChartAbstractAxis.h>
Inheritance diagram for KDChart::AbstractAxis:
For being useful, axes need to be assigned to a diagram, see AbstractCartesianDiagram::addAxis and AbstractCartesianDiagram::takeAxis.
Definition at line 63 of file KDChartAbstractAxis.h.
Public Member Functions | |
AbstractAxis (AbstractDiagram *diagram=0) | |
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 |
FrameAttributes | frameAttributes () const |
virtual QRect | geometry () const=0 |
void | getFrameLeadings (int &left, int &top, int &right, int &bottom) 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(). | |
bool | observedBy (AbstractDiagram *diagram) const |
virtual void | paint (QPainter *)=0 |
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 *context) |
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 () |
void | removeFromParentLayout () |
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)=0 |
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. | |
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. | |
QStringList | shortLabels () const |
Returns a list of strings, that are used as axis labels, as set via setShortLabels. | |
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. | |
virtual int | topOverlap (bool doNotRecalculate=false) const |
This is called at layout time by KDChart::AutoSpacerLayoutItem::sizeHint(). | |
virtual | ~AbstractAxis () |
Static Public Member Functions | |
void | paintBackgroundAttributes (QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes) |
void | paintFrameAttributes (QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes) |
Public Attributes | |
public | Q_SLOTS: void update() |
protected | Q_SLOTS: virtual void delayedInit() |
Protected Member Functions | |
virtual QRect | areaGeometry () const |
QRect | innerRect () const |
virtual void | positionHasChanged () |
Protected Attributes | |
Q_SIGNALS | __pad0__: void positionChanged( AbstractArea * ) |
QWidget * | mParent |
QLayout * | mParentLayout |
|
Definition at line 108 of file KDChartAbstractAxis.cpp.
00109 : AbstractArea( new Private( diagram, this ) ) 00110 { 00111 init(); 00112 QTimer::singleShot(0, this, SLOT(delayedInit())); 00113 } |
|
Definition at line 115 of file KDChartAbstractAxis.cpp. References d.
|
|
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 } |
|
Implements KDChart::AbstractAreaBase. Definition at line 150 of file KDChartAbstractArea.cpp. Referenced by KDChart::CartesianCoordinatePlane::drawingArea(), KDChart::PolarCoordinatePlane::layoutDiagrams(), KDChart::CartesianAxis::paint(), KDChart::AbstractArea::paintAll(), and KDChart::CartesianAxis::paintCtx().
00151 { 00152 return geometry(); 00153 } |
|
Definition at line 112 of file KDChartAbstractAreaBase.cpp. References d. Referenced by updateCommonBrush().
00113 { 00114 return d->backgroundAttributes; 00115 } |
|
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.
Definition at line 101 of file KDChartAbstractArea.cpp. References d. Referenced by KDChart::AutoSpacerLayoutItem::sizeHint().
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 } |
|
Returns true if both areas have the same settings.
Definition at line 75 of file KDChartAbstractAreaBase.cpp.
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 } |
|
Returns true if both axes have the same settings.
Definition at line 142 of file KDChartAbstractAxis.cpp.
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 } |
|
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.
Definition at line 211 of file KDChartAbstractAxis.cpp. References d. Referenced by createObserver().
00212 { 00213 if( d->observer ){ 00214 connect( d->observer, SIGNAL( diagramDataChanged( AbstractDiagram *) ), 00215 this, SLOT( update() ) ); 00216 } 00217 } |
|
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 312 of file KDChartAbstractAxis.cpp. References d.
|
|
Definition at line 177 of file KDChartAbstractAxis.cpp. References connectSignals(), and d. Referenced by KDChart::AbstractCartesianDiagram::addAxis().
00178 { 00179 if( d->setDiagram( diagram ) ) 00180 connectSignals(); 00181 } |
|
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.
Definition at line 161 of file KDChartAbstractAxis.cpp. Referenced by KDChart::CartesianAxis::maximumSize(), and KDChart::CartesianAxis::paintCtx().
00162 {
00163 return label;
00164 }
|
|
Definition at line 193 of file KDChartAbstractAxis.cpp. References d. Referenced by KDChart::AbstractCartesianDiagram::takeAxis(), and KDChart::AbstractCartesianDiagram::~AbstractCartesianDiagram().
00194 { 00195 d->unsetDiagram( diagram ); 00196 } |
|
Definition at line 319 of file KDChartAbstractAxis.cpp. References d.
00320 { 00321 return d->diagram(); 00322 } |
|
Definition at line 102 of file KDChartAbstractAreaBase.cpp. References d. Referenced by KDChart::Legend::clone(), and updateCommonBrush().
00103 { 00104 return d->frameAttributes; 00105 } |
|
Implemented in KDChart::CartesianAxis. |
|
Definition at line 204 of file KDChartAbstractAreaBase.cpp. References d. Referenced by KDChart::AbstractAreaBase::innerRect(), and KDChart::AbstractAreaWidget::paintAll().
00205 { 00206 if( d && d->frameAttributes.isVisible() ){ 00207 const int padding = qMax( d->frameAttributes.padding(), 0 ); 00208 left = padding; 00209 top = padding; 00210 right = padding; 00211 bottom = padding; 00212 }else{ 00213 left = 0; 00214 top = 0; 00215 right = 0; 00216 bottom = 0; 00217 } 00218 } |
|
Definition at line 220 of file KDChartAbstractAreaBase.cpp. References KDChart::AbstractAreaBase::areaGeometry(), and KDChart::AbstractAreaBase::getFrameLeadings(). Referenced by KDChart::TextArea::paintAll(), and KDChart::AbstractArea::paintAll().
00221 { 00222 int left; 00223 int top; 00224 int right; 00225 int bottom; 00226 getFrameLeadings( left, top, right, bottom ); 00227 return 00228 QRect( QPoint(0,0), areaGeometry().size() ) 00229 .adjusted( left, top, -right, -bottom ); 00230 } |
|
Returns a list of strings, that are used as axis labels, as set via setLabels.
Definition at line 273 of file KDChartAbstractAxis.cpp. References d. Referenced by KDChart::CartesianAxis::maximumSize(), and KDChart::CartesianAxis::paintCtx().
00274 { 00275 return d->hardLabels; 00276 } |
|
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.
Definition at line 77 of file KDChartAbstractArea.cpp. References d. Referenced by KDChart::AutoSpacerLayoutItem::sizeHint().
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 } |
|
Definition at line 324 of file KDChartAbstractAxis.cpp. References d.
00325 { 00326 return d->hasDiagram( diagram ); 00327 } |
|
|
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.
Reimplemented from KDChart::AbstractLayoutItem. 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 } |
|
Definition at line 188 of file KDChartAbstractAreaBase.cpp. References d, and KDChart::AbstractAreaBase::paintBackgroundAttributes(). Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().
00189 { 00190 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintBackground()", 00191 "Private class was not initialized!" ); 00192 paintBackgroundAttributes( painter, rect, d->backgroundAttributes ); 00193 } |
|
Definition at line 119 of file KDChartAbstractAreaBase.cpp. References KDChart::BackgroundAttributes::brush(), KDChart::BackgroundAttributes::isVisible(), KDChart::BackgroundAttributes::pixmap(), and KDChart::BackgroundAttributes::pixmapMode(). Referenced by KDChart::AbstractAreaBase::paintBackground().
00121 { 00122 if( !attributes.isVisible() ) return; 00123 00124 /* first draw the brush (may contain a pixmap)*/ 00125 if( Qt::NoBrush != attributes.brush().style() ) { 00126 KDChart::PainterSaver painterSaver( &painter ); 00127 painter.setPen( Qt::NoPen ); 00128 const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) ); 00129 painter.setBrushOrigin( newTopLeft ); 00130 painter.setBrush( attributes.brush() ); 00131 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00132 } 00133 /* next draw the backPixmap over the brush */ 00134 if( !attributes.pixmap().isNull() && 00135 attributes.pixmapMode() != BackgroundAttributes::BackgroundPixmapModeNone ) { 00136 QPointF ol = rect.topLeft(); 00137 if( BackgroundAttributes::BackgroundPixmapModeCentered == attributes.pixmapMode() ) 00138 { 00139 ol.setX( rect.center().x() - attributes.pixmap().width() / 2 ); 00140 ol.setY( rect.center().y() - attributes.pixmap().height()/ 2 ); 00141 painter.drawPixmap( ol, attributes.pixmap() ); 00142 } else { 00143 QMatrix m; 00144 double zW = (double)rect.width() / (double)attributes.pixmap().width(); 00145 double zH = (double)rect.height() / (double)attributes.pixmap().height(); 00146 switch( attributes.pixmapMode() ) { 00147 case BackgroundAttributes::BackgroundPixmapModeScaled: 00148 { 00149 double z; 00150 z = qMin( zW, zH ); 00151 m.scale( z, z ); 00152 } 00153 break; 00154 case BackgroundAttributes::BackgroundPixmapModeStretched: 00155 m.scale( zW, zH ); 00156 break; 00157 default: 00158 ; // Cannot happen, previously checked 00159 } 00160 QPixmap pm = attributes.pixmap().transformed( m ); 00161 ol.setX( rect.center().x() - pm.width() / 2 ); 00162 ol.setY( rect.center().y() - pm.height()/ 2 ); 00163 painter.drawPixmap( ol, pm ); 00164 } 00165 } 00166 } |
|
Default impl: Paint the complete item using its layouted position and size.
Reimplemented in KDChart::CartesianAxis. Definition at line 77 of file KDChartLayoutItems.cpp. References KDChart::AbstractLayoutItem::paint(), and KDChart::PaintContext::painter().
00078 { 00079 if( context ) 00080 paint( context->painter() ); 00081 } |
|
Definition at line 196 of file KDChartAbstractAreaBase.cpp. References d, and KDChart::AbstractAreaBase::paintFrameAttributes(). Referenced by KDChart::TextArea::paintAll(), KDChart::AbstractAreaWidget::paintAll(), and KDChart::AbstractArea::paintAll().
00197 { 00198 Q_ASSERT_X ( d != 0, "AbstractAreaBase::paintFrame()", 00199 "Private class was not initialized!" ); 00200 paintFrameAttributes( painter, rect, d->frameAttributes ); 00201 } |
|
Definition at line 169 of file KDChartAbstractAreaBase.cpp. References KDChart::FrameAttributes::isVisible(), and KDChart::FrameAttributes::pen(). Referenced by KDChart::AbstractAreaBase::paintFrame().
00171 { 00172 00173 if( !attributes.isVisible() ) return; 00174 00175 // Note: We set the brush to NoBrush explicitely here. 00176 // Otherwise we might get a filled rectangle, so any 00177 // previously drawn background would be overwritten by that area. 00178 00179 const QPen oldPen( painter.pen() ); 00180 const QBrush oldBrush( painter.brush() ); 00181 painter.setPen( attributes.pen() ); 00182 painter.setBrush( Qt::NoBrush ); 00183 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) ); 00184 painter.setBrush( oldBrush ); 00185 painter.setPen( oldPen ); 00186 } |
|
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 } |
|
Definition at line 74 of file KDChartLayoutItems.h.
00075 { 00076 return mParentLayout; 00077 } |
|
Reimplemented from KDChart::AbstractAreaBase. Definition at line 155 of file KDChartAbstractArea.cpp.
00156 {
00157 emit positionChanged( this );
00158 }
|
|
Definition at line 78 of file KDChartLayoutItems.h. Referenced by KDChart::Chart::takeCoordinatePlane().
00079 { 00080 if( mParentLayout ){ 00081 if( widget() ) 00082 mParentLayout->removeWidget( widget() ); 00083 else 00084 mParentLayout->removeItem( this ); 00085 } 00086 } |
|
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.
Definition at line 85 of file KDChartAbstractArea.cpp. References d. Referenced by KDChart::AutoSpacerLayoutItem::sizeHint().
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 } |
|
Definition at line 107 of file KDChartAbstractAreaBase.cpp. References d.
00108 { 00109 d->backgroundAttributes = a; 00110 } |
|
Definition at line 97 of file KDChartAbstractAreaBase.cpp. References d. Referenced by KDChart::Legend::clone().
00098 { 00099 d->frameAttributes = a; 00100 } |
|
Implemented in KDChart::CartesianAxis. |
|
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.
Definition at line 263 of file KDChartAbstractAxis.cpp. References d.
00264 { 00265 d->hardLabels = list; 00266 } |
|
Definition at line 70 of file KDChartLayoutItems.h.
00071 { 00072 mParentLayout = lay; 00073 } |
|
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::Legend::buildLegend(), and KDChart::AbstractCartesianDiagram::takeAxis().
00065 { 00066 mParent = widget; 00067 } |
|
Use this to specify your own set of strings, to be used as axis labels, in case the normal labels are too long.
Definition at line 289 of file KDChartAbstractAxis.cpp. References d.
00290 { 00291 d->hardShortLabels = list; 00292 } |
|
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.
Definition at line 231 of file KDChartAbstractAxis.cpp. References d.
00232 { 00233 d->textAttributes = a; 00234 } |
|
Returns a list of strings, that are used as axis labels, as set via setShortLabels.
Definition at line 302 of file KDChartAbstractAxis.cpp. References d. Referenced by KDChart::CartesianAxis::paintCtx().
00303 { 00304 return d->hardShortLabels; 00305 } |
|
Report changed size hint: ask the parent widget to recalculate the layout.
Definition at line 86 of file KDChartLayoutItems.cpp. 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 } |
|
Returns the text attributes to be used for axis labels.
Definition at line 241 of file KDChartAbstractAxis.cpp. References d. Referenced by KDChart::CartesianAxis::maximumSize(), KDChart::CartesianAxis::paintCtx(), and KDChart::CartesianAxis::titleTextAttributes().
00242 { 00243 return d->textAttributes; 00244 } |
|
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.
Definition at line 93 of file KDChartAbstractArea.cpp. References d. Referenced by KDChart::AutoSpacerLayoutItem::sizeHint().
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 } |
|
Reimplemented in KDChart::AbstractCoordinatePlane. Definition at line 141 of file KDChartAbstractArea.h. |
|
Definition at line 88 of file KDChartLayoutItems.h. Referenced by KDChart::AbstractLayoutItem::setParentWidget(). |
|
Definition at line 89 of file KDChartLayoutItems.h. |
|
Definition at line 129 of file KDChartAbstractAxis.h. |
|
Definition at line 126 of file KDChartAbstractAxis.h. |