@@ -1,149 +1,145 | |||||
1 | #include "dataseriedialog.h" |
|
1 | #include "dataseriedialog.h" | |
2 | #include <QDialogButtonBox> |
|
2 | #include <QDialogButtonBox> | |
3 | #include <QGridLayout> |
|
3 | #include <QGridLayout> | |
4 | #include <QCheckbox> |
|
4 | #include <QCheckbox> | |
5 | #include <QPushButton> |
|
5 | #include <QPushButton> | |
6 | #include <QGroupBox> |
|
6 | #include <QGroupBox> | |
7 | #include <QRadioButton> |
|
7 | #include <QRadioButton> | |
8 | #include <QLabel> |
|
8 | #include <QLabel> | |
9 | #include <QDebug> |
|
9 | #include <QDebug> | |
10 |
|
10 | |||
11 | DataSerieDialog::DataSerieDialog(QString defaultType, QWidget *parent) : |
|
11 | DataSerieDialog::DataSerieDialog(QString defaultType, QWidget *parent) : | |
12 | QDialog(parent) |
|
12 | QDialog(parent) | |
13 | { |
|
13 | { | |
14 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); |
|
14 | QDialogButtonBox *addSeriesBox = new QDialogButtonBox(Qt::Horizontal); | |
15 | QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); |
|
15 | QPushButton *b = addSeriesBox->addButton(QDialogButtonBox::Ok); | |
16 | connect(b, SIGNAL(clicked()), this, SLOT(accept())); |
|
16 | connect(b, SIGNAL(clicked()), this, SLOT(accept())); | |
17 | b = addSeriesBox->addButton(QDialogButtonBox::Cancel); |
|
17 | b = addSeriesBox->addButton(QDialogButtonBox::Cancel); | |
18 | connect(b, SIGNAL(clicked()), this, SLOT(reject())); |
|
18 | connect(b, SIGNAL(clicked()), this, SLOT(reject())); | |
19 |
|
19 | |||
20 | QGridLayout *grid = new QGridLayout(); |
|
20 | QGridLayout *grid = new QGridLayout(); | |
21 |
|
21 | |||
22 | m_seriesTypeSelector = seriesTypeSelector(); |
|
22 | m_seriesTypeSelector = seriesTypeSelector(); | |
23 | m_columnCountSelector = columnCountSelector(); |
|
23 | m_columnCountSelector = columnCountSelector(); | |
24 | m_rowCountSelector = rowCountSelector(); |
|
24 | m_rowCountSelector = rowCountSelector(); | |
25 | m_dataCharacteristicsSelector = dataCharacteristicsSelector(); |
|
25 | m_dataCharacteristicsSelector = dataCharacteristicsSelector(); | |
26 |
|
26 | |||
27 | grid->addWidget(m_seriesTypeSelector, 0, 0); |
|
27 | grid->addWidget(m_seriesTypeSelector, 0, 0); | |
28 | grid->addWidget(m_columnCountSelector, 0, 1); |
|
28 | grid->addWidget(m_columnCountSelector, 0, 1); | |
29 | grid->addWidget(m_rowCountSelector, 1, 1); |
|
29 | grid->addWidget(m_rowCountSelector, 1, 1); | |
30 | grid->addWidget(m_dataCharacteristicsSelector, 1, 0); |
|
30 | grid->addWidget(m_dataCharacteristicsSelector, 1, 0); | |
31 | m_labelsSelector = new QCheckBox("Labels defined"); |
|
31 | m_labelsSelector = new QCheckBox("Labels defined"); | |
32 | m_labelsSelector->setChecked(true); |
|
32 | m_labelsSelector->setChecked(true); | |
33 | grid->addWidget(m_labelsSelector, 2, 0); |
|
33 | grid->addWidget(m_labelsSelector, 2, 0); | |
34 | grid->addWidget(addSeriesBox, 3, 1); |
|
34 | grid->addWidget(addSeriesBox, 3, 1); | |
35 |
|
35 | |||
36 | setLayout(grid); |
|
36 | setLayout(grid); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | QGroupBox *DataSerieDialog::seriesTypeSelector() |
|
39 | QGroupBox *DataSerieDialog::seriesTypeSelector() | |
40 | { |
|
40 | { | |
41 | QVBoxLayout *layout = new QVBoxLayout(); |
|
41 | QVBoxLayout *layout = new QVBoxLayout(); | |
42 |
|
42 | |||
43 |
QRadioButton *line = new QRadioButton(" |
|
43 | QRadioButton *line = new QRadioButton("Line"); | |
44 | QRadioButton *area = new QRadioButton("&Area"); |
|
|||
45 | QRadioButton *pie = new QRadioButton("&Pie"); |
|
|||
46 | QRadioButton *bar = new QRadioButton("&Bar"); |
|
|||
47 | QRadioButton *scatter = new QRadioButton("&Scatter"); |
|
|||
48 | QRadioButton *spline = new QRadioButton("Spl&ine"); |
|
|||
49 | line->setChecked(true); |
|
44 | line->setChecked(true); | |
50 |
|
||||
51 | layout->addWidget(line); |
|
45 | layout->addWidget(line); | |
52 | layout->addWidget(area); |
|
46 | layout->addWidget(new QRadioButton("Area")); | |
53 |
layout->addWidget( |
|
47 | layout->addWidget(new QRadioButton("Pie")); | |
54 |
layout->addWidget( |
|
48 | layout->addWidget(new QRadioButton("Bar")); | |
55 |
layout->addWidget( |
|
49 | layout->addWidget(new QRadioButton("Stacked bar")); | |
56 |
layout->addWidget( |
|
50 | layout->addWidget(new QRadioButton("Percent bar")); | |
|
51 | layout->addWidget(new QRadioButton("Scatter")); | |||
|
52 | layout->addWidget(new QRadioButton("Spline")); | |||
57 |
|
53 | |||
58 | QGroupBox *groupBox = new QGroupBox("Series type"); |
|
54 | QGroupBox *groupBox = new QGroupBox("Series type"); | |
59 | groupBox->setLayout(layout); |
|
55 | groupBox->setLayout(layout); | |
60 |
|
56 | |||
61 | return groupBox; |
|
57 | return groupBox; | |
62 | } |
|
58 | } | |
63 |
|
59 | |||
64 | QGroupBox *DataSerieDialog::columnCountSelector() |
|
60 | QGroupBox *DataSerieDialog::columnCountSelector() | |
65 | { |
|
61 | { | |
66 | QVBoxLayout *layout = new QVBoxLayout(); |
|
62 | QVBoxLayout *layout = new QVBoxLayout(); | |
67 |
|
63 | |||
68 | QRadioButton *radio = new QRadioButton("1"); |
|
64 | QRadioButton *radio = new QRadioButton("1"); | |
69 | radio->setChecked(true); |
|
65 | radio->setChecked(true); | |
70 | layout->addWidget(radio); |
|
66 | layout->addWidget(radio); | |
71 | layout->addWidget(new QRadioButton("2")); |
|
67 | layout->addWidget(new QRadioButton("2")); | |
72 | layout->addWidget(new QRadioButton("3")); |
|
68 | layout->addWidget(new QRadioButton("3")); | |
73 | layout->addWidget(new QRadioButton("5")); |
|
69 | layout->addWidget(new QRadioButton("5")); | |
74 | layout->addWidget(new QRadioButton("10")); |
|
70 | layout->addWidget(new QRadioButton("10")); | |
75 | layout->addWidget(new QRadioButton("100")); |
|
71 | layout->addWidget(new QRadioButton("100")); | |
76 |
|
72 | |||
77 | QGroupBox *groupBox = new QGroupBox("Column count"); |
|
73 | QGroupBox *groupBox = new QGroupBox("Column count"); | |
78 | groupBox->setLayout(layout); |
|
74 | groupBox->setLayout(layout); | |
79 |
|
75 | |||
80 | return groupBox; |
|
76 | return groupBox; | |
81 | } |
|
77 | } | |
82 |
|
78 | |||
83 | QGroupBox *DataSerieDialog::rowCountSelector() |
|
79 | QGroupBox *DataSerieDialog::rowCountSelector() | |
84 | { |
|
80 | { | |
85 | QVBoxLayout *layout = new QVBoxLayout(); |
|
81 | QVBoxLayout *layout = new QVBoxLayout(); | |
86 |
|
82 | |||
87 | layout->addWidget(new QRadioButton("1")); |
|
83 | layout->addWidget(new QRadioButton("1")); | |
88 | QRadioButton *radio = new QRadioButton("10"); |
|
84 | QRadioButton *radio = new QRadioButton("10"); | |
89 | radio->setChecked(true); |
|
85 | radio->setChecked(true); | |
90 | layout->addWidget(radio); |
|
86 | layout->addWidget(radio); | |
91 | layout->addWidget(new QRadioButton("50")); |
|
87 | layout->addWidget(new QRadioButton("50")); | |
92 | layout->addWidget(new QRadioButton("100")); |
|
88 | layout->addWidget(new QRadioButton("100")); | |
93 | layout->addWidget(new QRadioButton("10000")); |
|
89 | layout->addWidget(new QRadioButton("10000")); | |
94 | layout->addWidget(new QRadioButton("1000000")); |
|
90 | layout->addWidget(new QRadioButton("1000000")); | |
95 |
|
91 | |||
96 | QGroupBox *groupBox = new QGroupBox("Row count"); |
|
92 | QGroupBox *groupBox = new QGroupBox("Row count"); | |
97 | groupBox->setLayout(layout); |
|
93 | groupBox->setLayout(layout); | |
98 |
|
94 | |||
99 | return groupBox; |
|
95 | return groupBox; | |
100 | } |
|
96 | } | |
101 |
|
97 | |||
102 | QGroupBox *DataSerieDialog::dataCharacteristicsSelector() |
|
98 | QGroupBox *DataSerieDialog::dataCharacteristicsSelector() | |
103 | { |
|
99 | { | |
104 | QVBoxLayout *layout = new QVBoxLayout(); |
|
100 | QVBoxLayout *layout = new QVBoxLayout(); | |
105 |
|
101 | |||
106 | QRadioButton *radio1 = new QRadioButton("Linear"); |
|
102 | QRadioButton *radio1 = new QRadioButton("Linear"); | |
107 | radio1->setChecked(true); |
|
103 | radio1->setChecked(true); | |
108 | layout->addWidget(radio1); |
|
104 | layout->addWidget(radio1); | |
109 | layout->addWidget(new QRadioButton("Constant")); |
|
105 | layout->addWidget(new QRadioButton("Constant")); | |
110 | layout->addWidget(new QRadioButton("Random")); |
|
106 | layout->addWidget(new QRadioButton("Random")); | |
111 | layout->addWidget(new QRadioButton("Sin")); |
|
107 | layout->addWidget(new QRadioButton("Sin")); | |
112 | layout->addWidget(new QRadioButton("Sin + random")); |
|
108 | layout->addWidget(new QRadioButton("Sin + random")); | |
113 |
|
109 | |||
114 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); |
|
110 | QGroupBox *groupBox = new QGroupBox("Data Characteristics"); | |
115 | groupBox->setLayout(layout); |
|
111 | groupBox->setLayout(layout); | |
116 |
|
112 | |||
117 | return groupBox; |
|
113 | return groupBox; | |
118 | } |
|
114 | } | |
119 |
|
115 | |||
120 | void DataSerieDialog::accept() |
|
116 | void DataSerieDialog::accept() | |
121 | { |
|
117 | { | |
122 | accepted(radioSelection(m_seriesTypeSelector), |
|
118 | accepted(radioSelection(m_seriesTypeSelector), | |
123 | radioSelection(m_columnCountSelector).toInt(), |
|
119 | radioSelection(m_columnCountSelector).toInt(), | |
124 | radioSelection(m_rowCountSelector).toInt(), |
|
120 | radioSelection(m_rowCountSelector).toInt(), | |
125 | radioSelection(m_dataCharacteristicsSelector), |
|
121 | radioSelection(m_dataCharacteristicsSelector), | |
126 | m_labelsSelector->isChecked()); |
|
122 | m_labelsSelector->isChecked()); | |
127 | QDialog::accept(); |
|
123 | QDialog::accept(); | |
128 | } |
|
124 | } | |
129 |
|
125 | |||
130 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) |
|
126 | QString DataSerieDialog::radioSelection(QGroupBox *groupBox) | |
131 | { |
|
127 | { | |
132 | QString selection; |
|
128 | QString selection; | |
133 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); |
|
129 | QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); | |
134 | Q_ASSERT(layout); |
|
130 | Q_ASSERT(layout); | |
135 |
|
131 | |||
136 | for (int i(0); i < layout->count(); i++) { |
|
132 | for (int i(0); i < layout->count(); i++) { | |
137 | QLayoutItem *item = layout->itemAt(i); |
|
133 | QLayoutItem *item = layout->itemAt(i); | |
138 | Q_ASSERT(item); |
|
134 | Q_ASSERT(item); | |
139 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); |
|
135 | QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); | |
140 | Q_ASSERT(radio); |
|
136 | Q_ASSERT(radio); | |
141 | if (radio->isChecked()) { |
|
137 | if (radio->isChecked()) { | |
142 | selection = radio->text(); |
|
138 | selection = radio->text(); | |
143 | break; |
|
139 | break; | |
144 | } |
|
140 | } | |
145 | } |
|
141 | } | |
146 |
|
142 | |||
147 | qDebug() << "radioSelection: " << selection; |
|
143 | qDebug() << "radioSelection: " << selection; | |
148 | return selection; |
|
144 | return selection; | |
149 | } |
|
145 | } |
@@ -1,343 +1,395 | |||||
1 | #include "mainwidget.h" |
|
1 | #include "mainwidget.h" | |
2 | #include "dataseriedialog.h" |
|
2 | #include "dataseriedialog.h" | |
3 | #include "qchartseries.h" |
|
3 | #include "qchartseries.h" | |
4 | #include "qpieseries.h" |
|
4 | #include "qpieseries.h" | |
5 | #include "qscatterseries.h" |
|
5 | #include "qscatterseries.h" | |
6 | #include <qlinechartseries.h> |
|
6 | #include <qlinechartseries.h> | |
7 | #include <qbarset.h> |
|
7 | #include <qbarset.h> | |
8 | #include <qbarcategory.h> |
|
8 | #include <qbarcategory.h> | |
9 | #include <qbarchartseries.h> |
|
9 | #include <qbarchartseries.h> | |
10 | #include <qstackedbarchartseries.h> |
|
10 | #include <qstackedbarchartseries.h> | |
11 | #include <qpercentbarchartseries.h> |
|
11 | #include <qpercentbarchartseries.h> | |
12 | #include <QPushButton> |
|
12 | #include <QPushButton> | |
13 | #include <QComboBox> |
|
13 | #include <QComboBox> | |
14 | #include <QSpinBox> |
|
14 | #include <QSpinBox> | |
15 | #include <QCheckBox> |
|
15 | #include <QCheckBox> | |
16 | #include <QGridLayout> |
|
16 | #include <QGridLayout> | |
17 | #include <QHBoxLayout> |
|
17 | #include <QHBoxLayout> | |
18 | #include <QLabel> |
|
18 | #include <QLabel> | |
19 | #include <QSpacerItem> |
|
19 | #include <QSpacerItem> | |
20 | #include <QMessageBox> |
|
20 | #include <QMessageBox> | |
21 | #include <cmath> |
|
21 | #include <cmath> | |
22 | #include <QDebug> |
|
22 | #include <QDebug> | |
23 | #include <QStandardItemModel> |
|
23 | #include <QStandardItemModel> | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
26 | QTCOMMERCIALCHART_USE_NAMESPACE | |
27 |
|
27 | |||
28 | MainWidget::MainWidget(QWidget *parent) : |
|
28 | MainWidget::MainWidget(QWidget *parent) : | |
29 | QWidget(parent) |
|
29 | QWidget(parent) | |
30 | { |
|
30 | { | |
31 | m_chartWidget = new QChartView(this); |
|
31 | m_chartWidget = new QChartView(this); | |
32 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); |
|
32 | m_chartWidget->setRubberBandPolicy(QChartView::HorizonalRubberBand); | |
33 |
|
33 | |||
34 | // Grid layout for the controls for configuring the chart widget |
|
34 | // Grid layout for the controls for configuring the chart widget | |
35 | QGridLayout *grid = new QGridLayout(); |
|
35 | QGridLayout *grid = new QGridLayout(); | |
36 | QPushButton *addSeriesButton = new QPushButton("Add series"); |
|
36 | QPushButton *addSeriesButton = new QPushButton("Add series"); | |
37 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); |
|
37 | connect(addSeriesButton, SIGNAL(clicked()), this, SLOT(addSeries())); | |
38 | grid->addWidget(addSeriesButton, 0, 1); |
|
38 | grid->addWidget(addSeriesButton, 0, 1); | |
39 | initBackroundCombo(grid); |
|
39 | initBackroundCombo(grid); | |
40 | initScaleControls(grid); |
|
40 | initScaleControls(grid); | |
41 | initThemeCombo(grid); |
|
41 | initThemeCombo(grid); | |
42 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); |
|
42 | QCheckBox *zoomCheckBox = new QCheckBox("Drag'n drop Zoom"); | |
43 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); |
|
43 | connect(zoomCheckBox, SIGNAL(toggled(bool)), m_chartWidget, SLOT(setZoomEnabled(bool))); | |
44 | zoomCheckBox->setChecked(true); |
|
44 | zoomCheckBox->setChecked(true); | |
45 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); |
|
45 | grid->addWidget(zoomCheckBox, grid->rowCount(), 0); | |
46 | // add row with empty label to make all the other rows static |
|
46 | // add row with empty label to make all the other rows static | |
47 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); |
|
47 | grid->addWidget(new QLabel(""), grid->rowCount(), 0); | |
48 | grid->setRowStretch(grid->rowCount() - 1, 1); |
|
48 | grid->setRowStretch(grid->rowCount() - 1, 1); | |
49 |
|
49 | |||
50 | // Another grid layout as a main layout |
|
50 | // Another grid layout as a main layout | |
51 | QGridLayout *mainLayout = new QGridLayout(); |
|
51 | QGridLayout *mainLayout = new QGridLayout(); | |
52 | mainLayout->addLayout(grid, 0, 0); |
|
52 | mainLayout->addLayout(grid, 0, 0); | |
53 |
|
53 | |||
54 | // Init series type specific controls |
|
54 | // Init series type specific controls | |
55 | initPieControls(); |
|
55 | initPieControls(); | |
56 | mainLayout->addLayout(m_pieLayout, 2, 0); |
|
56 | mainLayout->addLayout(m_pieLayout, 2, 0); | |
57 | // Scatter series specific settings |
|
57 | // Scatter series specific settings | |
58 | // m_scatterLayout = new QGridLayout(); |
|
58 | // m_scatterLayout = new QGridLayout(); | |
59 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); |
|
59 | // m_scatterLayout->addWidget(new QLabel("scatter"), 0, 0); | |
60 | // m_scatterLayout->setEnabled(false); |
|
60 | // m_scatterLayout->setEnabled(false); | |
61 | // mainLayout->addLayout(m_scatterLayout, 1, 0); |
|
61 | // mainLayout->addLayout(m_scatterLayout, 1, 0); | |
62 |
|
62 | |||
63 | // Add layouts and the chart widget to the main layout |
|
63 | // Add layouts and the chart widget to the main layout | |
64 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); |
|
64 | mainLayout->addWidget(m_chartWidget, 0, 1, 3, 1); | |
65 | setLayout(mainLayout); |
|
65 | setLayout(mainLayout); | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | // Combo box for selecting the chart's background |
|
68 | // Combo box for selecting the chart's background | |
69 | void MainWidget::initBackroundCombo(QGridLayout *grid) |
|
69 | void MainWidget::initBackroundCombo(QGridLayout *grid) | |
70 | { |
|
70 | { | |
71 | QComboBox *backgroundCombo = new QComboBox(this); |
|
71 | QComboBox *backgroundCombo = new QComboBox(this); | |
72 | backgroundCombo->addItem("Color"); |
|
72 | backgroundCombo->addItem("Color"); | |
73 | backgroundCombo->addItem("Gradient"); |
|
73 | backgroundCombo->addItem("Gradient"); | |
74 | backgroundCombo->addItem("Image"); |
|
74 | backgroundCombo->addItem("Image"); | |
75 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), |
|
75 | connect(backgroundCombo, SIGNAL(currentIndexChanged(int)), | |
76 | this, SLOT(backgroundChanged(int))); |
|
76 | this, SLOT(backgroundChanged(int))); | |
77 |
|
77 | |||
78 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); |
|
78 | grid->addWidget(new QLabel("Background:"), grid->rowCount(), 0); | |
79 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); |
|
79 | grid->addWidget(backgroundCombo, grid->rowCount() - 1, 1); | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | // Scale related controls (auto-scale vs. manual min-max values) |
|
82 | // Scale related controls (auto-scale vs. manual min-max values) | |
83 | void MainWidget::initScaleControls(QGridLayout *grid) |
|
83 | void MainWidget::initScaleControls(QGridLayout *grid) | |
84 | { |
|
84 | { | |
85 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); |
|
85 | m_autoScaleCheck = new QCheckBox("Automatic scaling"); | |
86 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); |
|
86 | connect(m_autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
87 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
87 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
88 | m_xMinSpin = new QSpinBox(); |
|
88 | m_xMinSpin = new QSpinBox(); | |
89 | m_xMinSpin->setMinimum(INT_MIN); |
|
89 | m_xMinSpin->setMinimum(INT_MIN); | |
90 | m_xMinSpin->setMaximum(INT_MAX); |
|
90 | m_xMinSpin->setMaximum(INT_MAX); | |
91 | m_xMinSpin->setValue(0); |
|
91 | m_xMinSpin->setValue(0); | |
92 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
92 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
93 | m_xMaxSpin = new QSpinBox(); |
|
93 | m_xMaxSpin = new QSpinBox(); | |
94 | m_xMaxSpin->setMinimum(INT_MIN); |
|
94 | m_xMaxSpin->setMinimum(INT_MIN); | |
95 | m_xMaxSpin->setMaximum(INT_MAX); |
|
95 | m_xMaxSpin->setMaximum(INT_MAX); | |
96 | m_xMaxSpin->setValue(10); |
|
96 | m_xMaxSpin->setValue(10); | |
97 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
97 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
98 | m_yMinSpin = new QSpinBox(); |
|
98 | m_yMinSpin = new QSpinBox(); | |
99 | m_yMinSpin->setMinimum(INT_MIN); |
|
99 | m_yMinSpin->setMinimum(INT_MIN); | |
100 | m_yMinSpin->setMaximum(INT_MAX); |
|
100 | m_yMinSpin->setMaximum(INT_MAX); | |
101 | m_yMinSpin->setValue(0); |
|
101 | m_yMinSpin->setValue(0); | |
102 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
102 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
103 | m_yMaxSpin = new QSpinBox(); |
|
103 | m_yMaxSpin = new QSpinBox(); | |
104 | m_yMaxSpin->setMinimum(INT_MIN); |
|
104 | m_yMaxSpin->setMinimum(INT_MIN); | |
105 | m_yMaxSpin->setMaximum(INT_MAX); |
|
105 | m_yMaxSpin->setMaximum(INT_MAX); | |
106 | m_yMaxSpin->setValue(10); |
|
106 | m_yMaxSpin->setValue(10); | |
107 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
107 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
108 |
|
108 | |||
109 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); |
|
109 | grid->addWidget(m_autoScaleCheck, grid->rowCount(), 0); | |
110 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); |
|
110 | grid->addWidget(new QLabel("x min:"), grid->rowCount(), 0); | |
111 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); |
|
111 | grid->addWidget(m_xMinSpin, grid->rowCount() - 1, 1); | |
112 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); |
|
112 | grid->addWidget(new QLabel("x max:"), grid->rowCount(), 0); | |
113 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); |
|
113 | grid->addWidget(m_xMaxSpin, grid->rowCount() - 1, 1); | |
114 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); |
|
114 | grid->addWidget(new QLabel("y min:"), grid->rowCount(), 0); | |
115 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); |
|
115 | grid->addWidget(m_yMinSpin, grid->rowCount() - 1, 1); | |
116 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); |
|
116 | grid->addWidget(new QLabel("y max:"), grid->rowCount(), 0); | |
117 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); |
|
117 | grid->addWidget(m_yMaxSpin, grid->rowCount() - 1, 1); | |
118 |
|
118 | |||
119 | m_autoScaleCheck->setChecked(true); |
|
119 | m_autoScaleCheck->setChecked(true); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | // Combo box for selecting theme |
|
122 | // Combo box for selecting theme | |
123 | void MainWidget::initThemeCombo(QGridLayout *grid) |
|
123 | void MainWidget::initThemeCombo(QGridLayout *grid) | |
124 | { |
|
124 | { | |
125 | QComboBox *chartTheme = new QComboBox(); |
|
125 | QComboBox *chartTheme = new QComboBox(); | |
126 | chartTheme->addItem("Default"); |
|
126 | chartTheme->addItem("Default"); | |
127 | chartTheme->addItem("Vanilla"); |
|
127 | chartTheme->addItem("Vanilla"); | |
128 | chartTheme->addItem("Icy"); |
|
128 | chartTheme->addItem("Icy"); | |
129 | chartTheme->addItem("Grayscale"); |
|
129 | chartTheme->addItem("Grayscale"); | |
130 | chartTheme->addItem("Scientific"); |
|
130 | chartTheme->addItem("Scientific"); | |
131 | chartTheme->addItem("Unnamed1"); |
|
131 | chartTheme->addItem("Unnamed1"); | |
132 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), |
|
132 | connect(chartTheme, SIGNAL(currentIndexChanged(int)), | |
133 | this, SLOT(changeChartTheme(int))); |
|
133 | this, SLOT(changeChartTheme(int))); | |
134 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); |
|
134 | grid->addWidget(new QLabel("Chart theme:"), 8, 0); | |
135 | grid->addWidget(chartTheme, 8, 1); |
|
135 | grid->addWidget(chartTheme, 8, 1); | |
136 | } |
|
136 | } | |
137 |
|
137 | |||
138 | void MainWidget::initPieControls() |
|
138 | void MainWidget::initPieControls() | |
139 | { |
|
139 | { | |
140 | // Pie series specific settings |
|
140 | // Pie series specific settings | |
141 | // Pie size factory |
|
141 | // Pie size factory | |
142 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); |
|
142 | QDoubleSpinBox *pieSizeSpin = new QDoubleSpinBox(); | |
143 | pieSizeSpin->setMinimum(LONG_MIN); |
|
143 | pieSizeSpin->setMinimum(LONG_MIN); | |
144 | pieSizeSpin->setMaximum(LONG_MAX); |
|
144 | pieSizeSpin->setMaximum(LONG_MAX); | |
145 | pieSizeSpin->setValue(1.0); |
|
145 | pieSizeSpin->setValue(1.0); | |
146 | pieSizeSpin->setSingleStep(0.1); |
|
146 | pieSizeSpin->setSingleStep(0.1); | |
147 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); |
|
147 | connect(pieSizeSpin, SIGNAL(valueChanged(double)), this, SLOT(setPieSizeFactor(double))); | |
148 | // Pie position |
|
148 | // Pie position | |
149 | QComboBox *piePosCombo = new QComboBox(this); |
|
149 | QComboBox *piePosCombo = new QComboBox(this); | |
150 | piePosCombo->addItem("Maximized"); |
|
150 | piePosCombo->addItem("Maximized"); | |
151 | piePosCombo->addItem("Top left"); |
|
151 | piePosCombo->addItem("Top left"); | |
152 | piePosCombo->addItem("Top right"); |
|
152 | piePosCombo->addItem("Top right"); | |
153 | piePosCombo->addItem("Bottom left"); |
|
153 | piePosCombo->addItem("Bottom left"); | |
154 | piePosCombo->addItem("Bottom right"); |
|
154 | piePosCombo->addItem("Bottom right"); | |
155 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), |
|
155 | connect(piePosCombo, SIGNAL(currentIndexChanged(int)), | |
156 | this, SLOT(setPiePosition(int))); |
|
156 | this, SLOT(setPiePosition(int))); | |
157 | m_pieLayout = new QGridLayout(); |
|
157 | m_pieLayout = new QGridLayout(); | |
158 | m_pieLayout->setEnabled(false); |
|
158 | m_pieLayout->setEnabled(false); | |
159 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); |
|
159 | m_pieLayout->addWidget(new QLabel("Pie size factor"), 0, 0); | |
160 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); |
|
160 | m_pieLayout->addWidget(pieSizeSpin, 0, 1); | |
161 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); |
|
161 | m_pieLayout->addWidget(new QLabel("Pie position"), 1, 0); | |
162 | m_pieLayout->addWidget(piePosCombo, 1, 1); |
|
162 | m_pieLayout->addWidget(piePosCombo, 1, 1); | |
163 | } |
|
163 | } | |
164 |
|
164 | |||
165 | void MainWidget::addSeries() |
|
165 | void MainWidget::addSeries() | |
166 | { |
|
166 | { | |
167 | DataSerieDialog dialog(m_defaultSeriesName, this); |
|
167 | DataSerieDialog dialog(m_defaultSeriesName, this); | |
168 | connect(&dialog, SIGNAL(accepted(QString, int, int, QString, bool)), |
|
168 | connect(&dialog, SIGNAL(accepted(QString, int, int, QString, bool)), | |
169 | this, SLOT(addSeries(QString, int, int, QString, bool))); |
|
169 | this, SLOT(addSeries(QString, int, int, QString, bool))); | |
170 | dialog.exec(); |
|
170 | dialog.exec(); | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) |
|
173 | QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QString dataCharacteristics) | |
174 | { |
|
174 | { | |
175 | // TODO: dataCharacteristics |
|
175 | // TODO: dataCharacteristics | |
176 | QList<RealList> testData; |
|
176 | QList<RealList> testData; | |
177 | for (int j(0); j < columnCount; j++) { |
|
177 | for (int j(0); j < columnCount; j++) { | |
178 | QList <qreal> newColumn; |
|
178 | QList <qreal> newColumn; | |
179 | for (int i(0); i < rowCount; i++) { |
|
179 | for (int i(0); i < rowCount; i++) { | |
180 | if (dataCharacteristics == "Sin") { |
|
180 | if (dataCharacteristics == "Sin") { | |
181 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100)); |
|
181 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100)); | |
182 | } else if (dataCharacteristics == "Sin + random") { |
|
182 | } else if (dataCharacteristics == "Sin + random") { | |
183 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); |
|
183 | newColumn.append(abs(sin(3.14159265358979 / 50 * i) * 100) + (rand() % 5)); | |
184 | } else if (dataCharacteristics == "Random") { |
|
184 | } else if (dataCharacteristics == "Random") { | |
185 | newColumn.append(rand() % 5); |
|
185 | newColumn.append(rand() % 5); | |
186 | } else if (dataCharacteristics == "Linear") { |
|
186 | } else if (dataCharacteristics == "Linear") { | |
187 | //newColumn.append(i * (j + 1.0)); |
|
187 | //newColumn.append(i * (j + 1.0)); | |
188 | // TODO: temporary hack to make pie work; prevent zero values: |
|
188 | // TODO: temporary hack to make pie work; prevent zero values: | |
189 | newColumn.append(i * (j + 1.0) + 0.1); |
|
189 | newColumn.append(i * (j + 1.0) + 0.1); | |
190 | } else { // "constant" |
|
190 | } else { // "constant" | |
191 | newColumn.append((j + 1.0)); |
|
191 | newColumn.append((j + 1.0)); | |
192 | } |
|
192 | } | |
193 | } |
|
193 | } | |
194 | testData.append(newColumn); |
|
194 | testData.append(newColumn); | |
195 | } |
|
195 | } | |
196 | return testData; |
|
196 | return testData; | |
197 | } |
|
197 | } | |
198 |
|
198 | |||
199 | QStringList MainWidget::generateLabels(int count) |
|
199 | QStringList MainWidget::generateLabels(int count) | |
200 | { |
|
200 | { | |
201 | QStringList result; |
|
201 | QStringList result; | |
202 | for (int i(0); i < count; i++) |
|
202 | for (int i(0); i < count; i++) | |
203 | result.append("label" + QString::number(i)); |
|
203 | result.append("label" + QString::number(i)); | |
204 | return result; |
|
204 | return result; | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled) |
|
207 | void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QString dataCharacteristics, bool labelsEnabled) | |
208 | { |
|
208 | { | |
209 | qDebug() << "addSeries: " << seriesName |
|
209 | qDebug() << "addSeries: " << seriesName | |
210 | << " columnCount: " << columnCount |
|
210 | << " columnCount: " << columnCount | |
211 | << " rowCount: " << rowCount |
|
211 | << " rowCount: " << rowCount | |
212 | << " dataCharacteristics: " << dataCharacteristics |
|
212 | << " dataCharacteristics: " << dataCharacteristics | |
213 | << " labels enabled: " << labelsEnabled; |
|
213 | << " labels enabled: " << labelsEnabled; | |
214 | m_defaultSeriesName = seriesName; |
|
214 | m_defaultSeriesName = seriesName; | |
215 |
|
215 | |||
216 | QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics); |
|
216 | QList<RealList> data = generateTestData(columnCount, rowCount, dataCharacteristics); | |
217 |
|
217 | |||
218 | // Line series and scatter series use similar data |
|
218 | // Line series and scatter series use similar data | |
219 | if (seriesName.contains("line", Qt::CaseInsensitive)) { |
|
219 | if (seriesName.contains("line", Qt::CaseInsensitive)) { | |
220 | for (int j(0); j < data.count(); j ++) { |
|
220 | for (int j(0); j < data.count(); j ++) { | |
221 | QList<qreal> column = data.at(j); |
|
221 | QList<qreal> column = data.at(j); | |
222 | QLineChartSeries *series = new QLineChartSeries(); |
|
222 | QLineChartSeries *series = new QLineChartSeries(); | |
223 | for (int i(0); i < column.count(); i++) { |
|
223 | for (int i(0); i < column.count(); i++) { | |
224 | series->add(i, column.at(i)); |
|
224 | series->add(i, column.at(i)); | |
225 | } |
|
225 | } | |
226 | m_chartWidget->addSeries(series); |
|
226 | m_chartWidget->addSeries(series); | |
227 | setCurrentSeries(series); |
|
227 | setCurrentSeries(series); | |
228 | } |
|
228 | } | |
229 | } else if (seriesName.contains("scatter", Qt::CaseInsensitive)) { |
|
229 | } else if (seriesName.contains("scatter", Qt::CaseInsensitive)) { | |
230 | for (int j(0); j < data.count(); j++) { |
|
230 | for (int j(0); j < data.count(); j++) { | |
231 | QList<qreal> column = data.at(j); |
|
231 | QList<qreal> column = data.at(j); | |
232 | QScatterSeries *series = new QScatterSeries(); |
|
232 | QScatterSeries *series = new QScatterSeries(); | |
233 | for (int i(0); i < column.count(); i++) { |
|
233 | for (int i(0); i < column.count(); i++) { | |
234 | (*series) << QPointF(i, column.at(i)); |
|
234 | (*series) << QPointF(i, column.at(i)); | |
235 | } |
|
235 | } | |
236 | m_chartWidget->addSeries(series); |
|
236 | m_chartWidget->addSeries(series); | |
237 | setCurrentSeries(series); |
|
237 | setCurrentSeries(series); | |
238 | } |
|
238 | } | |
239 | } else if (seriesName.contains("pie", Qt::CaseInsensitive)) { |
|
239 | } else if (seriesName.contains("pie", Qt::CaseInsensitive)) { | |
240 | QStringList labels = generateLabels(rowCount); |
|
240 | QStringList labels = generateLabels(rowCount); | |
241 | for (int j(0); j < data.count(); j++) { |
|
241 | for (int j(0); j < data.count(); j++) { | |
242 | QPieSeries *series = new QPieSeries(); |
|
242 | QPieSeries *series = new QPieSeries(); | |
243 | QList<qreal> column = data.at(j); |
|
243 | QList<qreal> column = data.at(j); | |
244 | for (int i(0); i < column.count(); i++) { |
|
244 | for (int i(0); i < column.count(); i++) { | |
245 | series->add(column.at(i), labels.at(i)); |
|
245 | series->add(column.at(i), labels.at(i)); | |
246 | } |
|
246 | } | |
247 | m_chartWidget->addSeries(series); |
|
247 | m_chartWidget->addSeries(series); | |
248 | setCurrentSeries(series); |
|
248 | setCurrentSeries(series); | |
249 | } |
|
249 | } | |
|
250 | } else if (seriesName == "Bar") { | |||
|
251 | // TODO: replace QBarCategory with QStringList? | |||
|
252 | QBarCategory *category = new QBarCategory; | |||
|
253 | QStringList labels = generateLabels(rowCount); | |||
|
254 | foreach(QString label, labels) | |||
|
255 | *category << label; | |||
|
256 | QBarChartSeries* series = new QBarChartSeries(category, this); | |||
|
257 | ||||
|
258 | for (int j(0); j < data.count(); j++) { | |||
|
259 | QList<qreal> column = data.at(j); | |||
|
260 | QBarSet *set = new QBarSet; | |||
|
261 | for (int i(0); i < column.count(); i++) { | |||
|
262 | *set << column.at(i); | |||
|
263 | } | |||
|
264 | series->addBarSet(set); | |||
|
265 | } | |||
|
266 | m_chartWidget->addSeries(series); | |||
|
267 | setCurrentSeries(series); | |||
|
268 | } else if (seriesName == "Stacked bar") { | |||
|
269 | QBarCategory *category = new QBarCategory; | |||
|
270 | QStringList labels = generateLabels(rowCount); | |||
|
271 | foreach(QString label, labels) | |||
|
272 | *category << label; | |||
|
273 | QStackedBarChartSeries* series = new QStackedBarChartSeries(category, this); | |||
|
274 | ||||
|
275 | for (int j(0); j < data.count(); j++) { | |||
|
276 | QList<qreal> column = data.at(j); | |||
|
277 | QBarSet *set = new QBarSet; | |||
|
278 | for (int i(0); i < column.count(); i++) { | |||
|
279 | *set << column.at(i); | |||
|
280 | } | |||
|
281 | series->addBarSet(set); | |||
|
282 | } | |||
|
283 | m_chartWidget->addSeries(series); | |||
|
284 | setCurrentSeries(series); | |||
|
285 | } else if (seriesName == "Percent bar") { | |||
|
286 | QBarCategory *category = new QBarCategory; | |||
|
287 | QStringList labels = generateLabels(rowCount); | |||
|
288 | foreach(QString label, labels) | |||
|
289 | *category << label; | |||
|
290 | QPercentBarChartSeries* series = new QPercentBarChartSeries(category, this); | |||
|
291 | ||||
|
292 | for (int j(0); j < data.count(); j++) { | |||
|
293 | QList<qreal> column = data.at(j); | |||
|
294 | QBarSet *set = new QBarSet; | |||
|
295 | for (int i(0); i < column.count(); i++) { | |||
|
296 | *set << column.at(i); | |||
|
297 | } | |||
|
298 | series->addBarSet(set); | |||
|
299 | } | |||
|
300 | m_chartWidget->addSeries(series); | |||
|
301 | setCurrentSeries(series); | |||
250 | } |
|
302 | } | |
251 |
|
303 | |||
252 |
// TODO: |
|
304 | // TODO: spline and area | |
253 | } |
|
305 | } | |
254 |
|
306 | |||
255 | void MainWidget::setCurrentSeries(QChartSeries *series) |
|
307 | void MainWidget::setCurrentSeries(QChartSeries *series) | |
256 | { |
|
308 | { | |
257 | if (series) { |
|
309 | if (series) { | |
258 | m_currentSeries = series; |
|
310 | m_currentSeries = series; | |
259 | switch (m_currentSeries->type()) { |
|
311 | switch (m_currentSeries->type()) { | |
260 | case QChartSeries::SeriesTypeLine: |
|
312 | case QChartSeries::SeriesTypeLine: | |
261 | break; |
|
313 | break; | |
262 | case QChartSeries::SeriesTypeScatter: |
|
314 | case QChartSeries::SeriesTypeScatter: | |
263 | break; |
|
315 | break; | |
264 | case QChartSeries::SeriesTypePie: |
|
316 | case QChartSeries::SeriesTypePie: | |
265 | break; |
|
317 | break; | |
266 | case QChartSeries::SeriesTypeBar: |
|
318 | case QChartSeries::SeriesTypeBar: | |
267 | qDebug() << "setCurrentSeries (bar)"; |
|
319 | qDebug() << "setCurrentSeries (bar)"; | |
268 | break; |
|
320 | break; | |
269 | case QChartSeries::SeriesTypeStackedBar: |
|
321 | case QChartSeries::SeriesTypeStackedBar: | |
270 | qDebug() << "setCurrentSeries (Stackedbar)"; |
|
322 | qDebug() << "setCurrentSeries (Stackedbar)"; | |
271 | break; |
|
323 | break; | |
272 | case QChartSeries::SeriesTypePercentBar: |
|
324 | case QChartSeries::SeriesTypePercentBar: | |
273 | qDebug() << "setCurrentSeries (Percentbar)"; |
|
325 | qDebug() << "setCurrentSeries (Percentbar)"; | |
274 | break; |
|
326 | break; | |
275 | default: |
|
327 | default: | |
276 | Q_ASSERT(false); |
|
328 | Q_ASSERT(false); | |
277 | break; |
|
329 | break; | |
278 | } |
|
330 | } | |
279 | } |
|
331 | } | |
280 | } |
|
332 | } | |
281 |
|
333 | |||
282 | void MainWidget::backgroundChanged(int itemIndex) |
|
334 | void MainWidget::backgroundChanged(int itemIndex) | |
283 | { |
|
335 | { | |
284 | qDebug() << "backgroundChanged: " << itemIndex; |
|
336 | qDebug() << "backgroundChanged: " << itemIndex; | |
285 | } |
|
337 | } | |
286 |
|
338 | |||
287 | void MainWidget::autoScaleChanged(int value) |
|
339 | void MainWidget::autoScaleChanged(int value) | |
288 | { |
|
340 | { | |
289 | if (value) { |
|
341 | if (value) { | |
290 | // TODO: enable auto scaling |
|
342 | // TODO: enable auto scaling | |
291 | } else { |
|
343 | } else { | |
292 | // TODO: set scaling manually (and disable auto scaling) |
|
344 | // TODO: set scaling manually (and disable auto scaling) | |
293 | } |
|
345 | } | |
294 |
|
346 | |||
295 | m_xMinSpin->setEnabled(!value); |
|
347 | m_xMinSpin->setEnabled(!value); | |
296 | m_xMaxSpin->setEnabled(!value); |
|
348 | m_xMaxSpin->setEnabled(!value); | |
297 | m_yMinSpin->setEnabled(!value); |
|
349 | m_yMinSpin->setEnabled(!value); | |
298 | m_yMaxSpin->setEnabled(!value); |
|
350 | m_yMaxSpin->setEnabled(!value); | |
299 | } |
|
351 | } | |
300 |
|
352 | |||
301 | void MainWidget::xMinChanged(int value) |
|
353 | void MainWidget::xMinChanged(int value) | |
302 | { |
|
354 | { | |
303 | qDebug() << "xMinChanged: " << value; |
|
355 | qDebug() << "xMinChanged: " << value; | |
304 | } |
|
356 | } | |
305 |
|
357 | |||
306 | void MainWidget::xMaxChanged(int value) |
|
358 | void MainWidget::xMaxChanged(int value) | |
307 | { |
|
359 | { | |
308 | qDebug() << "xMaxChanged: " << value; |
|
360 | qDebug() << "xMaxChanged: " << value; | |
309 | } |
|
361 | } | |
310 |
|
362 | |||
311 | void MainWidget::yMinChanged(int value) |
|
363 | void MainWidget::yMinChanged(int value) | |
312 | { |
|
364 | { | |
313 | qDebug() << "yMinChanged: " << value; |
|
365 | qDebug() << "yMinChanged: " << value; | |
314 | } |
|
366 | } | |
315 |
|
367 | |||
316 | void MainWidget::yMaxChanged(int value) |
|
368 | void MainWidget::yMaxChanged(int value) | |
317 | { |
|
369 | { | |
318 | qDebug() << "yMaxChanged: " << value; |
|
370 | qDebug() << "yMaxChanged: " << value; | |
319 | } |
|
371 | } | |
320 |
|
372 | |||
321 | void MainWidget::changeChartTheme(int themeIndex) |
|
373 | void MainWidget::changeChartTheme(int themeIndex) | |
322 | { |
|
374 | { | |
323 | qDebug() << "changeChartTheme: " << themeIndex; |
|
375 | qDebug() << "changeChartTheme: " << themeIndex; | |
324 | m_chartWidget->setChartTheme((QChart::ChartTheme) themeIndex); |
|
376 | m_chartWidget->setChartTheme((QChart::ChartTheme) themeIndex); | |
325 | //TODO: remove this hack. This is just to make it so that theme change is seen immediately. |
|
377 | //TODO: remove this hack. This is just to make it so that theme change is seen immediately. | |
326 | QSize s = size(); |
|
378 | QSize s = size(); | |
327 | s.setWidth(s.width()+1); |
|
379 | s.setWidth(s.width()+1); | |
328 | resize(s); |
|
380 | resize(s); | |
329 | } |
|
381 | } | |
330 |
|
382 | |||
331 | void MainWidget::setPieSizeFactor(double size) |
|
383 | void MainWidget::setPieSizeFactor(double size) | |
332 | { |
|
384 | { | |
333 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
385 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
334 | if (pie) |
|
386 | if (pie) | |
335 | pie->setSizeFactor(qreal(size)); |
|
387 | pie->setSizeFactor(qreal(size)); | |
336 | } |
|
388 | } | |
337 |
|
389 | |||
338 | void MainWidget::setPiePosition(int position) |
|
390 | void MainWidget::setPiePosition(int position) | |
339 | { |
|
391 | { | |
340 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); |
|
392 | QPieSeries *pie = qobject_cast<QPieSeries *>(m_currentSeries); | |
341 | if (pie) |
|
393 | if (pie) | |
342 | pie->setPosition((QPieSeries::PiePosition) position); |
|
394 | pie->setPosition((QPieSeries::PiePosition) position); | |
343 | } |
|
395 | } |
General Comments 0
You need to be logged in to leave comments.
Login now