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

KDChart::Chart Class Reference

#include <KDChartChart>

Inheritance diagram for KDChart::Chart:

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

Detailed Description

A chart with one or more diagrams.

The Chart class represents a drawing consisting of one or more diagrams and various optional elements such as legends, axes, text boxes, headers or footers. It takes ownership of all these elements when they are assigned to it. Each diagram is associated with a coordinate plane, of which the chart can have more than one. The coordinate planes (and thus the associated diagrams) can be layed out in various ways.

The Chart class makes heavy use of the Qt Interview framework for model/view programming, and thus requires data to be presented to it in a QAbstractItemModel compatible way. For many simple charts, especially if the visualized data is static, KDChart::Widget provides an abstracted interface, that hides the complexity of Interview to a large extent.

Definition at line 72 of file KDChartChart.h.

Public Member Functions

void addCoordinatePlane (AbstractCoordinatePlane *plane)
 Adds a coordinate plane to the chart.

void addHeaderFooter (HeaderFooter *headerFooter)
 Adds a header or a footer to the chart.

void addLegend (Legend *legend)
 Add the given legend to the chart.

BackgroundAttributes backgroundAttributes () const
 Chart (QWidget *parent=0)
AbstractCoordinatePlanecoordinatePlane ()
 Each chart must have at least one coordinate plane.

QLayout * coordinatePlaneLayout ()
CoordinatePlaneList coordinatePlanes ()
 The list of coordinate planes.

FrameAttributes frameAttributes () const
int globalLeadingBottom () const
 The padding between the start of the widget and the start of the area that is used for drawing at the bottom.

int globalLeadingLeft () const
 The padding between the start of the widget and the start of the area that is used for drawing on the left.

int globalLeadingRight () const
 The padding between the start of the widget and the start of the area that is used for drawing on the right.

int globalLeadingTop () const
 The padding between the start of the widget and the start of the area that is used for drawing at the top.

HeaderFooterheaderFooter ()
 The first header or footer of the chart.

HeaderFooterList headerFooters ()
 The list of headers and footers associated with the chart.

Legendlegend ()
 The first legend of the chart or 0 if there was none added to the chart.

LegendList legends ()
 The list of all legends associated with the chart.

void paint (QPainter *painter, const QRect &target)
 Paints all the contents of the chart.

void reLayoutFloatingLegends ()
void replaceCoordinatePlane (AbstractCoordinatePlane *plane, AbstractCoordinatePlane *oldPlane=0)
 Replaces the old coordinate plane, or appends the plane, it there is none yet.

void replaceHeaderFooter (HeaderFooter *headerFooter, HeaderFooter *oldHeaderFooter=0)
 Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet.

void replaceLegend (Legend *legend, Legend *oldLegend=0)
 Replaces the old legend, or appends the new legend, it there is none yet.

void setBackgroundAttributes (const BackgroundAttributes &a)
 Specify the background attributes to be used, by default there is no background.

void setCoordinatePlaneLayout (QLayout *layout)
void setFrameAttributes (const FrameAttributes &a)
 Specify the frame attributes to be used, by default is it a thin black line.

void setGlobalLeading (int left, int top, int right, int bottom)
 Set the padding between the margin of the widget and the area that the contents are drawn into.

