12 #include "KDChartPlotter_p.h"
15 #include "KDChartPainterSaver_p.h"
17 #include <KDABLibFakes>
19 #include "KDChartNormalPlotter_p.h"
20 #include "KDChartPercentPlotter_p.h"
24 Plotter::Private::Private()
28 Plotter::Private::~Private()
31 delete percentPlotter;
45 d->normalPlotter =
new NormalPlotter(
this);
46 d->percentPlotter =
new PercentPlotter(
this);
47 d->implementor =
d->normalPlotter;
48 Private *test =
d->implementor->plotterPrivate();
68 auto *newDiagram =
new Plotter(
new Private(*
d));
69 newDiagram->setType(
type());
92 d->plotterCompressor.setModel(
nullptr);
95 d->compressor.setModel(
nullptr);
112 return d->implementor->useCompression();
118 d->implementor->setUseCompression(value);
120 d->compressor.setModel(
nullptr);
129 return d->plotterCompressor.maxSlopeChange();
134 d->plotterCompressor.setMaxSlopeChange(value);
139 return d->mergeRadiusPercentage;
144 if (
d->mergeRadiusPercentage != value) {
145 d->mergeRadiusPercentage = value;
156 if (
d->implementor->type() ==
type) {
160 Q_ASSERT_X(
false,
"setType()",
161 "This line chart type can only be used with two-dimensional data.");
166 d->implementor =
d->normalPlotter;
169 d->implementor =
d->percentPlotter;
172 Q_ASSERT_X(
false,
"Plotter::setType",
"unknown plotter subtype");
175 d->implementor->plotterPrivate(), &KDChart::Plotter::Private::changedProperties);
176 Q_ASSERT(connection);
177 Q_UNUSED(connection);
180 Q_ASSERT(
d->implementor->type() ==
type);
192 return d->implementor->type();
227 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
237 d->attributesModel->resetData(
266 return d->attributesModel->data(
297 d->attributesModel->setData(
d->attributesModel->mapFromSource(index), QVariant::fromValue(la),
316 if (attrs.isValid()) {
327 return d->attributesModel->data(
347 d->attributesModel->setData(
d->attributesModel->mapFromSource(index),
357 return d->attributesModel->data(
369 return QPair<QPointF, QPointF>(QPointF(0, 0), QPointF(0, 0));
376 return d->implementor->calculateDataBoundaries();
381 QPainter painter(viewport());
398 d->setCompressorResolution(size(), plane);
403 const PainterSaver p(ctx->
painter());
404 if (model()->rowCount(rootIndex()) == 0 || model()->columnCount(rootIndex()) == 0)
410 d->implementor->paint(ctx);
419 d->plotterCompressor.cleanCache();
423 QAbstractItemView::resize(size.toSize());
440 QRectF range = plane->visibleDataRange();
442 const qreal radius = std::sqrt((range.x() + range.width()) * (range.y() + range.height()));
446 d->plotterCompressor.setMergeRadius(radius *
d->mergeRadiusPercentage);
449 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_COMPILER_MANGLES_RETURN_TYPE)
458 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_COMPILER_MANGLES_RETURN_TYPE)
Base class for diagrams based on a cartesian coordianate system.
void connectAttributesModel(AttributesModel *)
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
virtual AbstractCoordinatePlane * sharedAxisMasterPlane(QPainter *p=nullptr)
void internal_geometryChanged(QRect, QRect)
void geometryChanged(QRect, QRect)
virtual AttributesModel * attributesModel() const
virtual bool checkInvariants(bool justReturnTheStatus=false) const
void layoutChanged(AbstractDiagram *)
QModelIndex attributesModelRootIndex() const
returns a QModelIndex pointing into the AttributesModel that corresponds to the root index of the dia...
const QPair< QPointF, QPointF > dataBoundaries() const
Return the bottom left and top right data point, that the diagram will display (unless the grid adjus...
AbstractCoordinatePlane * coordinatePlane() const
void setDataBoundariesDirty() const
int datasetDimension() const
void attributesModelAboutToChange(AttributesModel *newModel, AttributesModel *oldModel)
void setDatasetDimensionInternal(int dimension)
static bool isBoundariesValid(const QRectF &r)
A proxy model used for decorating data with attributes.
Cartesian coordinate plane.
Set of attributes for changing the appearance of line charts.
Stores information about painting diagrams.
void setPainter(QPainter *painter)
void setCoordinatePlane(AbstractCoordinatePlane *plane)
void setRectangle(const QRectF &rect)
AbstractCoordinatePlane * coordinatePlane() const
QPainter * painter() const
Plotter defines a diagram type plotting two-dimensional data.
bool compare(const Plotter *other) const
void paintEvent(QPaintEvent *) override
void setType(const PlotType type)
int numberOfAbscissaSegments() const override
void resizeEvent(QResizeEvent *) override
Plotter(QWidget *parent=nullptr, CartesianCoordinatePlane *plane=nullptr)
void resize(const QSizeF &area) override
virtual Plotter * clone() const
ThreeDLineAttributes threeDLineAttributes() const
void paint(PaintContext *paintContext) override
void setLineAttributes(const LineAttributes &a)
void resetLineAttributes(int column)
void setThreeDLineAttributes(const ThreeDLineAttributes &a)
void setMaxSlopeChange(qreal value)
LineAttributes lineAttributes() const
void setUseDataCompression(CompressionMode value)
void setDataBoundariesDirty()
qreal maxSlopeChange() const
CompressionMode useDataCompression
const QPair< QPointF, QPointF > calculateDataBoundaries() const override
void setMergeRadiusPercentage(qreal value)
qreal mergeRadiusPercentage
int numberOfOrdinateSegments() const override
void connectAttributesModel(AttributesModel *)
qreal threeDItemDepth(const QModelIndex &index) const override
ValueTrackerAttributes valueTrackerAttributes(const QModelIndex &index) const
void setValueTrackerAttributes(const QModelIndex &index, const ValueTrackerAttributes &a)
A set of 3D line attributes.
Cell-specific attributes regarding value tracking.
@ ThreeDLineAttributesRole
@ ValueTrackerAttributesRole