chartaxiselement_p.h
176 lines
| 7.0 KiB
| text/x-c
|
CLexer
|
r2854 | /**************************************************************************** | ||
|
r2483 | ** | ||
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
|
r2483 | ** | ||
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
|
r2483 | ** | ||
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
|
r2483 | ** | ||
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
|
r2854 | ****************************************************************************/ | ||
|
r2483 | |||
// W A R N I N G | ||||
// ------------- | ||||
// | ||||
|
r2807 | // This file is not part of the Qt Chart API. It exists purely as an | ||
|
r2483 | // implementation detail. This header file may change from version to | ||
// version without notice, or even be removed. | ||||
// | ||||
// We mean it. | ||||
#ifndef CHARTAXISELEMENT_H | ||||
#define CHARTAXISELEMENT_H | ||||
|
r2714 | #include <QtCharts/QChartGlobal> | ||
#include <private/chartelement_p.h> | ||||
#include <private/axisanimation_p.h> | ||||
#include <QtWidgets/QGraphicsItem> | ||||
#include <QtWidgets/QGraphicsLayoutItem> | ||||
#include <QtGui/QFont> | ||||
|
r2483 | |||
|
r2712 | QT_CHARTS_BEGIN_NAMESPACE | ||
|
r2483 | |||
class ChartPresenter; | ||||
class QAbstractAxis; | ||||
class ChartAxisElement : public ChartElement, public QGraphicsLayoutItem | ||||
{ | ||||
Q_OBJECT | ||||
|
r2572 | |||
using QGraphicsLayoutItem::setGeometry; | ||||
|
r2483 | public: | ||
ChartAxisElement(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis = false); | ||||
~ChartAxisElement(); | ||||
virtual QRectF gridGeometry() const = 0; | ||||
virtual void setGeometry(const QRectF &axis, const QRectF &grid) = 0; | ||||
virtual bool isEmpty() = 0; | ||||
void setAnimation(AxisAnimation *animation) { m_animation = animation; } | ||||
AxisAnimation *animation() const { return m_animation; } | ||||
QAbstractAxis *axis() const { return m_axis; } | ||||
void setLayout(QVector<qreal> &layout) { m_layout = layout; } | ||||
QVector<qreal> &layout() { return m_layout; } // Modifiable reference | ||||
|
r2592 | inline qreal labelPadding() const { return qreal(4.0); } | ||
inline qreal titlePadding() const { return qreal(2.0); } | ||||
|
r2483 | void setLabels(const QStringList &labels) { m_labelsList = labels; } | ||
QStringList labels() const { return m_labelsList; } | ||||
qreal min() const; | ||||
qreal max() const; | ||||
QRectF axisGeometry() const { return m_axisRect; } | ||||
void setAxisGeometry(const QRectF &axisGeometry) { m_axisRect = axisGeometry; } | ||||
void axisSelected(); | ||||
//this flag indicates that axis is used to show intervals it means labels are in between ticks | ||||
bool intervalAxis() const { return m_intervalAxis; } | ||||
|
r2707 | QStringList createValueLabels(qreal max, qreal min, int ticks, const QString &format) const; | ||
QStringList createLogValueLabels(qreal min, qreal max, qreal base, int ticks, | ||||
const QString &format) const; | ||||
QStringList createDateTimeLabels(qreal max, qreal min, int ticks, const QString &format) const; | ||||
|
r2483 | |||
// from QGraphicsLayoutItem | ||||
QRectF boundingRect() const | ||||
{ | ||||
return QRectF(); | ||||
} | ||||
// from QGraphicsLayoutItem | ||||
void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) | ||||
{ | ||||
} | ||||
protected: | ||||
virtual QVector<qreal> calculateLayout() const = 0; | ||||
virtual void updateLayout(QVector<qreal> &layout) = 0; | ||||
QList<QGraphicsItem *> gridItems() { return m_grid->childItems(); } | ||||
|
r2795 | QList<QGraphicsItem *> minorGridItems() { return m_minorGrid->childItems(); } | ||
|
r2483 | QList<QGraphicsItem *> labelItems() { return m_labels->childItems(); } | ||
QList<QGraphicsItem *> shadeItems() { return m_shades->childItems(); } | ||||
QList<QGraphicsItem *> arrowItems() { return m_arrow->childItems(); } | ||||
|
r2795 | QList<QGraphicsItem *> minorArrowItems() { return m_minorArrow->childItems(); } | ||
|
r2539 | QGraphicsTextItem *titleItem() const { return m_title.data(); } | ||
|
r2483 | QGraphicsItemGroup *gridGroup() { return m_grid.data(); } | ||
|
r2795 | QGraphicsItemGroup *minorGridGroup() { return m_minorGrid.data(); } | ||
|
r2483 | QGraphicsItemGroup *labelGroup() { return m_labels.data(); } | ||
QGraphicsItemGroup *shadeGroup() { return m_shades.data(); } | ||||
QGraphicsItemGroup *arrowGroup() { return m_arrow.data(); } | ||||
|
r2795 | QGraphicsItemGroup *minorArrowGroup() { return m_minorArrow.data(); } | ||
|
r2483 | |||
public Q_SLOTS: | ||||
void handleVisibleChanged(bool visible); | ||||
void handleArrowVisibleChanged(bool visible); | ||||
void handleGridVisibleChanged(bool visible); | ||||
void handleLabelsVisibleChanged(bool visible); | ||||
void handleShadesVisibleChanged(bool visible); | ||||
void handleLabelsAngleChanged(int angle); | ||||
virtual void handleShadesBrushChanged(const QBrush &brush) = 0; | ||||
virtual void handleShadesPenChanged(const QPen &pen) = 0; | ||||
virtual void handleArrowPenChanged(const QPen &pen) = 0; | ||||
virtual void handleGridPenChanged(const QPen &pen) = 0; | ||||
|
r2795 | virtual void handleMinorArrowPenChanged(const QPen &pen) = 0; | ||
virtual void handleMinorGridPenChanged(const QPen &pen) = 0; | ||||
|
r2810 | virtual void handleMinorGridLineColorChanged(const QColor &color) = 0; | ||
virtual void handleGridLineColorChanged(const QColor &color) = 0; | ||||
|
r2483 | void handleLabelsBrushChanged(const QBrush &brush); | ||
void handleLabelsFontChanged(const QFont &font); | ||||
void handleTitleBrushChanged(const QBrush &brush); | ||||
void handleTitleFontChanged(const QFont &font); | ||||
void handleTitleTextChanged(const QString &title); | ||||
void handleTitleVisibleChanged(bool visible); | ||||
void handleRangeChanged(qreal min, qreal max); | ||||
|
r2781 | void handleReverseChanged(bool reverse); | ||
|
r2795 | void handleMinorArrowVisibleChanged(bool visible); | ||
void handleMinorGridVisibleChanged(bool visible); | ||||
|
r2801 | void handleLabelsPositionChanged(); | ||
|
r2483 | |||
Q_SIGNALS: | ||||
void clicked(); | ||||
private: | ||||
void connectSlots(); | ||||
|
r2707 | QString formatLabel(const QString &formatSpec, const QByteArray &array, | ||
qreal value, int precision, const QString &preStr, | ||||
const QString &postStr) const; | ||||
|
r2483 | |||
QAbstractAxis *m_axis; | ||||
AxisAnimation *m_animation; | ||||
QVector<qreal> m_layout; | ||||
QStringList m_labelsList; | ||||
QRectF m_axisRect; | ||||
QScopedPointer<QGraphicsItemGroup> m_grid; | ||||
QScopedPointer<QGraphicsItemGroup> m_arrow; | ||||
|
r2795 | QScopedPointer<QGraphicsItemGroup> m_minorGrid; | ||
QScopedPointer<QGraphicsItemGroup> m_minorArrow; | ||||
|
r2483 | QScopedPointer<QGraphicsItemGroup> m_shades; | ||
QScopedPointer<QGraphicsItemGroup> m_labels; | ||||
|
r2539 | QScopedPointer<QGraphicsTextItem> m_title; | ||
|
r2483 | bool m_intervalAxis; | ||
}; | ||||
|
r2712 | QT_CHARTS_END_NAMESPACE | ||
|
r2483 | |||
#endif /* CHARTAXISELEMENT_H */ | ||||