void setGlobalLeadingBottom (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the bottom.

void setGlobalLeadingLeft (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the left.

void setGlobalLeadingRight (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing on the right.

void setGlobalLeadingTop (int leading)
 Set the padding between the start of the widget and the start of the area that is used for drawing at the top.

void takeCoordinatePlane (AbstractCoordinatePlane *plane)
 Removes the coordinate plane from the chart, without deleting it.

void takeHeaderFooter (HeaderFooter *headerFooter)
 Removes the header (or footer, resp.) from the chart, without deleting it.

void takeLegend (Legend *legend)
 Removes the legend from the chart, without deleting it.

 ~Chart ()

Public Attributes

Q_SIGNALS __pad0__: void propertiesChanged()

Protected Member Functions

void mousePressEvent (QMouseEvent *event)
 reimp

void paintEvent (QPaintEvent *event)
 Draws the background and frame, then calls paint().

void resizeEvent (QResizeEvent *event)
 Adjusts the internal layout when the chart is resized.


Constructor & Destructor Documentation

Chart::Chart QWidget parent = 0  )  [explicit]
 

Definition at line 781 of file KDChartChart.cpp.

References addCoordinatePlane(), setFrameAttributes(), KDChart::FrameAttributes::setPadding(), KDChart::FrameAttributes::setPen(), and KDChart::FrameAttributes::setVisible().

00782     : QWidget ( parent )
00783     , _d( new Private( this ) )
00784 {
00785 #if defined KDAB_EVAL
00786     EvalDialog::checkEvalLicense( "KD Chart" );
00787 #endif
00788 
00789     FrameAttributes frameAttrs;
00790     frameAttrs.setVisible( true );
00791     frameAttrs.setPen( QPen( Qt::black ) );
00792     frameAttrs.setPadding( 1 );
00793     setFrameAttributes( frameAttrs );
00794 
00795     addCoordinatePlane( new CartesianCoordinatePlane ( this ) );
00796 }

Chart::~Chart  ) 
 

Definition at line 798 of file KDChartChart.cpp.

00799 {
00800     delete _d;
00801 }


Member Function Documentation

void Chart::addCoordinatePlane AbstractCoordinatePlane plane  ) 
 

Adds a coordinate plane to the chart.

The chart takes ownership.

Parameters:
plane The coordinate plane to add.
See also:
replaceCoordinatePlane, takeCoordinatePlane

Definition at line 846 of file KDChartChart.cpp.

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

Referenced by Chart(), and replaceCoordinatePlane().

00847 {
00848     connect( plane, SIGNAL( destroyedCoordinatePlane( AbstractCoordinatePlane* ) ),
00849              d,   SLOT( slotUnregisterDestroyedPlane( AbstractCoordinatePlane* ) ) );
00850     connect( plane, SIGNAL( needUpdate() ),       this,   SLOT( update() ) );
00851     connect( plane, SIGNAL( needRelayout() ),     d,      SLOT( slotRelayout() ) ) ;
00852     connect( plane, SIGNAL( needLayoutPlanes() ), d,      SLOT( slotLayoutPlanes() ) ) ;
00853     connect( plane, SIGNAL( propertiesChanged() ),this, SIGNAL( propertiesChanged() ) );
00854     d->coordinatePlanes.append( plane );
00855     plane->setParent( this );
00856     d->slotLayoutPlanes();
00857 }

void Chart::addHeaderFooter HeaderFooter headerFooter  ) 
 

Adds a header or a footer to the chart.

The chart takes ownership.

Parameters:
headerFooter The header (or footer, resp.) to add.
See also:
replaceHeaderFooter, takeHeaderFooter

Definition at line 1036 of file KDChartChart.cpp.

References d, and KDChart::HeaderFooter::setParent().

Referenced by replaceHeaderFooter().

01037 {
01038     d->headerFooters.append( headerFooter );
01039     headerFooter->setParent( this );
01040     connect( headerFooter, SIGNAL( destroyedHeaderFooter( HeaderFooter* ) ),
01041              d, SLOT( slotUnregisterDestroyedHeaderFooter( HeaderFooter* ) ) );
01042     connect( headerFooter, SIGNAL( positionChanged( HeaderFooter* ) ),
01043              d, SLOT( slotRelayout() ) );
01044     d->slotRelayout();
01045 }

void Chart::addLegend Legend legend  ) 
 

Add the given legend to the chart.

The chart takes ownership.

Parameters:
legend The legend to add.
See also:
replaceLegend, takeLegend

Definition at line 1089 of file KDChartChart.cpp.

