@@ -0,0 +1,53 | |||||
|
1 | #include "qchartwidget.h" | |||
|
2 | #include "qxyseries.h" | |||
|
3 | #include "xylinechart_p.h" | |||
|
4 | #include <QGraphicsView> | |||
|
5 | #include <QGraphicsScene> | |||
|
6 | ||||
|
7 | QCHART_BEGIN_NAMESPACE | |||
|
8 | ||||
|
9 | class QChartWidgetPrivate | |||
|
10 | { | |||
|
11 | public: | |||
|
12 | QChartWidgetPrivate(QWidget *parent) : m_view(0), m_scene(0), m_chart(0) { | |||
|
13 | m_scene = new QGraphicsScene(); | |||
|
14 | m_view = new QGraphicsView(m_scene, parent); | |||
|
15 | m_view->resize(490, 300); | |||
|
16 | m_view->show(); | |||
|
17 | } | |||
|
18 | ~QChartWidgetPrivate() { | |||
|
19 | delete m_view; | |||
|
20 | delete m_scene; | |||
|
21 | } | |||
|
22 | ||||
|
23 | QGraphicsView *m_view; | |||
|
24 | QGraphicsScene *m_scene; | |||
|
25 | QChart* m_chart; | |||
|
26 | }; | |||
|
27 | ||||
|
28 | QChartWidget::QChartWidget(QWidget *parent) : | |||
|
29 | QWidget(parent), | |||
|
30 | d(new QChartWidgetPrivate(this)) | |||
|
31 | { | |||
|
32 | setMinimumSize(d->m_view->size()); | |||
|
33 | } | |||
|
34 | ||||
|
35 | QChartWidget::~QChartWidget() | |||
|
36 | { | |||
|
37 | delete d; | |||
|
38 | } | |||
|
39 | ||||
|
40 | void QChartWidget::addDataSeries( | |||
|
41 | QChart::DataSeriesType dataSeriesType, | |||
|
42 | QList<QXYSeries*> dataset) | |||
|
43 | { | |||
|
44 | // TODO: implement management of several data series of different types | |||
|
45 | ||||
|
46 | d->m_chart = QChart::createXYLineChart(dataset); | |||
|
47 | d->m_scene->addItem(d->m_chart); | |||
|
48 | d->m_chart->setSize(this->size()); | |||
|
49 | } | |||
|
50 | ||||
|
51 | #include "moc_qchartwidget.cpp" | |||
|
52 | ||||
|
53 | QCHART_END_NAMESPACE |
@@ -0,0 +1,36 | |||||
|
1 | #ifndef QCHARTWIDGET_H | |||
|
2 | #define QCHARTWIDGET_H | |||
|
3 | ||||
|
4 | #include "qchartconfig.h" | |||
|
5 | #include "qchart.h" | |||
|
6 | #include <QWidget> | |||
|
7 | ||||
|
8 | QCHART_BEGIN_NAMESPACE | |||
|
9 | ||||
|
10 | class QXYSeries; | |||
|
11 | class QChartWidgetPrivate; | |||
|
12 | ||||
|
13 | class QCHART_EXPORT QChartWidget : public QWidget | |||
|
14 | { | |||
|
15 | Q_OBJECT | |||
|
16 | public: | |||
|
17 | explicit QChartWidget(QWidget *parent = 0); | |||
|
18 | ~QChartWidget(); | |||
|
19 | // TODO: replace QXYSeries list with a charts data API | |||
|
20 | // TODO: return QChartDataSeries | |||
|
21 | void addDataSeries(QChart::DataSeriesType dataSeriesType, QList<QXYSeries*> dataset); | |||
|
22 | ||||
|
23 | signals: | |||
|
24 | ||||
|
25 | public slots: | |||
|
26 | ||||
|
27 | private: | |||
|
28 | friend class QChartWidgetPrivate; | |||
|
29 | Q_DISABLE_COPY(QChartWidget) | |||
|
30 | // Q_DECLARE_PRIVATE(QChartWidget) | |||
|
31 | QChartWidgetPrivate * const d; | |||
|
32 | }; | |||
|
33 | ||||
|
34 | QCHART_END_NAMESPACE | |||
|
35 | ||||
|
36 | #endif // QCHARTWIDGET_H |
@@ -0,0 +1,24 | |||||
|
1 | #include "dataseriedialog.h" | |||
|
2 | #include <QDialogButtonBox> | |||
|
3 | #include <QAbstractButton> | |||
|
4 | #include <QDebug> | |||
|
5 | ||||
|
6 | DataSerieDialog::DataSerieDialog(QWidget *parent) : | |||
|
7 | QDialog(parent) | |||
|
8 | { | |||
|
9 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Vertical, this); | |||
|
10 | addSeriesBox->addButton("Line", QDialogButtonBox::AcceptRole); | |||
|
11 | addSeriesBox->addButton("Area", QDialogButtonBox::AcceptRole); | |||
|
12 | addSeriesBox->addButton("Bar", QDialogButtonBox::AcceptRole); | |||
|
13 | addSeriesBox->addButton("Pie", QDialogButtonBox::AcceptRole); | |||
|
14 | addSeriesBox->addButton("Scatter", QDialogButtonBox::AcceptRole); | |||
|
15 | addSeriesBox->addButton("Spline", QDialogButtonBox::AcceptRole); | |||
|
16 | connect(addSeriesBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(addSeries(QAbstractButton *))); | |||
|
17 | this->setFixedSize(addSeriesBox->sizeHint()); | |||
|
18 | } | |||
|
19 | ||||
|
20 | void DataSerieDialog::addSeries(QAbstractButton *button) | |||
|
21 | { | |||
|
22 | addSeries(button->text().toAscii()); | |||
|
23 | accept(); | |||
|
24 | } |
@@ -0,0 +1,21 | |||||
|
1 | #ifndef DATASERIEDIALOG_H | |||
|
2 | #define DATASERIEDIALOG_H | |||
|
3 | ||||
|
4 | #include <QDialog> | |||
|
5 | ||||
|
6 | class QAbstractButton; | |||
|
7 | ||||
|
8 | class DataSerieDialog : public QDialog | |||
|
9 | { | |||
|
10 | Q_OBJECT | |||
|
11 | public: | |||
|
12 | explicit DataSerieDialog(QWidget *parent = 0); | |||
|
13 | ||||
|
14 | signals: | |||
|
15 | void addSeries(QString series); | |||
|
16 | ||||
|
17 | public slots: | |||
|
18 | void addSeries(QAbstractButton *button); | |||
|
19 | }; | |||
|
20 | ||||
|
21 | #endif // DATASERIEDIALOG_H |
1 | NO CONTENT: file renamed from src/xylinechart/axis.cpp to src/axis.cpp |
|
NO CONTENT: file renamed from src/xylinechart/axis.cpp to src/axis.cpp |
1 | NO CONTENT: file renamed from src/xylinechart/axis_p.h to src/axis_p.h |
|
NO CONTENT: file renamed from src/xylinechart/axis_p.h to src/axis_p.h |
@@ -1,30 +1,29 | |||||
1 | #include "qchart.h" |
|
1 | #include "qchart.h" | |
2 | #include "xylinechart_p.h" |
|
2 | #include "xylinechart_p.h" | |
3 |
|
3 | |||
4 | QCHART_BEGIN_NAMESPACE |
|
4 | QCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 | QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent), |
|
6 | QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent), | |
7 | m_marginSize(0) |
|
7 | m_marginSize(0) | |
8 | { |
|
8 | { | |
9 | // setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
9 | // setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | QChart::~QChart(){} |
|
12 | QChart::~QChart(){} | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | QChart* QChart::createXYLineChart(const QList<QXYSeries*>& dataset) |
|
15 | QChart* QChart::createXYLineChart(const QList<QXYSeries*>& dataset) | |
16 | { |
|
16 | { | |
17 |
|
||||
18 | XYLineChart* chart = new XYLineChart(); |
|
17 | XYLineChart* chart = new XYLineChart(); | |
19 | foreach (const QXYSeries* series,dataset) { |
|
18 | foreach (const QXYSeries* series,dataset) { | |
20 | chart->addXYSeries(series); |
|
19 | chart->addXYSeries(series); | |
21 | } |
|
20 | } | |
22 | return chart; |
|
21 | return chart; | |
23 | } |
|
22 | } | |
24 |
|
23 | |||
25 | void QChart::setMargin(int margin) |
|
24 | void QChart::setMargin(int margin) | |
26 | { |
|
25 | { | |
27 |
|
|
26 | m_marginSize = margin; | |
28 | } |
|
27 | } | |
29 |
|
28 | |||
30 | QCHART_END_NAMESPACE |
|
29 | QCHART_END_NAMESPACE |
@@ -1,31 +1,40 | |||||
1 | #ifndef CHART_H |
|
1 | #ifndef CHART_H | |
2 | #define CHART_H |
|
2 | #define CHART_H | |
3 |
|
3 | |||
4 | #include <qchartconfig.h> |
|
4 | #include <qchartconfig.h> | |
5 | #include <qxyseries.h> |
|
5 | #include <qxyseries.h> | |
6 | #include <QGraphicsItem> |
|
6 | #include <QGraphicsItem> | |
7 |
|
7 | |||
8 | QCHART_BEGIN_NAMESPACE |
|
8 | QCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class QCHART_EXPORT QChart : public QGraphicsItem |
|
10 | class QCHART_EXPORT QChart : public QGraphicsItem | |
11 | { |
|
11 | { | |
|
12 | public: | |||
|
13 | enum DataSeriesType { | |||
|
14 | DataSeriesTypeLine = 0, | |||
|
15 | DataSeriesTypeArea, | |||
|
16 | DataSeriesTypeBar, | |||
|
17 | DataSeriesTypePie, | |||
|
18 | DataSeriesTypeScatter, | |||
|
19 | DataSeriesTypeSpline | |||
|
20 | }; | |||
12 |
|
21 | |||
13 | protected: |
|
22 | protected: | |
14 | QChart(QGraphicsItem* parent =0); |
|
23 | QChart(QGraphicsItem* parent =0); | |
15 |
|
24 | |||
16 | public: |
|
25 | public: | |
17 | virtual ~QChart(); |
|
26 | virtual ~QChart(); | |
18 |
|
27 | |||
19 | static QChart* createXYLineChart(const QList<QXYSeries*>& dataset); |
|
28 | static QChart* createXYLineChart(const QList<QXYSeries*>& dataset); | |
20 |
|
29 | |||
21 | virtual void setSize(const QSizeF& rect)=0; |
|
30 | virtual void setSize(const QSizeF& rect)=0; | |
22 | void setMargin(int margin); |
|
31 | void setMargin(int margin); | |
23 | int margin() const { return m_marginSize;} |
|
32 | int margin() const { return m_marginSize;} | |
24 |
|
33 | |||
25 | private: |
|
34 | private: | |
26 | int m_marginSize; |
|
35 | int m_marginSize; | |
27 | }; |
|
36 | }; | |
28 |
|
37 | |||
29 | QCHART_END_NAMESPACE |
|
38 | QCHART_END_NAMESPACE | |
30 |
|
39 | |||
31 | #endif |
|
40 | #endif |
@@ -1,44 +1,45 | |||||
1 | TARGET = QChart |
|
1 | TARGET = QChart | |
2 | TEMPLATE = lib |
|
2 | TEMPLATE = lib | |
3 | QT += core \ |
|
3 | QT += core \ | |
4 | gui |
|
4 | gui | |
5 | CONFIG += debug_and_release |
|
5 | CONFIG += debug_and_release | |
6 | CONFIG(debug, debug|release):TARGET = QChartd |
|
6 | CONFIG(debug, debug|release):TARGET = QChartd | |
|
7 | ||||
7 | SOURCES += \ |
|
8 | SOURCES += \ | |
8 | xylinechart/qchartwidget.cpp \ |
|
9 | xylinechart/qchartgraphicswidget.cpp \ | |
9 | xylinechart/qchart.cpp \ |
|
|||
10 | xylinechart/qxyseries.cpp \ |
|
10 | xylinechart/qxyseries.cpp \ | |
11 | xylinechart/axis.cpp \ |
|
|||
12 | xylinechart/xylinechart.cpp \ |
|
11 | xylinechart/xylinechart.cpp \ | |
13 | xylinechart/xygrid.cpp \ |
|
12 | xylinechart/xygrid.cpp \ | |
14 | xylinechart/xyplotdata.cpp |
|
13 | xylinechart/xyplotdata.cpp \ | |
|
14 | qchart.cpp \ | |||
|
15 | axis.cpp \ | |||
|
16 | qchartwidget.cpp | |||
15 |
|
17 | |||
16 | PRIVATE_HEADERS += \ |
|
18 | PRIVATE_HEADERS += \ | |
17 | xylinechart/xylinechart_p.h \ |
|
19 | xylinechart/xylinechart_p.h \ | |
18 | xylinechart/axis_p.h \ |
|
|||
19 | xylinechart/xygrid_p.h \ |
|
20 | xylinechart/xygrid_p.h \ | |
20 | xylinechart/xyplotdata_p.h |
|
21 | xylinechart/xyplotdata_p.h \ | |
21 |
|
22 | axis_p.h | ||
22 | PUBLIC_HEADERS += \ |
|
23 | PUBLIC_HEADERS += \ | |
23 | xylinechart/qchart.h \ |
|
|||
24 | xylinechart/qxyseries.h \ |
|
24 | xylinechart/qxyseries.h \ | |
25 | xylinechart/qchartwidget.h \ |
|
25 | xylinechart/qchartgraphicswidget.h \ | |
26 |
qchart |
|
26 | qchart.h \ | |
27 |
|
27 | qchartwidget.h \ | ||
|
28 | qchartconfig.h | |||
28 | HEADERS += $$PUBLIC_HEADERS |
|
29 | HEADERS += $$PUBLIC_HEADERS | |
29 | HEADERS += $$PRIVATE_HEADERS |
|
30 | HEADERS += $$PRIVATE_HEADERS | |
30 |
|
31 | |||
31 | INCLUDEPATH += xylinechart \ |
|
32 | INCLUDEPATH += xylinechart \ | |
32 | . |
|
33 | . | |
33 |
|
34 | |||
34 | OBJECTS_DIR = ../build/lib |
|
35 | OBJECTS_DIR = ../build/lib | |
35 | MOC_DIR = ../build/lib |
|
36 | MOC_DIR = ../build/lib | |
36 | UI_DIR = ../build/lib |
|
37 | UI_DIR = ../build/lib | |
37 | RCC_DIR = ../build/lib |
|
38 | RCC_DIR = ../build/lib | |
38 | DEFINES += QCHART_LIBRARY |
|
39 | DEFINES += QCHART_LIBRARY | |
39 |
|
40 | |||
40 | public_headers.path = $$[QT_INSTALL_HEADERS]/QCharts |
|
41 | public_headers.path = $$[QT_INSTALL_HEADERS]/QCharts | |
41 | public_headers.files = $$PUBLIC_HEADERS |
|
42 | public_headers.files = $$PUBLIC_HEADERS | |
42 | target.path = $$[QT_INSTALL_LIBS] |
|
43 | target.path = $$[QT_INSTALL_LIBS] | |
43 | INSTALLS += target \ |
|
44 | INSTALLS += target \ | |
44 | public_headers |
|
45 | public_headers |
@@ -1,41 +1,41 | |||||
1 | #include "qchartwidget.h" |
|
1 | #include "qchartgraphicswidget.h" | |
2 | #include "qchart.h" |
|
2 | #include "qchart.h" | |
3 |
|
3 | |||
4 | QCHART_BEGIN_NAMESPACE |
|
4 | QCHART_BEGIN_NAMESPACE | |
5 |
|
5 | |||
6 |
|
6 | |||
7 | class QChartWidgetPrivate |
|
7 | class QChartGraphicsWidgetPrivate | |
8 | { |
|
8 | { | |
9 | public: |
|
9 | public: | |
10 | QChart* chart; |
|
10 | QChart* chart; | |
11 | //Q_DECLARE_PUBLIC(ChartWidget) |
|
11 | //Q_DECLARE_PUBLIC(ChartWidget) | |
12 | QChartWidgetPrivate() {} |
|
12 | QChartGraphicsWidgetPrivate() {} | |
13 | }; |
|
13 | }; | |
14 |
|
14 | |||
15 | //////////////////////////////////////////////////////////////////////////// |
|
15 | //////////////////////////////////////////////////////////////////////////// | |
16 |
|
16 | |||
17 | QChartWidget::QChartWidget(QGraphicsItem *parent,Qt::WindowFlags wFlags) |
|
17 | QChartGraphicsWidget::QChartGraphicsWidget(QGraphicsItem *parent,Qt::WindowFlags wFlags) | |
18 | : QGraphicsWidget(parent,wFlags), |
|
18 | : QGraphicsWidget(parent,wFlags), | |
19 | d_ptr(new QChartWidgetPrivate()) |
|
19 | d_ptr(new QChartGraphicsWidgetPrivate()) | |
20 | { |
|
20 | { | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | QChartWidget::~QChartWidget() |
|
23 | QChartGraphicsWidget::~QChartGraphicsWidget() | |
24 | { |
|
24 | { | |
25 | delete d_ptr; |
|
25 | delete d_ptr; | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 |
|
28 | |||
29 | void QChartWidget::addChart(QChart *chart) |
|
29 | void QChartGraphicsWidget::addChart(QChart *chart) | |
30 | { |
|
30 | { | |
31 | d_ptr->chart=chart; |
|
31 | d_ptr->chart=chart; | |
32 | chart->setParentItem(this); |
|
32 | chart->setParentItem(this); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | void QChartWidget::setGeometry(const QRectF & rect) |
|
35 | void QChartGraphicsWidget::setGeometry(const QRectF & rect) | |
36 | { |
|
36 | { | |
37 | d_ptr->chart->setSize(rect.size()); |
|
37 | d_ptr->chart->setSize(rect.size()); | |
38 | QGraphicsWidget::setGeometry(rect); |
|
38 | QGraphicsWidget::setGeometry(rect); | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | QCHART_END_NAMESPACE |
|
41 | QCHART_END_NAMESPACE |
@@ -1,34 +1,34 | |||||
1 | #ifndef QCHARTWIDGET_H |
|
1 | #ifndef QCHARTGRAPHICSWIDGET_H | |
2 | #define QCHARTWIDGET_H |
|
2 | #define QCHARTGRAPHICSWIDGET_H | |
3 |
|
3 | |||
4 | #include <qchartconfig.h> |
|
4 | #include <qchartconfig.h> | |
5 | #include <QGraphicsWidget> |
|
5 | #include <QGraphicsWidget> | |
6 |
|
6 | |||
7 | class QGraphicsItem; |
|
7 | class QGraphicsItem; | |
8 |
|
8 | |||
9 | QCHART_BEGIN_NAMESPACE |
|
9 | QCHART_BEGIN_NAMESPACE | |
10 |
|
10 | |||
11 | class QChart; |
|
11 | class QChart; | |
12 | class QChartWidgetPrivate; |
|
12 | class QChartGraphicsWidgetPrivate; | |
13 |
|
13 | |||
14 | class QCHART_EXPORT QChartWidget : public QGraphicsWidget |
|
14 | class QCHART_EXPORT QChartGraphicsWidget : public QGraphicsWidget | |
15 | { |
|
15 | { | |
16 |
|
16 | |||
17 | public: |
|
17 | public: | |
18 | explicit QChartWidget(QGraphicsItem *parent = 0,Qt::WindowFlags wFlags = 0); |
|
18 | explicit QChartGraphicsWidget(QGraphicsItem *parent = 0,Qt::WindowFlags wFlags = 0); | |
19 | ~QChartWidget(); |
|
19 | ~QChartGraphicsWidget(); | |
20 |
|
20 | |||
21 | QChart* chart() const; |
|
21 | QChart* chart() const; | |
22 | void addChart(QChart* chart); |
|
22 | void addChart(QChart* chart); | |
23 |
|
23 | |||
24 | virtual void setGeometry(const QRectF & rect); |
|
24 | virtual void setGeometry(const QRectF & rect); | |
25 |
|
25 | |||
26 | private: |
|
26 | private: | |
27 | Q_DISABLE_COPY(QChartWidget) |
|
27 | Q_DISABLE_COPY(QChartGraphicsWidget) | |
28 | Q_DECLARE_PRIVATE(QChartWidget) |
|
28 | Q_DECLARE_PRIVATE(QChartGraphicsWidget) | |
29 | QChartWidgetPrivate * const d_ptr; |
|
29 | QChartGraphicsWidgetPrivate * const d_ptr; | |
30 | }; |
|
30 | }; | |
31 |
|
31 | |||
32 | QCHART_END_NAMESPACE |
|
32 | QCHART_END_NAMESPACE | |
33 |
|
33 | |||
34 | #endif |
|
34 | #endif |
@@ -1,59 +1,63 | |||||
1 | #include "qxyseries.h" |
|
1 | #include "qxyseries.h" | |
2 |
|
2 | |||
|
3 | QCHART_BEGIN_NAMESPACE | |||
|
4 | ||||
3 | QXYSeries::QXYSeries(): |
|
5 | QXYSeries::QXYSeries(): | |
4 | m_color(Qt::black) |
|
6 | m_color(Qt::black) | |
5 | { |
|
7 | { | |
6 | } |
|
8 | } | |
7 |
|
9 | |||
8 | QXYSeries::~QXYSeries() |
|
10 | QXYSeries::~QXYSeries() | |
9 | { |
|
11 | { | |
10 | } |
|
12 | } | |
11 |
|
13 | |||
12 |
|
14 | |||
13 | void QXYSeries::setColor(const QColor& color) |
|
15 | void QXYSeries::setColor(const QColor& color) | |
14 | { |
|
16 | { | |
15 | m_color = color; |
|
17 | m_color = color; | |
16 | } |
|
18 | } | |
17 |
|
19 | |||
18 |
|
20 | |||
19 | void QXYSeries::add(qreal x,qreal y) |
|
21 | void QXYSeries::add(qreal x,qreal y) | |
20 | { |
|
22 | { | |
21 | m_x<<x; |
|
23 | m_x<<x; | |
22 | m_y<<y; |
|
24 | m_y<<y; | |
23 | } |
|
25 | } | |
24 |
|
26 | |||
25 | void QXYSeries::clear() |
|
27 | void QXYSeries::clear() | |
26 | { |
|
28 | { | |
27 | m_x.clear(); |
|
29 | m_x.clear(); | |
28 | m_y.clear(); |
|
30 | m_y.clear(); | |
29 | } |
|
31 | } | |
30 |
|
32 | |||
31 | qreal QXYSeries::x(int pos) const |
|
33 | qreal QXYSeries::x(int pos) const | |
32 | { |
|
34 | { | |
33 | return m_x.at(pos); |
|
35 | return m_x.at(pos); | |
34 | } |
|
36 | } | |
35 |
|
37 | |||
36 | qreal QXYSeries::y(int pos) const |
|
38 | qreal QXYSeries::y(int pos) const | |
37 | { |
|
39 | { | |
38 | return m_y.at(pos); |
|
40 | return m_y.at(pos); | |
39 | } |
|
41 | } | |
40 |
|
42 | |||
41 | int QXYSeries::count() const |
|
43 | int QXYSeries::count() const | |
42 | { |
|
44 | { | |
43 | Q_ASSERT(m_x.size() == m_y.size()); |
|
45 | Q_ASSERT(m_x.size() == m_y.size()); | |
44 |
|
46 | |||
45 | return m_x.size(); |
|
47 | return m_x.size(); | |
46 |
|
48 | |||
47 | } |
|
49 | } | |
48 |
|
50 | |||
49 | QDebug operator<< (QDebug debug, const QXYSeries series) |
|
51 | QDebug operator<< (QDebug debug, const QXYSeries series) | |
50 | { |
|
52 | { | |
51 | Q_ASSERT(series.m_x.size() == series.m_y.size()); |
|
53 | Q_ASSERT(series.m_x.size() == series.m_y.size()); | |
52 |
|
54 | |||
53 | int size = series.m_x.size(); |
|
55 | int size = series.m_x.size(); | |
54 |
|
56 | |||
55 | for (int i=0;i<size;i++) { |
|
57 | for (int i=0;i<size;i++) { | |
56 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; |
|
58 | debug.nospace() << "(" << series.m_x.at(i) << ','<< series.m_y.at(i) << ") "; | |
57 | } |
|
59 | } | |
58 | return debug.space(); |
|
60 | return debug.space(); | |
59 | } |
|
61 | } | |
|
62 | ||||
|
63 | QCHART_END_NAMESPACE |
@@ -1,28 +1,33 | |||||
1 | #ifndef QXYSERIES_H_ |
|
1 | #ifndef QXYSERIES_H_ | |
2 | #define QXYSERIES_H_ |
|
2 | #define QXYSERIES_H_ | |
|
3 | ||||
|
4 | #include "qchartconfig.h" | |||
3 | #include <QDebug> |
|
5 | #include <QDebug> | |
4 | #include <QColor> |
|
6 | #include <QColor> | |
5 |
|
7 | |||
|
8 | QCHART_BEGIN_NAMESPACE | |||
6 |
|
9 | |||
7 | class QXYSeries |
|
10 | class QCHART_EXPORT QXYSeries | |
8 | { |
|
11 | { | |
9 | public: |
|
12 | public: | |
10 | QXYSeries(); |
|
13 | QXYSeries(); | |
11 | virtual ~QXYSeries(); |
|
14 | virtual ~QXYSeries(); | |
12 | void add(qreal x, qreal y); |
|
15 | void add(qreal x, qreal y); | |
13 | void clear(); |
|
16 | void clear(); | |
14 | void setColor(const QColor& color); |
|
17 | void setColor(const QColor& color); | |
15 | const QColor& color() const { return m_color;} |
|
18 | const QColor& color() const { return m_color;} | |
16 | int count() const; |
|
19 | int count() const; | |
17 | qreal x(int pos) const; |
|
20 | qreal x(int pos) const; | |
18 | qreal y(int pos) const; |
|
21 | qreal y(int pos) const; | |
19 | friend QDebug operator<< (QDebug d, const QXYSeries series); |
|
22 | friend QDebug operator<< (QDebug d, const QXYSeries series); | |
20 |
|
23 | |||
21 | private: |
|
24 | private: | |
22 | QColor m_color; |
|
25 | QColor m_color; | |
23 | QList<qreal> m_x; |
|
26 | QList<qreal> m_x; | |
24 | QList<qreal> m_y; |
|
27 | QList<qreal> m_y; | |
25 |
|
28 | |||
26 | }; |
|
29 | }; | |
27 |
|
30 | |||
|
31 | QCHART_END_NAMESPACE | |||
|
32 | ||||
28 | #endif |
|
33 | #endif |
@@ -1,32 +1,33 | |||||
1 | TARGET = chartwidgettest |
|
1 | TARGET = chartwidgettest | |
2 | TEMPLATE = app |
|
2 | TEMPLATE = app | |
3 |
|
3 | |||
4 | QT += core gui |
|
4 | QT += core gui | |
5 | contains(QT_MAJOR_VERSION, 5) { |
|
5 | contains(QT_MAJOR_VERSION, 5) { | |
6 | QT += widgets |
|
6 | QT += widgets | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | CONFIG += charts |
|
9 | CONFIG += charts | |
10 | CHARTS += widget |
|
|||
11 |
|
10 | |||
12 | OBJECTS_DIR = tmp |
|
11 | OBJECTS_DIR = tmp | |
13 | MOC_DIR = tmp |
|
12 | MOC_DIR = tmp | |
14 |
|
13 | |||
15 | SOURCES += main.cpp \ |
|
14 | SOURCES += main.cpp \ | |
16 | mainwidget.cpp \ |
|
15 | mainwidget.cpp \ | |
17 | qscatterseries.cpp \ |
|
16 | # qscatterseries.cpp \ | |
18 | qchartwidget.cpp \ |
|
17 | # qseriespointgraphicsitem.cpp \ | |
19 | qseriespointgraphicsitem.cpp |
|
18 | dataseriedialog.cpp | |
20 |
|
19 | |||
21 | HEADERS += \ |
|
20 | HEADERS += \ | |
22 | mainwidget.h \ |
|
21 | mainwidget.h \ | |
23 | qscatterseries.h \ |
|
22 | # qscatterseries.h \ | |
24 | qchartwidget.h \ |
|
23 | # qseriespointgraphicsitem.h \ | |
25 | qseriespointgraphicsitem.h |
|
24 | dataseriedialog.h | |
|
25 | ||||
|
26 | ||||
26 |
|
27 | |||
27 |
|
28 | |||
28 |
|
29 | |||
29 |
|
30 | |||
30 |
|
31 | |||
31 |
|
32 | |||
32 |
|
33 |
@@ -1,199 +1,229 | |||||
1 | #include "mainwidget.h" |
|
1 | #include "mainwidget.h" | |
2 |
#include " |
|
2 | #include "dataseriedialog.h" | |
3 |
|
|
3 | #include <qxyseries.h> | |
4 | #include <QPushButton> |
|
4 | #include <QPushButton> | |
5 | #include <QComboBox> |
|
5 | #include <QComboBox> | |
6 | #include <QSpinBox> |
|
6 | #include <QSpinBox> | |
7 | #include <QCheckBox> |
|
7 | #include <QCheckBox> | |
8 | #include <QGridLayout> |
|
8 | #include <QGridLayout> | |
9 | #include <QHBoxLayout> |
|
9 | #include <QHBoxLayout> | |
10 | #include <QLabel> |
|
10 | #include <QLabel> | |
11 | #include <QSpacerItem> |
|
11 | #include <QSpacerItem> | |
12 | #include <QMessageBox> |
|
12 | #include <QMessageBox> | |
13 | #include <cmath> |
|
13 | #include <cmath> | |
14 | #include <QDebug> |
|
14 | #include <QDebug> | |
15 |
|
15 | |||
|
16 | QCHART_USE_NAMESPACE | |||
|
17 | ||||
16 | MainWidget::MainWidget(QWidget *parent) : |
|
18 | MainWidget::MainWidget(QWidget *parent) : | |
17 | QWidget(parent) |
|
19 | QWidget(parent) | |
18 | { |
|
20 | { | |
19 | m_chartWidget = new QChartWidget(this); |
|
21 | m_chartWidget = new QChartWidget(this); | |
20 | // m_chartWidget->resize(QSize(200,200)); |
|
22 | // m_chartWidget->resize(QSize(200,200)); | |
21 | // m_chartWidget->setColor(Qt::red); |
|
23 | // m_chartWidget->setColor(Qt::red); | |
22 | // Chart type |
|
24 | // Chart type | |
23 | // TODO: How about multiple types? |
|
25 | // TODO: How about multiple types? | |
24 | // Should the type be a property of a graph instead of the chart? |
|
26 | // Should the type be a property of a graph instead of the chart? | |
25 | QComboBox *chartTypeCombo = new QComboBox(this); |
|
27 | // QComboBox *chartTypeCombo = new QComboBox(this); | |
26 | chartTypeCombo->addItem("Line"); |
|
28 | // chartTypeCombo->addItem("Line"); | |
27 | chartTypeCombo->addItem("Area"); |
|
29 | // chartTypeCombo->addItem("Area"); | |
28 | chartTypeCombo->addItem("Bar"); |
|
30 | // chartTypeCombo->addItem("Bar"); | |
29 | chartTypeCombo->addItem("Pie"); |
|
31 | // chartTypeCombo->addItem("Pie"); | |
30 | chartTypeCombo->addItem("Scatter"); |
|
32 | // chartTypeCombo->addItem("Scatter"); | |
31 | chartTypeCombo->addItem("Spline"); |
|
33 | // chartTypeCombo->addItem("Spline"); | |
32 | connect(chartTypeCombo, SIGNAL(currentIndexChanged(int)), |
|
34 | // connect(chartTypeCombo, SIGNAL(currentIndexChanged(int)), | |
33 | this, SLOT(chartTypeChanged(int))); |
|
35 | // this, SLOT(chartTypeChanged(int))); | |
|
36 | ||||
|
37 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |||
|
38 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |||
34 |
|
39 | |||
35 | // Test data selector |
|
40 | // Test data selector | |
36 | QComboBox *testDataCombo = new QComboBox(this); |
|
41 | QComboBox *testDataCombo = new QComboBox(this); | |
37 | testDataCombo->addItem("linear"); |
|
42 | testDataCombo->addItem("linear"); | |
38 | testDataCombo->addItem("SIN"); |
|
43 | testDataCombo->addItem("SIN"); | |
39 | testDataCombo->addItem("SIN + random component"); |
|
44 | testDataCombo->addItem("SIN + random component"); | |
40 | testDataCombo->addItem("TODO From file..."); |
|
45 | testDataCombo->addItem("TODO From file..."); | |
41 | testDataCombo->addItem("TODO From URL..."); |
|
46 | testDataCombo->addItem("TODO From URL..."); | |
42 | connect(testDataCombo, SIGNAL(currentIndexChanged(int)), |
|
47 | connect(testDataCombo, SIGNAL(currentIndexChanged(int)), | |
43 | this, SLOT(testDataChanged(int))); |
|
48 | this, SLOT(testDataChanged(int))); | |
44 |
|
49 | |||
45 | // Chart background |
|
50 | // Chart background | |
46 | QComboBox *backgroundCombo = new QComboBox(this); |
|
51 | QComboBox *backgroundCombo = new QComboBox(this); | |
47 | backgroundCombo->addItem("None"); |
|
52 | backgroundCombo->addItem("None"); | |
48 | backgroundCombo->addItem("TODO Grid"); |
|
53 | backgroundCombo->addItem("TODO Grid"); | |
49 | backgroundCombo->addItem("TODO Image"); |
|
54 | backgroundCombo->addItem("TODO Image"); | |
50 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
55 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
51 | this, SLOT(backgroundChanged(int))); |
|
56 | this, SLOT(backgroundChanged(int))); | |
52 |
|
57 | |||
53 | // Axis |
|
58 | // Axis | |
54 | // TODO: multiple axes? |
|
59 | // TODO: multiple axes? | |
55 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
60 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
56 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
61 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
57 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
62 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
58 | m_xMinSpin = new QSpinBox(); |
|
63 | m_xMinSpin = new QSpinBox(); | |
59 | m_xMinSpin->setMinimum(INT_MIN); |
|
64 | m_xMinSpin->setMinimum(INT_MIN); | |
60 | m_xMinSpin->setMaximum(INT_MAX); |
|
65 | m_xMinSpin->setMaximum(INT_MAX); | |
61 | m_xMinSpin->setValue(0); |
|
66 | m_xMinSpin->setValue(0); | |
62 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
67 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
63 | m_xMaxSpin = new QSpinBox(); |
|
68 | m_xMaxSpin = new QSpinBox(); | |
64 | m_xMaxSpin->setMinimum(INT_MIN); |
|
69 | m_xMaxSpin->setMinimum(INT_MIN); | |
65 | m_xMaxSpin->setMaximum(INT_MAX); |
|
70 | m_xMaxSpin->setMaximum(INT_MAX); | |
66 | m_xMaxSpin->setValue(10); |
|
71 | m_xMaxSpin->setValue(10); | |
67 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
72 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
68 | m_yMinSpin = new QSpinBox(); |
|
73 | m_yMinSpin = new QSpinBox(); | |
69 | m_yMinSpin->setMinimum(INT_MIN); |
|
74 | m_yMinSpin->setMinimum(INT_MIN); | |
70 | m_yMinSpin->setMaximum(INT_MAX); |
|
75 | m_yMinSpin->setMaximum(INT_MAX); | |
71 | m_yMinSpin->setValue(0); |
|
76 | m_yMinSpin->setValue(0); | |
72 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
77 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
73 | m_yMaxSpin = new QSpinBox(); |
|
78 | m_yMaxSpin = new QSpinBox(); | |
74 | m_yMaxSpin->setMinimum(INT_MIN); |
|
79 | m_yMaxSpin->setMinimum(INT_MIN); | |
75 | m_yMaxSpin->setMaximum(INT_MAX); |
|
80 | m_yMaxSpin->setMaximum(INT_MAX); | |
76 | m_yMaxSpin->setValue(10); |
|
81 | m_yMaxSpin->setValue(10); | |
77 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
82 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
78 |
|
83 | |||
79 | QGridLayout *grid = new QGridLayout(); |
|
84 | QGridLayout *grid = new QGridLayout(); | |
80 | QHBoxLayout *hbox = new QHBoxLayout(); |
|
85 | QHBoxLayout *hbox = new QHBoxLayout(); | |
81 |
grid->addWidget(new QLabel(" |
|
86 | //grid->addWidget(new QLabel("Add series:"), 0, 0); | |
82 |
grid->addWidget( |
|
87 | grid->addWidget(addSeriesButton, 0, 1); | |
|
88 | // grid->addWidget(new QLabel("Chart type:"), 0, 0); | |||
|
89 | // grid->addWidget(chartTypeCombo, 0, 1); | |||
83 | grid->addWidget(new QLabel("Data:"), 1, 0); |
|
90 | grid->addWidget(new QLabel("Data:"), 1, 0); | |
84 | grid->addWidget(testDataCombo, 1, 1); |
|
91 | grid->addWidget(testDataCombo, 1, 1); | |
85 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
92 | grid->addWidget(new QLabel("Background:"), 2, 0); | |
86 | grid->addWidget(backgroundCombo, 2, 1); |
|
93 | grid->addWidget(backgroundCombo, 2, 1); | |
87 | grid->addWidget(m_autoScaleCheck, 3, 0); |
|
94 | grid->addWidget(m_autoScaleCheck, 3, 0); | |
88 | grid->addWidget(new QLabel("x min:"), 4, 0); |
|
95 | grid->addWidget(new QLabel("x min:"), 4, 0); | |
89 | grid->addWidget(m_xMinSpin, 4, 1); |
|
96 | grid->addWidget(m_xMinSpin, 4, 1); | |
90 | grid->addWidget(new QLabel("x max:"), 5, 0); |
|
97 | grid->addWidget(new QLabel("x max:"), 5, 0); | |
91 | grid->addWidget(m_xMaxSpin, 5, 1); |
|
98 | grid->addWidget(m_xMaxSpin, 5, 1); | |
92 | grid->addWidget(new QLabel("y min:"), 6, 0); |
|
99 | grid->addWidget(new QLabel("y min:"), 6, 0); | |
93 | grid->addWidget(m_yMinSpin, 6, 1); |
|
100 | grid->addWidget(m_yMinSpin, 6, 1); | |
94 | grid->addWidget(new QLabel("y max:"), 7, 0); |
|
101 | grid->addWidget(new QLabel("y max:"), 7, 0); | |
95 | grid->addWidget(m_yMaxSpin, 7, 1); |
|
102 | grid->addWidget(m_yMaxSpin, 7, 1); | |
96 | // add row with empty label to make all the other rows static |
|
103 | // add row with empty label to make all the other rows static | |
97 | grid->addWidget(new QLabel(""), 8, 0); |
|
104 | grid->addWidget(new QLabel(""), 8, 0); | |
98 | grid->setRowStretch(8, 1); |
|
105 | grid->setRowStretch(8, 1); | |
99 |
|
106 | |||
100 | hbox->addLayout(grid); |
|
107 | hbox->addLayout(grid); | |
101 | hbox->addWidget(m_chartWidget); |
|
108 | hbox->addWidget(m_chartWidget); | |
102 | hbox->setStretch(1, 1); |
|
109 | hbox->setStretch(1, 1); | |
103 |
|
110 | |||
104 | setLayout(hbox); |
|
111 | setLayout(hbox); | |
105 |
|
112 | |||
106 | m_autoScaleCheck->setChecked(true); |
|
113 | m_autoScaleCheck->setChecked(true); | |
107 | chartTypeChanged(4); |
|
114 | chartTypeChanged(4); | |
108 | testDataChanged(0); |
|
115 | testDataChanged(0); | |
109 | } |
|
116 | } | |
110 |
|
117 | |||
|
118 | void MainWidget::addSeries() | |||
|
119 | { | |||
|
120 | DataSerieDialog dialog(this); | |||
|
121 | connect(&dialog, SIGNAL(addSeries(QString)), this, SLOT(addSeries(QString))); | |||
|
122 | dialog.exec(); | |||
|
123 | } | |||
|
124 | ||||
|
125 | void MainWidget::addSeries(QString series) | |||
|
126 | { | |||
|
127 | if (series == "Scatter") { | |||
|
128 | QXYSeries* series0 = new QXYSeries(); | |||
|
129 | series0->setColor(Qt::blue); | |||
|
130 | for (int x = 0; x < 100; x++) | |||
|
131 | series0->add(x, abs(sin(3.14159265358979 / 50 * x) * 100)); | |||
|
132 | QList<QXYSeries*> dataset; | |||
|
133 | dataset << series0; | |||
|
134 | m_chartWidget->addDataSeries(QChart::DataSeriesTypeScatter, dataset); | |||
|
135 | //m_chartWidget->addDataSeries(dataset); | |||
|
136 | } else { | |||
|
137 | // TODO | |||
|
138 | qDebug() << "addSeries: " << series; | |||
|
139 | } | |||
|
140 | } | |||
|
141 | ||||
111 | void MainWidget::chartTypeChanged(int itemIndex) |
|
142 | void MainWidget::chartTypeChanged(int itemIndex) | |
112 | { |
|
143 | { | |
113 | // TODO: change chart type |
|
144 | // TODO: change chart type | |
114 | switch (itemIndex) { |
|
145 | switch (itemIndex) { | |
115 | case 4: |
|
146 | case 4: | |
116 | m_chartWidget->setType(4); |
|
147 | //m_chartWidget->setType(4); | |
117 | break; |
|
148 | break; | |
118 | default: { |
|
149 | default: { | |
119 | m_chartWidget->setType(0); |
|
150 | //m_chartWidget->setType(0); | |
120 | break; |
|
151 | break; | |
121 | } |
|
152 | } | |
122 | } |
|
153 | } | |
123 | } |
|
154 | } | |
124 |
|
155 | |||
125 | void MainWidget::testDataChanged(int itemIndex) |
|
156 | void MainWidget::testDataChanged(int itemIndex) | |
126 | { |
|
157 | { | |
127 | qDebug() << "testDataChanged: " << itemIndex; |
|
158 | qDebug() << "testDataChanged: " << itemIndex; | |
128 |
|
159 | |||
129 | switch (itemIndex) { |
|
160 | // switch (itemIndex) { | |
130 | case 0: { |
|
161 | // case 0: { | |
131 | QList<QChartDataPoint> data; |
|
162 | // QList<QChartDataPoint> data; | |
132 | for (int x = 0; x < 20; x++) { |
|
163 | // for (int x = 0; x < 20; x++) { | |
133 | data.append(QChartDataPoint() << x << x / 2); |
|
164 | // data.append(QChartDataPoint() << x << x / 2); | |
134 | } |
|
165 | // } | |
135 | m_chartWidget->setData(data); |
|
166 | // m_chartWidget->setData(data); | |
136 | break; |
|
167 | // break; | |
137 | } |
|
168 | // } | |
138 | case 1: { |
|
169 | // case 1: { | |
139 | QList<QChartDataPoint> data; |
|
170 | // QList<QChartDataPoint> data; | |
140 | for (int x = 0; x < 100; x++) { |
|
171 | // for (int x = 0; x < 100; x++) { | |
141 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); |
|
172 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100)); | |
142 | } |
|
173 | // } | |
143 | m_chartWidget->setData(data); |
|
174 | // m_chartWidget->setData(data); | |
144 | break; |
|
175 | // break; | |
145 | } |
|
176 | // } | |
146 | case 2: { |
|
177 | // case 2: { | |
147 | QList<QChartDataPoint> data; |
|
178 | // QList<QChartDataPoint> data; | |
148 | for (int x = 0; x < 1000; x++) { |
|
179 | // for (int x = 0; x < 1000; x++) { | |
149 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
180 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
150 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
181 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
151 | data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); |
|
182 | // data.append(QChartDataPoint() << x - 200 << 2 * (uint(sin(3.14159/50*x)*80) % 100) + (rand() % 100 * 0.2)); | |
152 | } |
|
183 | // } | |
153 | m_chartWidget->setData(data); |
|
184 | // m_chartWidget->setData(data); | |
154 | break; |
|
185 | // break; | |
155 | } |
|
186 | // } | |
156 | default: |
|
187 | // default: | |
157 | break; |
|
188 | // break; | |
158 | } |
|
189 | // } | |
159 |
|
||||
160 | } |
|
190 | } | |
161 |
|
191 | |||
162 | void MainWidget::backgroundChanged(int itemIndex) |
|
192 | void MainWidget::backgroundChanged(int itemIndex) | |
163 | { |
|
193 | { | |
164 | qDebug() << "backgroundChanged: " << itemIndex; |
|
194 | qDebug() << "backgroundChanged: " << itemIndex; | |
165 | } |
|
195 | } | |
166 |
|
196 | |||
167 | void MainWidget::autoScaleChanged(int value) |
|
197 | void MainWidget::autoScaleChanged(int value) | |
168 | { |
|
198 | { | |
169 | if (value) { |
|
199 | if (value) { | |
170 | // TODO: enable auto scaling |
|
200 | // TODO: enable auto scaling | |
171 | } else { |
|
201 | } else { | |
172 | // TODO: set scaling manually (and disable auto scaling) |
|
202 | // TODO: set scaling manually (and disable auto scaling) | |
173 | } |
|
203 | } | |
174 |
|
204 | |||
175 | m_xMinSpin->setEnabled(!value); |
|
205 | m_xMinSpin->setEnabled(!value); | |
176 | m_xMaxSpin->setEnabled(!value); |
|
206 | m_xMaxSpin->setEnabled(!value); | |
177 | m_yMinSpin->setEnabled(!value); |
|
207 | m_yMinSpin->setEnabled(!value); | |
178 | m_yMaxSpin->setEnabled(!value); |
|
208 | m_yMaxSpin->setEnabled(!value); | |
179 | } |
|
209 | } | |
180 |
|
210 | |||
181 | void MainWidget::xMinChanged(int value) |
|
211 | void MainWidget::xMinChanged(int value) | |
182 | { |
|
212 | { | |
183 | qDebug() << "xMinChanged: " << value; |
|
213 | qDebug() << "xMinChanged: " << value; | |
184 | } |
|
214 | } | |
185 |
|
215 | |||
186 | void MainWidget::xMaxChanged(int value) |
|
216 | void MainWidget::xMaxChanged(int value) | |
187 | { |
|
217 | { | |
188 | qDebug() << "xMaxChanged: " << value; |
|
218 | qDebug() << "xMaxChanged: " << value; | |
189 | } |
|
219 | } | |
190 |
|
220 | |||
191 | void MainWidget::yMinChanged(int value) |
|
221 | void MainWidget::yMinChanged(int value) | |
192 | { |
|
222 | { | |
193 | qDebug() << "yMinChanged: " << value; |
|
223 | qDebug() << "yMinChanged: " << value; | |
194 | } |
|
224 | } | |
195 |
|
225 | |||
196 | void MainWidget::yMaxChanged(int value) |
|
226 | void MainWidget::yMaxChanged(int value) | |
197 | { |
|
227 | { | |
198 | qDebug() << "yMaxChanged: " << value; |
|
228 | qDebug() << "yMaxChanged: " << value; | |
199 | } |
|
229 | } |
@@ -1,37 +1,42 | |||||
1 | #ifndef MAINWIDGET_H |
|
1 | #ifndef MAINWIDGET_H | |
2 | #define MAINWIDGET_H |
|
2 | #define MAINWIDGET_H | |
3 |
|
3 | |||
|
4 | #include <qchartconfig.h> | |||
|
5 | #include <qchartwidget.h> | |||
4 | #include <QWidget> |
|
6 | #include <QWidget> | |
5 |
|
7 | |||
6 | class QChartWidget; |
|
|||
7 | class QSpinBox; |
|
8 | class QSpinBox; | |
8 | class QCheckBox; |
|
9 | class QCheckBox; | |
9 |
|
10 | |||
|
11 | QCHART_USE_NAMESPACE | |||
|
12 | ||||
10 | class MainWidget : public QWidget |
|
13 | class MainWidget : public QWidget | |
11 | { |
|
14 | { | |
12 | Q_OBJECT |
|
15 | Q_OBJECT | |
13 | public: |
|
16 | public: | |
14 | explicit MainWidget(QWidget *parent = 0); |
|
17 | explicit MainWidget(QWidget *parent = 0); | |
15 |
|
18 | |||
16 | signals: |
|
19 | signals: | |
17 |
|
20 | |||
18 | private slots: |
|
21 | private slots: | |
19 | void chartTypeChanged(int itemIndex); |
|
22 | void chartTypeChanged(int itemIndex); | |
|
23 | void addSeries(); | |||
|
24 | void addSeries(QString series); | |||
20 | void testDataChanged(int itemIndex); |
|
25 | void testDataChanged(int itemIndex); | |
21 | void backgroundChanged(int itemIndex); |
|
26 | void backgroundChanged(int itemIndex); | |
22 | void autoScaleChanged(int value); |
|
27 | void autoScaleChanged(int value); | |
23 | void xMinChanged(int value); |
|
28 | void xMinChanged(int value); | |
24 | void xMaxChanged(int value); |
|
29 | void xMaxChanged(int value); | |
25 | void yMinChanged(int value); |
|
30 | void yMinChanged(int value); | |
26 | void yMaxChanged(int value); |
|
31 | void yMaxChanged(int value); | |
27 |
|
32 | |||
28 | private: |
|
33 | private: | |
29 | QChartWidget *m_chartWidget; |
|
34 | QChartWidget *m_chartWidget; | |
30 | QCheckBox *m_autoScaleCheck; |
|
35 | QCheckBox *m_autoScaleCheck; | |
31 | QSpinBox *m_xMinSpin; |
|
36 | QSpinBox *m_xMinSpin; | |
32 | QSpinBox *m_xMaxSpin; |
|
37 | QSpinBox *m_xMaxSpin; | |
33 | QSpinBox *m_yMinSpin; |
|
38 | QSpinBox *m_yMinSpin; | |
34 | QSpinBox *m_yMaxSpin; |
|
39 | QSpinBox *m_yMaxSpin; | |
35 | }; |
|
40 | }; | |
36 |
|
41 | |||
37 | #endif // MAINWIDGET_H |
|
42 | #endif // MAINWIDGET_H |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now