 |
KD Chart 2
[rev.2.7]
|
Go to the documentation of this file.
24 #include "KDChartLineDiagram_p.h"
29 #include "KDChartAbstractGrid.h"
30 #include "KDChartPainterSaver_p.h"
32 #include <KDABLibFakes>
34 #include "KDChartNormalLineDiagram_p.h"
35 #include "KDChartStackedLineDiagram_p.h"
36 #include "KDChartPercentLineDiagram_p.h"
41 #include <QPainterPath>
47 LineDiagram::Private::Private()
52 LineDiagram::Private::~Private() {}
64 void LineDiagram::init()
66 d->normalDiagram =
new NormalLineDiagram(
this );
67 d->stackedDiagram =
new StackedLineDiagram(
this );
68 d->percentDiagram =
new PercentLineDiagram(
this );
69 d->implementor =
d->normalDiagram;
70 d->centerDataPoints =
false;
71 d->reverseDatasetOrder =
false;
76 delete d->normalDiagram;
77 delete d->stackedDiagram;
78 delete d->percentDiagram;
94 if ( other ==
this )
return true;
112 if (
d->implementor->type() ==
type )
return;
114 Q_ASSERT_X (
false,
"setType()",
115 "This line chart type can't be used with multi-dimensional data." );
120 d->implementor =
d->normalDiagram;
123 d->implementor =
d->stackedDiagram;
126 d->implementor =
d->percentDiagram;
129 Q_ASSERT_X(
false,
"LineDiagram::setType",
"unknown diagram subtype" );
133 Q_ASSERT(
d->implementor->type() ==
type );
147 return d->implementor->type();
152 if (
d->centerDataPoints == center ) {
156 d->centerDataPoints = center;
167 return d->centerDataPoints;
172 d->reverseDatasetOrder = reverse;
177 return d->reverseDatasetOrder;
185 d->attributesModel->setModelData(
186 qVariantFromValue( la ),
215 const QModelIndex& index,
218 d->attributesModel->setData(
219 d->attributesModel->mapFromSource(index),
220 qVariantFromValue( la ),
230 d->attributesModel->resetData(
249 if ( attrs.isValid() )
258 const QModelIndex& index )
const
260 return d->attributesModel->data(
261 d->attributesModel->mapFromSource(index),
272 d->attributesModel->setModelData(
273 qVariantFromValue( la ),
294 const QModelIndex & index,
298 d->attributesModel->setData(
299 d->attributesModel->mapFromSource(index),
300 qVariantFromValue( la ),
319 if ( attrs.isValid() )
329 return d->attributesModel->data(
330 d->attributesModel->mapFromSource( index ),
350 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
351 qVariantFromValue( va ),
360 const QModelIndex & index )
const
362 return d->attributesModel->data(
363 d->attributesModel->mapFromSource( index ),
379 d->tension = tension;
391 d->compressor.setResolution(
static_cast<int>( this->size().width() *
coordinatePlane()->zoomFactorX() ),
392 static_cast<int>( this->size().height() *
coordinatePlane()->zoomFactorY() ) );
401 return d->implementor->calculateDataBoundaries();
407 QPainter painter ( viewport() );
410 ctx.
setRectangle ( QRectF ( 0, 0, width(), height() ) );
420 const PainterSaver p( ctx->
painter() );
421 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
429 d->implementor->paint( ctx );
436 d->compressor.setResolution(
static_cast<int>( size.width() *
coordinatePlane()->zoomFactorX() ),
437 static_cast<int>( size.height() *
coordinatePlane()->zoomFactorY() ) );
439 QAbstractItemView::resize( size.toSize() );
442 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
450 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
void setType(const LineType type)
Sets the line diagram's type to type.
void paintEvent(QPaintEvent *) override
LineDiagram(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
const int numberOfAbscissaSegments() const
void resizeEvent(QResizeEvent *) override
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
qreal threeDItemDepth(const QModelIndex &index) const override
void layoutChanged(AbstractDiagram *)
Diagrams are supposed to emit this signal, when the layout of one of their element changes.
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
Sets the global 3D line attributes to la.
AbstractCoordinatePlane * coordinatePlane() const
void setPainter(QPainter *painter)
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
qreal lineTension() const
Returns whether the lines are drawn smoothed.
void setDataBoundariesDirty() const
Stores information about painting diagrams.
LineDiagram defines a common line diagram.
void setReverseDatasetOrder(bool reverse)
With this property set to true, data sets in a normal line diagram are drawn in reversed order.
@ ValueTrackerAttributesRole
ThreeDLineAttributes threeDLineAttributes() const
QPainter * painter() const
void setCenterDataPoints(bool center)
If centerDataPoints() is true, all data points are moved by an offset of 0.5 to the right.
void setPercentMode(bool percent)
Deprecated method that turns the percent mode of this diagram on or off.
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
@ ThreeDLineAttributesRole
A set of 3D line attributes.
Base class for diagrams based on a cartesian coordianate system.
Cell-specific attributes regarding value tracking.
bool reverseDatasetOrder() const
bool compare(const LineDiagram *other) const
Returns true if both diagrams have the same settings.
Set of attributes for changing the appearance of line charts.
bool centerDataPoints() const
void setCoordinatePlane(AbstractCoordinatePlane *plane)
QModelIndex attributesModelRootIndex() const
void setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
Sets the value tracker attributes of the model index index to va.
virtual LineDiagram * clone() const
Creates an exact copy of this diagram.
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
Returns the value tracker attributes of the model index index.
LineAttributes lineAttributes() const
void setRectangle(const QRectF &rect)
void setLineTension(qreal tenson)
This property defines the strength of the line curvature - 0 for straight lines between data points,...
void propertiesChanged()
Emitted upon change of a property of the Diagram.
Cartesian coordinate plane.
void resetLineAttributes(int column)
Resets the line attributes of data set column.
virtual bool checkInvariants(bool justReturnTheStatus=false) const
const int numberOfOrdinateSegments() const
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
void setLineAttributes(const LineAttributes &a)
Sets the global line attributes to la.