References d, KDChart::TextAttributes::fontSize(), KDChart::TextAttributes::setFontSize(), KDChart::Legend::setReferenceArea(), KDChart::Measure::setRelativeMode(), KDChart::Legend::setTextAttributes(), KDChart::Legend::setTitleTextAttributes(), KDChart::Measure::setValue(), KDChart::Legend::setVisible(), KDChart::Legend::textAttributes(), and KDChart::Legend::titleTextAttributes().

Referenced by replaceLegend().

01090 {
01091     if( ! legend ) return;
01092 
01093     //qDebug() << "adding the legend";
01094     d->legends.append( legend );
01095     legend->setParent( this );
01096 
01097     TextAttributes textAttrs( legend->textAttributes() );
01098 
01099     KDChart::Measure measure( textAttrs.fontSize() );
01100     measure.setRelativeMode( this, KDChartEnums::MeasureOrientationMinimum );
01101     measure.setValue( 20 );
01102     textAttrs.setFontSize( measure );
01103     legend->setTextAttributes( textAttrs );
01104 
01105     textAttrs = legend->titleTextAttributes();
01106     measure.setRelativeMode( this, KDChartEnums::MeasureOrientationMinimum );
01107     measure.setValue( 24 );
01108     textAttrs.setFontSize( measure );
01109 
01110     legend->setTitleTextAttributes( textAttrs );
01111 
01112     legend->setReferenceArea( this );
01113 
01114 /*
01115     future: Use relative sizes for the markers too!
01116 
01117     const uint nMA = Legend::datasetCount();
01118     for( uint iMA = 0; iMA < nMA; ++iMA ){
01119         MarkerAttributes ma( legend->markerAttributes( iMA ) );
01120         ma.setMarkerSize( ... )
01121         legend->setMarkerAttributes( iMA, ma )
01122     }
01123 */
01124 
01125     connect( legend, SIGNAL( destroyedLegend( Legend* ) ),
01126              d, SLOT( slotUnregisterDestroyedLegend( Legend* ) ) );
01127     connect( legend, SIGNAL( positionChanged( AbstractAreaWidget* ) ),
01128              d, SLOT( slotLayoutPlanes() ) ); //slotRelayout() ) );
01129     connect( legend, SIGNAL( propertiesChanged() ),this, SIGNAL( propertiesChanged() ) );
01130     legend->setVisible( true );
01131     d->slotRelayout();
01132 }

BackgroundAttributes Chart::backgroundAttributes  )  const
 

Definition at line 820 of file KDChartChart.cpp.

References d.

00821 {
00822     return d->backgroundAttributes;
00823 }

AbstractCoordinatePlane * Chart::coordinatePlane  ) 
 

Each chart must have at least one coordinate plane.

Initially a default CartesianCoordinatePlane is created. Use replaceCoordinatePlane() to replace it with a different one, such as a PolarCoordinatePlane.

Returns:
The first coordinate plane of the chart.

Definition at line 830 of file KDChartChart.cpp.

References d.

00831 {
00832     if ( d->coordinatePlanes.isEmpty() )
00833     {
00834         qWarning() << "Chart::coordinatePlane: warning: no coordinate plane defined.";
00835         return 0;
00836     } else {
00837         return d->coordinatePlanes.first();
00838     }
00839 }

QLayout * Chart::coordinatePlaneLayout  ) 
 

Definition at line 825 of file KDChartChart.cpp.

References d.

00826 {
00827     return d->planesLayout;
00828 }

CoordinatePlaneList Chart::coordinatePlanes  ) 
 

The list of coordinate planes.

Returns:
The list of coordinate planes.

Definition at line 841 of file KDChartChart.cpp.

References KDChart::CoordinatePlaneList, and d.

00842 {
00843     return d->coordinatePlanes;
00844 }

FrameAttributes Chart::frameAttributes  )  const
 

Definition at line 810 of file KDChartChart.cpp.

References d.

00811 {
00812     return d->frameAttributes;
00813 }

int Chart::globalLeadingBottom  )  const
 

The padding between the start of the widget and the start of the area that is used for drawing at the bottom.

Returns:
The padding between the start of the widget and the start of the area that is used for drawing at the bottom.
See also:
setGlobalLeading

