24 #include "KDChartPlotter_p.h" 26 #include "KDChartAbstractGrid.h" 27 #include "KDChartPainterSaver_p.h" 29 #include <KDABLibFakes> 31 #include "KDChartNormalPlotter_p.h" 32 #include "KDChartPercentPlotter_p.h" 36 Plotter::Private::Private()
43 Plotter::Private::~Private()
46 delete percentPlotter;
62 d->normalPlotter =
new NormalPlotter(
this );
63 d->percentPlotter =
new PercentPlotter(
this );
64 d->implementor =
d->normalPlotter;
65 QObject* test =
d->implementor->plotterPrivate();
66 connect(
this, SIGNAL(
boundariesChanged() ), test, SLOT( changedProperties() ) );
110 d->plotterCompressor.setModel( 0 );
115 d->compressor.setModel( 0 );
122 connect(
coordinatePlane(), SIGNAL( internal_geometryChanged( QRect,QRect ) ),
134 return d->implementor->useCompression();
141 d->implementor->setUseCompression( value );
144 d->compressor.setModel( NULL );
153 return d->plotterCompressor.maxSlopeChange();
158 d->plotterCompressor.setMaxSlopeChange( value );
163 return d->mergeRadiusPercentage;
168 if (
d->mergeRadiusPercentage != value )
170 d->mergeRadiusPercentage = value;
181 if (
d->implementor->type() ==
type ) {
185 Q_ASSERT_X (
false,
"setType()",
186 "This line chart type can only be used with two-dimensional data." );
191 d->implementor =
d->normalPlotter;
194 d->implementor =
d->percentPlotter;
197 Q_ASSERT_X(
false,
"Plotter::setType",
"unknown plotter subtype" );
200 d->implementor->plotterPrivate(), SLOT( changedProperties() ) );
201 Q_ASSERT( connection );
202 Q_UNUSED( connection );
205 Q_ASSERT(
d->implementor->type() ==
type );
217 return d->implementor->type();
252 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ),
262 d->attributesModel->resetData(
281 if ( attrs.isValid() )
291 return d->attributesModel->data(
321 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ), qVariantFromValue( la ),
340 if ( attrs.isValid() ) {
351 return d->attributesModel->data(
370 d->attributesModel->setData(
d->attributesModel->mapFromSource( index ),
380 return d->attributesModel->data(
398 return d->implementor->calculateDataBoundaries();
404 QPainter painter ( viewport() );
407 ctx.
setRectangle ( QRectF ( 0, 0, width(), height() ) );
418 if ( ! plane )
return;
419 d->setCompressorResolution( size(), plane );
423 const PainterSaver p( ctx->
painter() );
424 if ( model()->rowCount( rootIndex() ) == 0 || model()->columnCount( rootIndex() ) == 0 )
430 d->implementor->paint( ctx );
440 d->plotterCompressor.cleanCache();
444 QAbstractItemView::resize( size.toSize() );
464 const qreal radius = std::sqrt( ( range.x() + range.width() ) * ( range.y() + range.height() ) );
468 d->plotterCompressor.setMergeRadius( radius *
d->mergeRadiusPercentage );
471 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE) 479 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE) Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane, TernaryCoordinatePlane.
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
qreal maxSlopeChange() const
void setPainter(QPainter *painter)
void setDataBoundariesDirty() const
void connectAttributesModel(AttributesModel *)
virtual bool checkInvariants(bool justReturnTheStatus=false) const
AbstractCoordinatePlane * coordinatePlane() const
QPainter * painter() const
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
AbstractCoordinatePlane * coordinatePlane() const
The coordinate plane associated with the diagram.
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 setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
Sets the value tracker attributes of the model index index to va.
virtual Plotter * clone() const
Creates an exact copy of this diagram.
Plotter(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
void setDataBoundariesDirty()
void setDatasetDimensionInternal(int dimension)
Plotter defines a diagram type plotting two-dimensional data.
ThreeDLineAttributes threeDLineAttributes() const
void setMergeRadiusPercentage(qreal value)
Set of attributes for changing the appearance of line charts.
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 connectAttributesModel(AttributesModel *)
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
Sets the global 3D line attributes to la.
void setType(const PlotType type)
Sets the plotter's type to type.
bool compare(const Plotter *other) const
Returns true if both diagrams have the same settings.
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
void resetLineAttributes(int column)
Resets the line attributes of data set column.
qreal threeDItemDepth(const QModelIndex &index) const override
void propertiesChanged()
Emitted upon change of a property of the Diagram.
A proxy model used for decorating data with attributes.
void paintEvent(QPaintEvent *) override
LineAttributes lineAttributes() const
Cell-specific attributes regarding value tracking.
void setMaxSlopeChange(qreal value)
Base class for diagrams based on a cartesian coordianate system.
Stores information about painting diagrams.
void setUseDataCompression(CompressionMode value)
void resizeEvent(QResizeEvent *) override
const int numberOfOrdinateSegments() const
void layoutChanged(AbstractDiagram *)
Diagrams are supposed to emit this signal, when the layout of one of their element changes...
const int numberOfAbscissaSegments() const
QModelIndex attributesModelRootIndex() const
qreal mergeRadiusPercentage() const
Class only listed here to document inheritance of some KDChart classes.
Cartesian coordinate plane.
void boundariesChanged()
Emitted upon change of a data boundary.
void setCoordinatePlane(AbstractCoordinatePlane *plane)
void setLineAttributes(const LineAttributes &a)
Sets the global line attributes to la.
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
void setRectangle(const QRectF &rect)
void attributesModelAboutToChange(AttributesModel *newModel, AttributesModel *oldModel)
This signal is emitted just before the new attributes model is connected internally.
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
Returns the value tracker attributes of the model index index.
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
QRectF visibleDataRange() const
Returns the currently visible data range.
CompressionMode useDataCompression() const
A set of 3D line attributes.