Warning, file /libraries/kqtquickcharts/src/xychartcore.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  Copyright 2015  Jesper Hellesø Hansen <jesperhh@gmail.com>
0003  *
0004  *  This library is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU Lesser General Public
0006  *  License as published by the Free Software Foundation; either
0007  *  version 2.1 of the License, or (at your option) version 3, or any
0008  *  later version accepted by the membership of KDE e.V. (or its
0009  *  successor approved by the membership of KDE e.V.), which shall
0010  *  act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  *  This library is distributed in the hope that it will be useful,
0013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  *  Lesser General Public License for more details.
0016  *
0017  *  You should have received a copy of the GNU Lesser General Public
0018  */
0019 
0020 #ifndef XYCHARTCORE_H
0021 #define XYCHARTCORE_H
0022 
0023 #include "chartcore.h"
0024 #include <QFont>
0025 #include <QFontMetrics>
0026 
0027 class Dimension;
0028 
0029 class XYChartCore : public ChartCore
0030 {
0031     Q_OBJECT
0032     Q_PROPERTY(qreal pointRadius READ pointRadius WRITE setPointRadius NOTIFY pointRadiusChanged)
0033     Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
0034     Q_PROPERTY(Dimension* xAxis READ xAxis WRITE setXAxis NOTIFY xAxisChanged)
0035     Q_PROPERTY(Dimension* yAxis READ yAxis WRITE setYAxis NOTIFY yAxisChanged)
0036     Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
0037     Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
0038     Q_PROPERTY(bool gridLines READ gridLines WRITE setGridLines NOTIFY gridLinesChanged)
0039     Q_PROPERTY(unsigned int axisLabelCountGoal READ axisLabelCountGoal WRITE setAxisLabelCountGoal NOTIFY axisLabelCountGoalChanged)
0040 public:
0041     explicit XYChartCore(QQuickItem* parent = nullptr);
0042     qreal pointRadius() const;
0043     void setPointRadius(qreal pointRadius);
0044     qreal lineWidth() const;
0045     void setLineWidth(qreal lineWidth);
0046     Dimension* xAxis() const;
0047     void setXAxis(Dimension* xAxis);
0048     Dimension* yAxis() const;
0049     void setYAxis(Dimension* yAxis);
0050     QColor textColor() const;
0051     void setTextColor(QColor color);
0052     QFont font() const;
0053     void setFont(const QFont &font);
0054     bool gridLines() const;
0055     void setGridLines(bool gridLines);
0056     unsigned int axisLabelCountGoal() const;
0057     void setAxisLabelCountGoal(unsigned int axisLabelCountGoal);
0058     QList<qreal> generateAxisLabels(const qreal minValue, const qreal maxValue);
0059     void paint(QPainter* painter) override;
0060     QPointF translatePoint(QPointF point);
0061 
0062 Q_SIGNALS:
0063     void pointRadiusChanged();
0064     void lineWidthChanged();
0065     void xAxisChanged();
0066     void yAxisChanged();
0067     void textColorChanged();
0068     void fontChanged();
0069     void gridLinesChanged();
0070     void axisLabelCountGoalChanged();
0071 
0072 protected Q_SLOTS:
0073     void updateAxis();
0074 
0075 protected:
0076     void paintAxis(QPainter* painter);
0077     void paintAxisLabels(QPainter* painter);
0078     void paintTicks(QPainter* painter);
0079     void paintGrid(QPainter* painter);
0080     void paintDimensionLabels(QPainter* painter);
0081 
0082 private:
0083     QString formatLabel(const qreal label, const Dimension* dimension) const;
0084 
0085     QList<qreal> m_xAxisLabels;
0086     QList<qreal> m_yAxisLabels;
0087     qreal m_pointRadius;
0088     qreal m_lineWidth;
0089     QPointF m_lowerLeftCorner;
0090     Dimension* m_xAxis;
0091     Dimension* m_yAxis;
0092     QFont m_labelFont;
0093     QFontMetrics m_labelFontMetrics;
0094     QColor m_textColor;
0095     qreal m_graphHeight;
0096     qreal m_graphWidth;
0097     int m_minorTickSize;
0098     int m_majorTickSize;
0099     int m_margin;
0100     bool m_gridLines;
0101     unsigned int m_axisLabelCountGoal;
0102 };
0103 
0104 #endif // XYCHARTCORE_H