Definition at line 935 of file KDChartChart.cpp.

References d.

00936 {
00937     return d->globalLeadingBottom;
00938 }

int Chart::globalLeadingLeft  )  const
 

The padding between the start of the widget and the start of the area that is used for drawing on the left.

Returns:
The padding between the start of the widget and the start of the area that is used for drawing on the left.
See also:
setGlobalLeading

Definition at line 902 of file KDChartChart.cpp.

References d.

00903 {
00904     return d->globalLeadingLeft;
00905 }

int Chart::globalLeadingRight  )  const
 

The padding between the start of the widget and the start of the area that is used for drawing on the right.

Returns:
The padding between the start of the widget and the start of the area that is used for drawing on the right.
See also:
setGlobalLeading

Definition at line 924 of file KDChartChart.cpp.

References d.

00925 {
00926     return d->globalLeadingRight;
00927 }

int Chart::globalLeadingTop  )  const
 

The padding between the start of the widget and the start of the area that is used for drawing at the top.

Returns:
The padding between the start of the widget and the start of the area that is used for drawing at the top.
See also:
setGlobalLeading

Definition at line 913 of file KDChartChart.cpp.

References d.

00914 {
00915     return d->globalLeadingTop;
00916 }

HeaderFooter * Chart::headerFooter  ) 
 

The first header or footer of the chart.

By default there is none.

Returns:
The first header or footer of the chart or 0 if there was none added to the chart.

Definition at line 1074 of file KDChartChart.cpp.

References d.

01075 {
01076     if( d->headerFooters.isEmpty() ) {
01077         return 0;
01078     } else {
01079         return d->headerFooters.first();
01080     }
01081 }

HeaderFooterList Chart::headerFooters  ) 
 

The list of headers and footers associated with the chart.

Returns:
The list of headers and footers associated with the chart.

Definition at line 1083 of file KDChartChart.cpp.

References d, and KDChart::HeaderFooterList.

01084 {
01085     return d->headerFooters;
01086 }

Legend * Chart::legend  ) 
 

The first legend of the chart or 0 if there was none added to the chart.

Returns:
The first legend of the chart or 0 if none exists.

Definition at line 1161 of file KDChartChart.cpp.

References d.

Referenced by paint(), and reLayoutFloatingLegends().

01162 {
01163     if ( d->legends.isEmpty() )
01164     {
01165         return 0;
01166     } else {
01167         return d->legends.first();
01168     }
01169 }

LegendList Chart::legends  ) 
 

The list of all legends associated with the chart.

Returns:
The list of all legends associated with the chart.

Definition at line 1171 of file KDChartChart.cpp.

References d, and KDChart::LegendList.

01172 {
01173     return d->legends;
01174 }

void Chart::mousePressEvent QMouseEvent *  event  )  [protected]
 

reimp

Definition at line 1177 of file KDChartChart.cpp.

References d, KDChart::AbstractCoordinatePlane::diagram(), KDChart::AbstractCoordinatePlane::diagrams(), KDChart::AbstractCoordinatePlane::geometry(), and KDChart::AbstractCoordinatePlane::mousePressEvent().

01178 {
01179     KDAB_FOREACH( AbstractCoordinatePlane* plane, d->coordinatePlanes ) {
01180        if ( plane->geometry().contains( event->pos() ) ) {
01181            if ( plane->diagrams().size() > 0 ) {
01182                QPoint pos = plane->diagram()->mapFromGlobal( event->globalPos() );
01183                QMouseEvent ev( QEvent::MouseButtonPress, pos, event->globalPos(),
01184                                event->button(), event->buttons(),
01185                                event->modifiers() );
01186                plane->mousePressEvent( &ev );
01187            }
01188        }
01189     }
01190 }

void Chart::paint QPainter *  painter,
const QRect &  target
 

Paints all the contents of the chart.

Use this method, to make KDChart draw into your QPainter.

Note:
Any global leading settings will be used by the paint method too, so make sure to set them to zero, if you want the drawing to have the exact size of the target rectangle.
Parameters:
painter The painter to be drawn into.
target The rectangle to be filled by the Chart's drawing.
See also:
setGlobalLeading

