KD Chart API Documentation 3.0
Loading...
Searching...
No Matches
KDChartAbstractDiagram.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#ifndef KDCHARTABSTRACTDIAGRAM_H
12#define KDCHARTABSTRACTDIAGRAM_H
13
14#include <QAbstractItemView>
15#include <QList>
16#include <QRectF>
17
19#include "KDChartGlobal.h"
21
22namespace KDChart {
23
24class AbstractCoordinatePlane;
25class AttributesModel;
26class DataValueAttributes;
27class PaintContext;
28
38class KDCHART_EXPORT AbstractDiagram : public QAbstractItemView
39{
40 Q_OBJECT
41 Q_DISABLE_COPY(AbstractDiagram)
43
47
48protected:
49 explicit inline AbstractDiagram(
50 Private *p, QWidget *parent, AbstractCoordinatePlane *plane);
51 explicit AbstractDiagram(
52 QWidget *parent = nullptr, AbstractCoordinatePlane *plane = nullptr);
53
54public:
55 ~AbstractDiagram() override;
56
60 bool compare(const AbstractDiagram *other) const;
61
76 const QPair<QPointF, QPointF> dataBoundaries() const;
77
78 // protected: // FIXME: why should that be private? (Mirko)
85 virtual void paint(PaintContext *paintContext) = 0;
86
93 virtual void resize(const QSizeF &area) = 0;
94
96 void setModel(QAbstractItemModel *model) override;
97
99 void setSelectionModel(QItemSelectionModel *selectionModel) override;
100
129 virtual void setAttributesModel(AttributesModel *model);
130
137 virtual bool usesExternalAttributesModel() const;
138
149 virtual AttributesModel *attributesModel() const;
150
153 void setRootIndex(const QModelIndex &idx) override;
154
156 QRect visualRect(const QModelIndex &index) const override;
158 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
160 QModelIndex indexAt(const QPoint &point) const override;
162 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
164 int horizontalOffset() const override;
166 int verticalOffset() const override;
168 bool isIndexHidden(const QModelIndex &index) const override;
170 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
172 QRegion visualRegionForSelection(const QItemSelection &selection) const override;
173 virtual QRegion visualRegion(const QModelIndex &index) const;
175 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
177 void doItemsLayout() override;
178
185 AbstractCoordinatePlane *coordinatePlane() const;
186
192 virtual void setCoordinatePlane(AbstractCoordinatePlane *plane);
193
207 void setHidden(const QModelIndex &index, bool hidden);
208
221 void setHidden(int dataset, bool hidden);
222
234 void setHidden(bool hidden);
235
242 bool isHidden() const;
243
251 bool isHidden(int dataset) const;
252
260 bool isHidden(const QModelIndex &index) const;
261
268 void setDataValueAttributes(const QModelIndex &index,
269 const DataValueAttributes &a);
270
276 void setDataValueAttributes(int dataset, const DataValueAttributes &a);
277
282 void setDataValueAttributes(const DataValueAttributes &a);
283
290 DataValueAttributes dataValueAttributes() const;
291
299 DataValueAttributes dataValueAttributes(int dataset) const;
300
309 DataValueAttributes dataValueAttributes(const QModelIndex &index) const;
310
317 void setPen(const QModelIndex &index, const QPen &pen);
318
324 void setPen(int dataset, const QPen &pen);
325
330 void setPen(const QPen &pen);
331
338 QPen pen() const;
346 QPen pen(int dataset) const;
354 QPen pen(const QModelIndex &index) const;
355
362 void setBrush(const QModelIndex &index, const QBrush &brush);
363
369 void setBrush(int dataset, const QBrush &brush);
370
375 void setBrush(const QBrush &brush);
376
383 QBrush brush() const;
391 QBrush brush(int dataset) const;
399 QBrush brush(const QModelIndex &index) const;
400
407 void setUnitPrefix(const QString &prefix, int column, Qt::Orientation orientation);
413 void setUnitPrefix(const QString &prefix, Qt::Orientation orientation);
414
421 void setUnitSuffix(const QString &suffix, int column, Qt::Orientation orientation);
427 void setUnitSuffix(const QString &suffix, Qt::Orientation orientation);
428
437 QString unitPrefix(int column, Qt::Orientation orientation, bool fallback = false) const;
443 QString unitPrefix(Qt::Orientation orientation) const;
444
453 QString unitSuffix(int column, Qt::Orientation orientation, bool fallback = false) const;
459 QString unitSuffix(Qt::Orientation orientation) const;
460
465 void setAllowOverlappingDataValueTexts(bool allow);
466
470 bool allowOverlappingDataValueTexts() const;
471
477 void setAntiAliasing(bool enabled);
478
483 bool antiAliasing() const;
484
491 void useDefaultColors();
492
498 void useRainbowColors();
499
505 void useSubduedColors();
506
511 QStringList itemRowLabels() const;
512
517 QStringList datasetLabels() const;
518
528 QList<QBrush> datasetBrushes() const;
529
539 QList<QPen> datasetPens() const;
540
550 QList<MarkerAttributes> datasetMarkers() const;
551
562 Q_DECL_DEPRECATED void setPercentMode(bool percent);
563
575 bool percentMode() const;
576
577 virtual void paintMarker(QPainter *painter,
578 const MarkerAttributes &markerAttributes,
579 const QBrush &brush, const QPen &,
580 const QPointF &point, const QSizeF &size);
581
596 int datasetDimension() const;
597
604 Q_DECL_DEPRECATED void setDatasetDimension(int dimension);
605
606protected:
607 void setDatasetDimensionInternal(int dimension);
608
609public:
610 void update() const;
611
612 void paintMarker(QPainter *painter, const DataValueAttributes &a,
613 const QModelIndex &index,
614 const QPointF &pos);
615 void paintMarker(QPainter *painter,
616 const QModelIndex &index,
617 const QPointF &pos);
618 void paintDataValueText(QPainter *painter, const QModelIndex &index,
619 const QPointF &pos, qreal value);
620
621 // reverse mapping:
625 QModelIndexList indexesAt(const QPoint &point) const;
626 QModelIndexList indexesIn(const QRect &rect) const;
627
628protected:
629 virtual bool checkInvariants(bool justReturnTheStatus = false) const;
630 virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const = 0;
631
632protected Q_SLOTS:
633 void setDataBoundariesDirty() const;
634
635protected:
643 Q_DECL_DEPRECATED virtual void paintDataValueTexts(QPainter *painter);
651 Q_DECL_DEPRECATED virtual void paintMarkers(QPainter *painter);
652 void setAttributesModelRootIndex(const QModelIndex &);
653 QModelIndex attributesModelRootIndex() const;
654
662 Q_DECL_DEPRECATED qreal valueForCell(int row, int column) const;
663
664Q_SIGNALS:
673 void layoutChanged(AbstractDiagram *);
674
679 void aboutToBeDestroyed();
680
682 void modelsChanged();
683
686 void attributesModelAboutToChange(AttributesModel *newModel, AttributesModel *oldModel);
687
689 void modelDataChanged();
690
692 void dataHidden();
693
695 void propertiesChanged();
696
698 void boundariesChanged();
700 void viewportCoordinateSystemChanged();
701
702private:
703 QModelIndex conditionallyMapFromSource(const QModelIndex &sourceIndex) const;
704};
705
708
713{
714 Q_OBJECT
715public:
716 explicit PrivateAttributesModel(QAbstractItemModel *model, QObject *parent = nullptr)
717 : AttributesModel(model, parent)
718 {
719 }
720};
721}
722
723#endif
Contains KDChart macros.
#define KDCHART_DECLARE_PRIVATE_BASE_POLYMORPHIC(X)
Base class common for all coordinate planes, CartesianCoordinatePlane, PolarCoordinatePlane,...
AbstractDiagram defines the interface for diagram classes.
A proxy model used for decorating data with attributes.
Diagram attributes dealing with data value labels.
A set of attributes controlling the appearance of data set markers.
Stores information about painting diagrams.
Internally used class just adding a special constructor used by AbstractDiagram.
PrivateAttributesModel(QAbstractItemModel *model, QObject *parent=nullptr)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Fri Feb 23 2024 00:02:58 for KD Chart API Documentation by doxygen 1.9.8