 |
KD Chart 2
[rev.2.7]
|
Go to the documentation of this file.
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)
int datasetDimension() const
The dataset dimension of a diagram determines how many value dimensions it expects each datapoint to ...
void setLineAttributes(const LineAttributes &a)
Sets the global line attributes to la.
Plotter defines a diagram type plotting two-dimensional data.
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=0)
qreal maxSlopeChange() const
void connectAttributesModel(AttributesModel *)
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...
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 layoutChanged(AbstractDiagram *)
Diagrams are supposed to emit this signal, when the layout of one of their element changes.
qreal threeDItemDepth(const QModelIndex &index) const override
void setType(const PlotType type)
Sets the plotter's type to type.
virtual Plotter * clone() const
Creates an exact copy of this diagram.
AbstractCoordinatePlane * coordinatePlane() const
void setPainter(QPainter *painter)
void setMergeRadiusPercentage(qreal value)
void setDataBoundariesDirty()
void setDataBoundariesDirty() const
void setDatasetDimensionInternal(int dimension)
Stores information about painting diagrams.
void setUseDataCompression(CompressionMode value)
void setMaxSlopeChange(qreal value)
@ ValueTrackerAttributesRole
Plotter(QWidget *parent=0, CartesianCoordinatePlane *plane=0)
void connectAttributesModel(AttributesModel *)
QPainter * painter() const
const int numberOfOrdinateSegments() const
void paintEvent(QPaintEvent *) override
LineAttributes lineAttributes() const
void resize(const QSizeF &area) override
Called by the widget's sizeEvent.
@ ThreeDLineAttributesRole
A set of 3D line attributes.
void resetLineAttributes(int column)
Resets the line attributes of data set column.
qreal mergeRadiusPercentage
Base class for diagrams based on a cartesian coordianate system.
void setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
Sets the value tracker attributes of the model index index to va.
Cell-specific attributes regarding value tracking.
QRectF visibleDataRange() const
Returns the currently visible data range.
void resizeEvent(QResizeEvent *) override
void boundariesChanged()
Emitted upon change of a data boundary.
A proxy model used for decorating data with attributes.
virtual AttributesModel * attributesModel() const
Returns the AttributesModel, that is used by this diagram.
void attributesModelAboutToChange(AttributesModel *newModel, AttributesModel *oldModel)
This signal is emitted just before the new attributes model is connected internally.
Set of attributes for changing the appearance of line charts.
const int numberOfAbscissaSegments() const
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
[reimplemented]
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
Sets the global 3D line attributes to la.
void setCoordinatePlane(AbstractCoordinatePlane *plane)
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
Returns the value tracker attributes of the model index index.
QModelIndex attributesModelRootIndex() const
ThreeDLineAttributes threeDLineAttributes() const
void setRectangle(const QRectF &rect)
void propertiesChanged()
Emitted upon change of a property of the Diagram.
Cartesian coordinate plane.
virtual bool checkInvariants(bool justReturnTheStatus=false) const
CompressionMode useDataCompression
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
bool compare(const Plotter *other) const
Returns true if both diagrams have the same settings.