Definition at line 940 of file KDChartChart.cpp.

References d, legend(), and KDChart::AbstractAreaWidget::paintIntoRect().

00941 {
00942     if( target.isEmpty() || !painter ) return;
00943     //qDebug() << "Chart::paint( ..," << target << ")";
00944 
00945     GlobalMeasureScaling::instance()->setFactors(
00946             static_cast<qreal>(target.width()) /
00947             static_cast<qreal>(geometry().size().width()),
00948             static_cast<qreal>(target.height()) /
00949             static_cast<qreal>(geometry().size().height()) );
00950 
00951     if( target.size() != d->currentLayoutSize ){
00952         d->resizeLayout( target.size() );
00953     }
00954     const QPoint translation = target.topLeft();
00955     painter->translate( translation );
00956 
00957     d->paintAll( painter );
00958 
00959     // for debugging:
00960     //painter->setPen(QPen(Qt::blue, 8));
00961     //painter->drawRect(target.adjusted(12,12,-12,-12));
00962 
00963     KDAB_FOREACH( Legend *legend, d->legends ) {
00964         const bool hidden = legend->isHidden() && legend->testAttribute(Qt::WA_WState_ExplicitShowHide);
00965         if ( !hidden ) {
00966             //qDebug() << "painting legend at " << legend->geometry();
00967             legend->paintIntoRect( *painter, legend->geometry() );
00968             //testing:
00969             //legend->paintIntoRect( *painter, legend->geometry().adjusted(-100,0,-100,0) );
00970         }
00971     }
00972 
00973     painter->translate( -translation.x(), -translation.y() );
00974 
00975     GlobalMeasureScaling::instance()->resetFactors();
00976 
00977     //qDebug() << "KDChart::Chart::paint() done.\n";
00978 }

void Chart::paintEvent QPaintEvent *  event  )  [protected]
 

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

In most cases there is no need to override this method in a derived class, but if you do, do not forget to call paint().

See also:
paint

Definition at line 1022 of file KDChartChart.cpp.

References d, and reLayoutFloatingLegends().

01023 {
01024     QPainter painter( this );
01025 
01026     if( size() != d->currentLayoutSize ){
01027         d->resizeLayout( size() );
01028         reLayoutFloatingLegends();
01029     }
01030 
01031     //FIXME(khz): Paint the background/frame too!
01032     //            (can we derive Chart from AreaWidget ??)
01033     d->paintAll( &painter );
01034 }

void Chart::reLayoutFloatingLegends  ) 
 

Definition at line 990 of file KDChartChart.cpp.

References KDChart::RelativePosition::alignment(), KDChart::RelativePosition::calculatedPoint(), d, KDChart::Legend::floatingPosition(), KDChart::Position::isFloating(), legend(), KDChart::Legend::position(), and KDChart::Legend::sizeHint().

Referenced by paintEvent(), and resizeEvent().

00991 {
00992     KDAB_FOREACH( Legend *legend, d->legends ) {
00993         const bool hidden = legend->isHidden() && legend->testAttribute(Qt::WA_WState_ExplicitShowHide);
00994         if ( legend->position().isFloating() && !hidden ){
00995             // resize the legend
00996             const QSize legendSize( legend->sizeHint() );
00997             legend->setGeometry( QRect( legend->geometry().topLeft(), legendSize ) );
00998             // find the legends corner point (reference point plus any paddings)
00999             const RelativePosition relPos( legend->floatingPosition() );
01000             QPointF pt( relPos.calculatedPoint( size() ) );
01001             qDebug() << pt;
01002             // calculate the legend's top left point
01003             const Qt::Alignment alignTopLeft = Qt::AlignBottom | Qt::AlignLeft;
01004             if( (relPos.alignment() & alignTopLeft) != alignTopLeft ){
01005                 if( relPos.alignment() & Qt::AlignRight )
01006                     pt.rx() -= legendSize.width();
01007                 else if( relPos.alignment() & Qt::AlignHCenter )
01008                     pt.rx() -= 0.5 * legendSize.width();
01009 
01010                 if( relPos.alignment() & Qt::AlignBottom )
01011                     pt.ry() -= legendSize.height();
01012                 else if( relPos.alignment() & Qt::AlignVCenter )
01013                     pt.ry() -= 0.5 * legendSize.height();
01014             }
01015             qDebug() << pt << endl;
01016             legend->move( static_cast<int>(pt.x()), static_cast<int>(pt.y()) );
01017         }
01018     }
01019 }

