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()
51 LineDiagram::Private::~Private() {}
63 void LineDiagram::init()
65 d->normalDiagram =
new NormalLineDiagram(
this );
66 d->stackedDiagram =
new StackedLineDiagram(
this );
67 d->percentDiagram =
new PercentLineDiagram(
this );
68 d->implementor =
d->normalDiagram;
69 d->centerDataPoints =
false;
70 d->reverseDatasetOrder =
false;
75 delete d->normalDiagram;
76 delete d->stackedDiagram;
77 delete d->percentDiagram;
93 if ( other ==
this )
return true;
111 if (
d->implementor->type() ==
type )
return;
113 Q_ASSERT_X (
false,
"setType()",
114 "This line chart type can't be used with multi-dimensional data." );
119 d->implementor =
d->normalDiagram;
122 d->implementor =
d->stackedDiagram;
125 d->implementor =
d->percentDiagram;
128 Q_ASSERT_X(
false,
"LineDiagram::setType",
"unknown diagram subtype" );
132 Q_ASSERT(
d->implementor->type() ==
type );
146 return d->implementor->type();
151 if (
d->centerDataPoints == center ) {
155 d->centerDataPoints = center;
166 return d->centerDataPoints;
171 d->reverseDatasetOrder = reverse;
176 return d->reverseDatasetOrder;
184 d->attributesModel->setModelData(
185 qVariantFromValue( la ),
214 const QModelIndex& index,
217 d->attributesModel->setData(
218 d->attributesModel->mapFromSource(index),
219 qVariantFromValue( la ),
229 d->attributesModel->resetData(
248 if ( attrs.isValid() )
257 const QModelIndex& index )
const 259 return d->attributesModel->data(
260 d->attributesModel->mapFromSource(index),
271 d->attributesModel->setModelData(
272 qVariantFromValue( la ),
293 const QModelIndex & index,
297 d->attributesModel->setData(
298 d->attributesModel->mapFromSource(index),
299 qVariantFromValue( la ),
318 if ( attrs.isValid() )
328 return d->attributesModel->data(
329 d->attributesModel->mapFromSource( index ),
349 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
350 qVariantFromValue( va ),
359 const QModelIndex & index )
const 361 return d->attributesModel->data(
362 d->attributesModel->mapFromSource( index ),
372 d->compressor.setResolution( static_cast<int>( this->size().width() *
coordinatePlane()->zoomFactorX() ),
373 static_cast<int>( this->size().height() *
coordinatePlane()->zoomFactorY() ) );
382 return d->implementor->calculateDataBoundaries();
388 QPainter painter ( viewport() );
391 ctx.
setRectangle ( QRectF ( 0, 0, width(), height() ) );
401 const PainterSaver p( ctx->
painter() );
402 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
410 d->implementor->paint( ctx );
420 QAbstractItemView::resize( size.toSize() );
423 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE) 431 #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...
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
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.
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 resizeEvent(QResizeEvent *)
void propertiesChanged()
Emitted upon change of a property of the Diagram.
LineDiagram defines a common line diagram.
Cell-specific attributes regarding value tracking.
void resize(const QSizeF &area)
Called by the widget's sizeEvent.
Base class for diagrams based on a cartesian coordianate system.
Stores information about painting diagrams.
virtual qreal threeDItemDepth(const QModelIndex &index) const
void paintEvent(QPaintEvent *)
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 paint(PaintContext *paintContext)
Draw the diagram contents to the rectangle and painter, that are passed in as part of the paint conte...
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
Sets the global 3D line attributes to la.
QModelIndex attributesModelRootIndex() const
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
virtual const QPair< QPointF, QPointF > calculateDataBoundaries() const
[reimplemented]
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
A set of 3D line attributes.
bool compare(const LineDiagram *other) const
Returns true if both diagrams have the same settings.