@@ -3,6 +3,7 | |||||
3 | #include <QPushButton> |
|
3 | #include <QPushButton> | |
4 | #include <QComboBox> |
|
4 | #include <QComboBox> | |
5 | #include <QSpinBox> |
|
5 | #include <QSpinBox> | |
|
6 | #include <QCheckBox> | |||
6 | #include <QGridLayout> |
|
7 | #include <QGridLayout> | |
7 | #include <QHBoxLayout> |
|
8 | #include <QHBoxLayout> | |
8 | #include <QLabel> |
|
9 | #include <QLabel> | |
@@ -41,27 +42,29 MainWidget::MainWidget(QWidget *parent) : | |||||
41 | this, SLOT(backgroundChanged(int))); |
|
42 | this, SLOT(backgroundChanged(int))); | |
42 |
|
43 | |||
43 | // Axis |
|
44 | // Axis | |
|
45 | QCheckBox *autoScaleCheck = new QCheckBox("Automatic scaling"); | |||
|
46 | connect(autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |||
44 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
47 | // Allow setting also non-sense values (like -2147483648 and 2147483647) | |
45 |
|
|
48 | m_xMinSpin = new QSpinBox(); | |
46 | xMinSpin->setMinimum(INT_MIN); |
|
49 | m_xMinSpin->setMinimum(INT_MIN); | |
47 | xMinSpin->setMaximum(INT_MAX); |
|
50 | m_xMinSpin->setMaximum(INT_MAX); | |
48 | xMinSpin->setValue(0); |
|
51 | m_xMinSpin->setValue(0); | |
49 | connect(xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); |
|
52 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
50 |
|
|
53 | m_xMaxSpin = new QSpinBox(); | |
51 | xMaxSpin->setMinimum(INT_MIN); |
|
54 | m_xMaxSpin->setMinimum(INT_MIN); | |
52 | xMaxSpin->setMaximum(INT_MAX); |
|
55 | m_xMaxSpin->setMaximum(INT_MAX); | |
53 | xMaxSpin->setValue(10); |
|
56 | m_xMaxSpin->setValue(10); | |
54 | connect(xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); |
|
57 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
55 |
|
|
58 | m_yMinSpin = new QSpinBox(); | |
56 | yMinSpin->setMinimum(INT_MIN); |
|
59 | m_yMinSpin->setMinimum(INT_MIN); | |
57 | yMinSpin->setMaximum(INT_MAX); |
|
60 | m_yMinSpin->setMaximum(INT_MAX); | |
58 | yMinSpin->setValue(0); |
|
61 | m_yMinSpin->setValue(0); | |
59 | connect(yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); |
|
62 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
60 |
|
|
63 | m_yMaxSpin = new QSpinBox(); | |
61 | yMaxSpin->setMinimum(INT_MIN); |
|
64 | m_yMaxSpin->setMinimum(INT_MIN); | |
62 | yMaxSpin->setMaximum(INT_MAX); |
|
65 | m_yMaxSpin->setMaximum(INT_MAX); | |
63 | yMaxSpin->setValue(10); |
|
66 | m_yMaxSpin->setValue(10); | |
64 | connect(yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); |
|
67 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
65 |
|
68 | |||
66 | QGridLayout *grid = new QGridLayout(); |
|
69 | QGridLayout *grid = new QGridLayout(); | |
67 | QHBoxLayout *hbox = new QHBoxLayout(); |
|
70 | QHBoxLayout *hbox = new QHBoxLayout(); | |
@@ -71,40 +74,36 MainWidget::MainWidget(QWidget *parent) : | |||||
71 | grid->addWidget(dataCombo, 1, 1); |
|
74 | grid->addWidget(dataCombo, 1, 1); | |
72 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
75 | grid->addWidget(new QLabel("Background:"), 2, 0); | |
73 | grid->addWidget(backgroundCombo, 2, 1); |
|
76 | grid->addWidget(backgroundCombo, 2, 1); | |
74 |
grid->addWidget( |
|
77 | grid->addWidget(autoScaleCheck, 3, 0); | |
75 |
grid->addWidget( |
|
78 | grid->addWidget(new QLabel("x min:"), 4, 0); | |
76 |
grid->addWidget( |
|
79 | grid->addWidget(m_xMinSpin, 4, 1); | |
77 |
grid->addWidget( |
|
80 | grid->addWidget(new QLabel("x max:"), 5, 0); | |
78 |
grid->addWidget( |
|
81 | grid->addWidget(m_xMaxSpin, 5, 1); | |
79 |
grid->addWidget( |
|
82 | grid->addWidget(new QLabel("y min:"), 6, 0); | |
80 |
grid->addWidget( |
|
83 | grid->addWidget(m_yMinSpin, 6, 1); | |
81 |
grid->addWidget( |
|
84 | grid->addWidget(new QLabel("y max:"), 7, 0); | |
|
85 | grid->addWidget(m_yMaxSpin, 7, 1); | |||
82 | // add row with empty label to make all the other rows static |
|
86 | // add row with empty label to make all the other rows static | |
83 |
grid->addWidget(new QLabel(""), |
|
87 | grid->addWidget(new QLabel(""), 8, 0); | |
84 |
grid->setRowStretch( |
|
88 | grid->setRowStretch(8, 1); | |
85 |
|
89 | |||
86 | hbox->addLayout(grid); |
|
90 | hbox->addLayout(grid); | |
87 | hbox->addWidget(m_chartWidget); |
|
91 | hbox->addWidget(m_chartWidget); | |
88 | hbox->setStretch(1, 1); |
|
92 | hbox->setStretch(1, 1); | |
89 |
|
93 | |||
90 | setLayout(hbox); |
|
94 | setLayout(hbox); | |
|
95 | ||||
|
96 | // Setting auto scale affects min/max value spin boxes, so it needs to be done after they have | |||
|
97 | // been constructed | |||
|
98 | autoScaleCheck->setChecked(true); | |||
91 | } |
|
99 | } | |
92 |
|
100 | |||
93 | void MainWidget::chartTypeChanged(int itemIndex) |
|
101 | void MainWidget::chartTypeChanged(int itemIndex) | |
94 | { |
|
102 | { | |
95 | qDebug() << "chartTypeChanged: " << itemIndex; |
|
103 | qDebug() << "chartTypeChanged: " << itemIndex; | |
96 |
|
104 | QMessageBox msg; | ||
97 | switch (itemIndex) { |
|
105 | msg.setText("TODO: API for setting chart type"); | |
98 | // case 0: |
|
106 | msg.exec(); | |
99 | // m_chartWidget->setType(ChartWidget::TypeLine); |
|
|||
100 | // break; |
|
|||
101 | default: |
|
|||
102 | // TODO: api for setting chart type? |
|
|||
103 | QMessageBox msg; |
|
|||
104 | msg.setText("TODO: API for setting chart type"); |
|
|||
105 | msg.exec(); |
|
|||
106 | break; |
|
|||
107 | } |
|
|||
108 | } |
|
107 | } | |
109 |
|
108 | |||
110 | void MainWidget::dataChanged(QString itemText) |
|
109 | void MainWidget::dataChanged(QString itemText) | |
@@ -117,6 +116,21 void MainWidget::backgroundChanged(int itemIndex) | |||||
117 | qDebug() << "backgroundChanged: " << itemIndex; |
|
116 | qDebug() << "backgroundChanged: " << itemIndex; | |
118 | } |
|
117 | } | |
119 |
|
118 | |||
|
119 | void MainWidget::autoScaleChanged(int value) | |||
|
120 | { | |||
|
121 | if (this->isVisible()) { | |||
|
122 | QMessageBox msg; | |||
|
123 | msg.setText("TODO: APIs for using either auto scaling or explicit values"); | |||
|
124 | msg.exec(); | |||
|
125 | } | |||
|
126 | ||||
|
127 | // TODO: get initial spin box axis values from charts widget | |||
|
128 | m_xMinSpin->setEnabled(value == Qt::Unchecked); | |||
|
129 | m_xMaxSpin->setEnabled(value == Qt::Unchecked); | |||
|
130 | m_yMinSpin->setEnabled(value == Qt::Unchecked); | |||
|
131 | m_yMaxSpin->setEnabled(value == Qt::Unchecked); | |||
|
132 | } | |||
|
133 | ||||
120 | void MainWidget::xMinChanged(int value) |
|
134 | void MainWidget::xMinChanged(int value) | |
121 | { |
|
135 | { | |
122 | qDebug() << "xMinChanged: " << value; |
|
136 | qDebug() << "xMinChanged: " << value; |
@@ -4,6 +4,7 | |||||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
5 |
|
5 | |||
6 | class ChartWidget; |
|
6 | class ChartWidget; | |
|
7 | class QSpinBox; | |||
7 |
|
8 | |||
8 | class MainWidget : public QWidget |
|
9 | class MainWidget : public QWidget | |
9 | { |
|
10 | { | |
@@ -17,6 +18,7 private slots: | |||||
17 | void chartTypeChanged(int itemIndex); |
|
18 | void chartTypeChanged(int itemIndex); | |
18 | void dataChanged(QString itemText); |
|
19 | void dataChanged(QString itemText); | |
19 | void backgroundChanged(int itemIndex); |
|
20 | void backgroundChanged(int itemIndex); | |
|
21 | void autoScaleChanged(int value); | |||
20 | void xMinChanged(int value); |
|
22 | void xMinChanged(int value); | |
21 | void xMaxChanged(int value); |
|
23 | void xMaxChanged(int value); | |
22 | void yMinChanged(int value); |
|
24 | void yMinChanged(int value); | |
@@ -24,6 +26,10 private slots: | |||||
24 |
|
26 | |||
25 | private: |
|
27 | private: | |
26 | ChartWidget *m_chartWidget; |
|
28 | ChartWidget *m_chartWidget; | |
|
29 | QSpinBox *m_xMinSpin; | |||
|
30 | QSpinBox *m_xMaxSpin; | |||
|
31 | QSpinBox *m_yMinSpin; | |||
|
32 | QSpinBox *m_yMaxSpin; | |||
27 | }; |
|
33 | }; | |
28 |
|
34 | |||
29 | #endif // MAINWIDGET_H |
|
35 | #endif // MAINWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now