void Chart::replaceCoordinatePlane AbstractCoordinatePlane plane,
AbstractCoordinatePlane oldPlane = 0
 

Replaces the old coordinate plane, or appends the plane, it there is none yet.

Parameters:
plane The coordinate plane to be used instead of the old plane. This parameter must not be zero, or the method will do nothing.
oldPlane The coordinate plane to be removed by the new plane. This plane will be deleted automatically. If the parameter is omitted, the very first coordinate plane will be replaced. In case, there was no plane yet, the new plane will just be added.
Note:
If you want to re-use the old coordinate plane, call takeCoordinatePlane and addCoordinatePlane, instead of using replaceCoordinatePlane.
See also:
addCoordinatePlane, takeCoordinatePlane

Definition at line 859 of file KDChartChart.cpp.

References addCoordinatePlane(), d, and takeCoordinatePlane().

00861 {
00862     if( plane && oldPlane_ != plane ){
00863         AbstractCoordinatePlane* oldPlane = oldPlane_;
00864         if( d->coordinatePlanes.count() ){
00865             if( ! oldPlane )
00866                 oldPlane = d->coordinatePlanes.first();
00867             takeCoordinatePlane( oldPlane );
00868         }
00869         delete oldPlane;
00870         addCoordinatePlane( plane );
00871     }
00872 }

void Chart::replaceHeaderFooter HeaderFooter headerFooter,
HeaderFooter oldHeaderFooter = 0
 

Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet.

Parameters:
headerFooter The header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldHeaderFooter The header or footer to be removed by the new one. This header or footer will be deleted automatically. If the parameter is omitted, the very first header or footer will be replaced. In case, there was no header and no footer yet, the new header or footer will just be added.
Note:
If you want to re-use the old header or footer, call takeHeaderFooter and addHeaderFooter, instead of using replaceHeaderFooter.
See also:
addHeaderFooter, takeHeaderFooter

Definition at line 1047 of file KDChartChart.cpp.

References addHeaderFooter(), d, and takeHeaderFooter().

01049 {
01050     if( headerFooter && oldHeaderFooter_ != headerFooter ){
01051         HeaderFooter* oldHeaderFooter = oldHeaderFooter_;
01052         if( d->headerFooters.count() ){
01053             if( ! oldHeaderFooter )
01054                 oldHeaderFooter =  d->headerFooters.first();
01055             takeHeaderFooter( oldHeaderFooter );
01056         }
01057         delete oldHeaderFooter;
01058         addHeaderFooter( headerFooter );
01059     }
01060 }

void Chart::replaceLegend Legend legend,
Legend oldLegend = 0
 

Replaces the old legend, or appends the new legend, it there is none yet.

Parameters:
legend The legend to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldLegend The legend to be removed by the new one. This legend will be deleted automatically. If the parameter is omitted, the very first legend will be replaced. In case, there was no legend yet, the new legend will just be added.
If you want to re-use the old legend, call takeLegend and addLegend, instead of using replaceLegend.

Note:
Whenever addLegend is called the font sizes used by the Legend are set to relative and they get coupled to the Chart's size, with their relative values being 20 for the item texts and 24 to the title text. So if you want to use custom font sizes for the Legend make sure to set them after calling addLegend.
See also:
addLegend, takeLegend

Definition at line 1135 of file KDChartChart.cpp.

References addLegend(), d, and takeLegend().

