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 );
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) void setLineAttributes(const LineAttributes &a)
Sets the global line attributes to la.
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
void setPainter(QPainter *painter)
void setType(const LineType type)
Sets the line diagram's type to type.
void setDataBoundariesDirty() const
virtual bool checkInvariants(bool justReturnTheStatus=false) const
void resetLineAttributes(int column)
Resets the line attributes of data set column.
AbstractCoordinatePlane * coordinatePlane() const
LineDiagram(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
const int numberOfAbscissaSegments() const
void setPercentMode(bool percent)
Deprecated method that turns the percent mode of this diagram on or off.
QPainter * painter() const
void setReverseDatasetOrder(bool reverse)
With this property set to true, data sets in a normal line diagram are drawn in reversed order...
void paint(PaintContext *paintContext) override
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
void setLineTension(qreal tenson)
This property defines the strength of the line curvature - 0 for straight lines between data points...
qreal lineTension() const
Returns whether the lines are drawn smoothed.
ThreeDLineAttributes threeDLineAttributes() const
Set of attributes for changing the appearance of line charts.
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
Returns the value tracker attributes of the model index index.
void resizeEvent(QResizeEvent *) override
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
void paintEvent(QPaintEvent *) override
void propertiesChanged()
Emitted upon change of a property of the Diagram.
LineDiagram defines a common line diagram.
Cell-specific attributes regarding value tracking.
Base class for diagrams based on a cartesian coordianate system.
Stores information about painting diagrams.
virtual LineDiagram * clone() const
Creates an exact copy of this diagram.
virtual qreal zoomFactorY() const
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.
QModelIndex attributesModelRootIndex() const
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
LineAttributes lineAttributes() const
Cartesian coordinate plane.
void setCenterDataPoints(bool center)
If centerDataPoints() is true, all data points are moved by an offset of 0.5 to the right...
void setCoordinatePlane(AbstractCoordinatePlane *plane)
void setRectangle(const QRectF &rect)
bool reverseDatasetOrder() const
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
bool centerDataPoints() const
const int numberOfOrdinateSegments() const
void setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
Sets the value tracker attributes of the model index index to va.
virtual qreal zoomFactorX() const
qreal threeDItemDepth(const QModelIndex &index) const override
A set of 3D line attributes.
bool compare(const LineDiagram *other) const
Returns true if both diagrams have the same settings.