01136 {
01137     if( legend && oldLegend_ != legend ){
01138         Legend* oldLegend = oldLegend_;
01139         if( d->legends.count() ){
01140             if( ! oldLegend )
01141                 oldLegend = d->legends.first();
01142             takeLegend( oldLegend );
01143         }
01144         delete oldLegend;
01145         addLegend( legend );
01146     }
01147 }

void Chart::resizeEvent QResizeEvent *  event  )  [protected]
 

Adjusts the internal layout when the chart is resized.

Definition at line 980 of file KDChartChart.cpp.

References d, reLayoutFloatingLegends(), and KDChart::AbstractCoordinatePlane::setGridNeedsRecalculate().

00981 {
00982     d->resizeLayout( size() );
00983     KDAB_FOREACH( AbstractCoordinatePlane* plane, d->coordinatePlanes ){
00984         plane->setGridNeedsRecalculate();
00985     }
00986     reLayoutFloatingLegends();
00987 }

void Chart::setBackgroundAttributes const BackgroundAttributes a  ) 
 

Specify the background attributes to be used, by default there is no background.

To set a light blue background, you could do something like this:

KDChart::BackgroundAttributes backgroundAttrs( my_chart->backgroundAttributes() ); backgroundAttrs.setVisible( true ); backgroundAttrs.setBrush( QColor(0xd0,0xd0,0xff) ); my_chart->setBackgroundAttributes( backgroundAttrs );

See also:
setFrameAttributes

Definition at line 815 of file KDChartChart.cpp.

References d.

00816 {
00817     d->backgroundAttributes = a;
00818 }

void KDChart::Chart::setCoordinatePlaneLayout QLayout *  layout  ) 
 

void Chart::setFrameAttributes const FrameAttributes a  ) 
 

Specify the frame attributes to be used, by default is it a thin black line.

To hide the frame line, you could do something like this:

KDChart::FrameAttributes frameAttrs( my_chart->frameAttributes() ); frameAttrs.setVisible( false ); my_chart->setFrameAttributes( frameAttrs );

See also:
setBackgroundAttributes

Definition at line 805 of file KDChartChart.cpp.

References d.

Referenced by Chart().

00806 {
00807     d->frameAttributes = a;
00808 }

void Chart::setGlobalLeading int  left,
int  top,
int  right,
int  bottom
 

Set the padding between the margin of the widget and the area that the contents are drawn into.

Parameters:
left The padding on the left side.
top The padding at the top.
right The padding on the left hand side.
bottom The padding on the bottom.
Note:
Using previous versions of KD Chart you might have called setGlobalLeading() to make room for long Abscissa labels (or for an overlapping top label of an Ordinate axis, resp.) that would not fit into the normal axis area. This is no longer needed because KD Chart now is using hidden auto-spacer items reserving as much free space as is needed for axes with overlaping content at the respective sides.
See also:
setGlobalLeadingTop, setGlobalLeadingBottom, setGlobalLeadingLeft, setGlobalLeadingRight

globalLeadingTop, globalLeadingBottom, globalLeadingLeft, globalLeadingRight

Definition at line 887 of file KDChartChart.cpp.

References d, setGlobalLeadingBottom(), setGlobalLeadingLeft(), setGlobalLeadingRight(), and setGlobalLeadingTop().

00888 {
00889     setGlobalLeadingLeft( left );
00890     setGlobalLeadingTop( top );
00891     setGlobalLeadingRight( right );
00892     setGlobalLeadingBottom( bottom );
00893     d->slotRelayout();
00894 }

void Chart::setGlobalLeadingBottom int  leading  ) 
 

Set the padding between the start of the widget and the start of the area that is used for drawing on the bottom.

Parameters:
leading The padding value.
See also:
setGlobalLeading

Definition at line 929 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

00930 {
00931     d->globalLeadingBottom = leading;
00932     d->slotRelayout();
00933 }

void Chart::setGlobalLeadingLeft int  leading  ) 
 

Set the padding between the start of the widget and the start of the area that is used for drawing on the left.

Parameters:
leading The padding value.
See also:
setGlobalLeading

Definition at line 896 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

00897 {
00898     d->globalLeadingLeft = leading;
00899     d->slotRelayout();
00900 }

void Chart::setGlobalLeadingRight int  leading  ) 
 

Set the padding between the start of the widget and the start of the area that is used for drawing on the right.

Parameters:
leading The padding value.
See also:
setGlobalLeading

Definition at line 918 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

00919 {
00920     d->globalLeadingRight = leading;
00921     d->slotRelayout();
00922 }

void Chart::setGlobalLeadingTop int  leading  ) 
 

Set the padding between the start of the widget and the start of the area that is used for drawing at the top.

Parameters:
leading The padding value.
See also:
setGlobalLeading

Definition at line 907 of file KDChartChart.cpp.

References d.

Referenced by setGlobalLeading().

00908 {
00909     d->globalLeadingTop = leading;
00910     d->slotRelayout();
00911 }

void Chart::takeCoordinatePlane AbstractCoordinatePlane plane  ) 
 

Removes the coordinate plane from the chart, without deleting it.

The chart no longer owns the plane, so it is the caller's responsibility to delete the plane.

See also:
addCoordinatePlane, takeCoordinatePlane

Definition at line 874 of file KDChartChart.cpp.

References d, KDChart::AbstractLayoutItem::removeFromParentLayout(), and KDChart::AbstractCoordinatePlane::setParent().

Referenced by replaceCoordinatePlane().

00875 {
00876     const int idx = d->coordinatePlanes.indexOf( plane );
00877     if( idx != -1 ){
00878         d->coordinatePlanes.takeAt( idx );
00879         disconnect( plane, SIGNAL( destroyedCoordinatePlane( AbstractCoordinatePlane* ) ),
00880                     d, SLOT( slotUnregisterDestroyedPlane( AbstractCoordinatePlane* ) ) );
00881         plane->removeFromParentLayout();
00882         plane->setParent( 0 );
00883     }
00884     d->slotLayoutPlanes();
00885 }

void Chart::takeHeaderFooter HeaderFooter headerFooter  ) 
 

Removes the header (or footer, resp.) from the chart, without deleting it.

The chart no longer owns the header or footer, so it is the caller's responsibility to delete the header or footer.

See also:
addHeaderFooter, replaceHeaderFooter

Definition at line 1062 of file KDChartChart.cpp.

References d, and KDChart::HeaderFooter::setParent().

Referenced by replaceHeaderFooter().

01063 {
01064     const int idx = d->headerFooters.indexOf( headerFooter );
01065     if( idx != -1 ){
01066         d->headerFooters.takeAt( idx );
01067         disconnect( headerFooter, SIGNAL( destroyedHeaderFooter( HeaderFooter* ) ),
01068                     d, SLOT( slotUnregisterDestroyedHeaderFooter( HeaderFooter* ) ) );
01069         headerFooter->setParent( 0 );
01070     }
01071     d->slotRelayout();
01072 }

void Chart::takeLegend Legend legend  ) 
 

Removes the legend from the chart, without deleting it.

The chart no longer owns the legend, so it is the caller's responsibility to delete the legend.

See also:
addLegend, takeLegend

Definition at line 1149 of file KDChartChart.cpp.

References d.

Referenced by replaceLegend().

01150 {
01151     const int idx = d->legends.indexOf( legend );
01152     if( idx != -1 ){
01153         d->legends.takeAt( idx );
01154         disconnect( legend, SIGNAL( destroyedLegend( Legend* ) ),
01155                     d, SLOT( slotUnregisterDestroyedLegend( Legend* ) ) );
01156         legend->setParent( 0 );
01157     }
01158     d->slotRelayout();
01159 }


Member Data Documentation

Q_SIGNALS KDChart::Chart::__pad0__
 

Definition at line 396 of file KDChartChart.h.


The documentation for this class was generated from the following files:
Generated on Thu May 10 11:06:32 2007 for KD Chart 2 by doxygen 1.3.6