@@ -3,6 +3,7 | |||
|
3 | 3 | #include <QPushButton> |
|
4 | 4 | #include <QComboBox> |
|
5 | 5 | #include <QSpinBox> |
|
6 | #include <QCheckBox> | |
|
6 | 7 | #include <QGridLayout> |
|
7 | 8 | #include <QHBoxLayout> |
|
8 | 9 | #include <QLabel> |
@@ -41,27 +42,29 MainWidget::MainWidget(QWidget *parent) : | |||
|
41 | 42 | this, SLOT(backgroundChanged(int))); |
|
42 | 43 | |
|
43 | 44 | // Axis |
|
45 | QCheckBox *autoScaleCheck = new QCheckBox("Automatic scaling"); | |
|
46 | connect(autoScaleCheck, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int))); | |
|
44 | 47 | // Allow setting also non-sense values (like -2147483648 and 2147483647) |
|
45 |
|
|
|
46 | xMinSpin->setMinimum(INT_MIN); | |
|
47 | xMinSpin->setMaximum(INT_MAX); | |
|
48 | xMinSpin->setValue(0); | |
|
49 | connect(xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
|
50 |
|
|
|
51 | xMaxSpin->setMinimum(INT_MIN); | |
|
52 | xMaxSpin->setMaximum(INT_MAX); | |
|
53 | xMaxSpin->setValue(10); | |
|
54 | connect(xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
|
55 |
|
|
|
56 | yMinSpin->setMinimum(INT_MIN); | |
|
57 | yMinSpin->setMaximum(INT_MAX); | |
|
58 | yMinSpin->setValue(0); | |
|
59 | connect(yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
|
60 |
|
|
|
61 | yMaxSpin->setMinimum(INT_MIN); | |
|
62 | yMaxSpin->setMaximum(INT_MAX); | |
|
63 | yMaxSpin->setValue(10); | |
|
64 | connect(yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
|
48 | m_xMinSpin = new QSpinBox(); | |
|
49 | m_xMinSpin->setMinimum(INT_MIN); | |
|
50 | m_xMinSpin->setMaximum(INT_MAX); | |
|
51 | m_xMinSpin->setValue(0); | |
|
52 | connect(m_xMinSpin, SIGNAL(valueChanged(int)), this, SLOT(xMinChanged(int))); | |
|
53 | m_xMaxSpin = new QSpinBox(); | |
|
54 | m_xMaxSpin->setMinimum(INT_MIN); | |
|
55 | m_xMaxSpin->setMaximum(INT_MAX); | |
|
56 | m_xMaxSpin->setValue(10); | |
|
57 | connect(m_xMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(xMaxChanged(int))); | |
|
58 | m_yMinSpin = new QSpinBox(); | |
|
59 | m_yMinSpin->setMinimum(INT_MIN); | |
|
60 | m_yMinSpin->setMaximum(INT_MAX); | |
|
61 | m_yMinSpin->setValue(0); | |
|
62 | connect(m_yMinSpin, SIGNAL(valueChanged(int)), this, SLOT(yMinChanged(int))); | |
|
63 | m_yMaxSpin = new QSpinBox(); | |
|
64 | m_yMaxSpin->setMinimum(INT_MIN); | |
|
65 | m_yMaxSpin->setMaximum(INT_MAX); | |
|
66 | m_yMaxSpin->setValue(10); | |
|
67 | connect(m_yMaxSpin, SIGNAL(valueChanged(int)), this, SLOT(yMaxChanged(int))); | |
|
65 | 68 | |
|
66 | 69 | QGridLayout *grid = new QGridLayout(); |
|
67 | 70 | QHBoxLayout *hbox = new QHBoxLayout(); |
@@ -71,40 +74,36 MainWidget::MainWidget(QWidget *parent) : | |||
|
71 | 74 | grid->addWidget(dataCombo, 1, 1); |
|
72 | 75 | grid->addWidget(new QLabel("Background:"), 2, 0); |
|
73 | 76 | grid->addWidget(backgroundCombo, 2, 1); |
|
74 |
grid->addWidget( |
|
|
75 |
grid->addWidget( |
|
|
76 |
grid->addWidget( |
|
|
77 |
grid->addWidget( |
|
|
78 |
grid->addWidget( |
|
|
79 |
grid->addWidget( |
|
|
80 |
grid->addWidget( |
|
|
81 |
grid->addWidget( |
|
|
77 | grid->addWidget(autoScaleCheck, 3, 0); | |
|
78 | grid->addWidget(new QLabel("x min:"), 4, 0); | |
|
79 | grid->addWidget(m_xMinSpin, 4, 1); | |
|
80 | grid->addWidget(new QLabel("x max:"), 5, 0); | |
|
81 | grid->addWidget(m_xMaxSpin, 5, 1); | |
|
82 | grid->addWidget(new QLabel("y min:"), 6, 0); | |
|
83 | grid->addWidget(m_yMinSpin, 6, 1); | |
|
84 | grid->addWidget(new QLabel("y max:"), 7, 0); | |
|
85 | grid->addWidget(m_yMaxSpin, 7, 1); | |
|
82 | 86 | // add row with empty label to make all the other rows static |
|
83 |
grid->addWidget(new QLabel(""), |
|
|
84 |
grid->setRowStretch( |
|
|
87 | grid->addWidget(new QLabel(""), 8, 0); | |
|
88 | grid->setRowStretch(8, 1); | |
|
85 | 89 | |
|
86 | 90 | hbox->addLayout(grid); |
|
87 | 91 | hbox->addWidget(m_chartWidget); |
|
88 | 92 | hbox->setStretch(1, 1); |
|
89 | 93 | |
|
90 | 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 | 101 | void MainWidget::chartTypeChanged(int itemIndex) |
|
94 | 102 | { |
|
95 | 103 | qDebug() << "chartTypeChanged: " << itemIndex; |
|
96 | ||
|
97 | switch (itemIndex) { | |
|
98 | // case 0: | |
|
99 | // m_chartWidget->setType(ChartWidget::TypeLine); | |
|
100 | // break; | |
|
101 | default: | |
|
102 | // TODO: api for setting chart type? | |
|
103 | 104 |
|
|
104 | 105 |
|
|
105 | 106 |
|
|
106 | break; | |
|
107 | } | |
|
108 | 107 | } |
|
109 | 108 | |
|
110 | 109 | void MainWidget::dataChanged(QString itemText) |
@@ -117,6 +116,21 void MainWidget::backgroundChanged(int itemIndex) | |||
|
117 | 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 | 134 | void MainWidget::xMinChanged(int value) |
|
121 | 135 | { |
|
122 | 136 | qDebug() << "xMinChanged: " << value; |
@@ -4,6 +4,7 | |||
|
4 | 4 | #include <QWidget> |
|
5 | 5 | |
|
6 | 6 | class ChartWidget; |
|
7 | class QSpinBox; | |
|
7 | 8 | |
|
8 | 9 | class MainWidget : public QWidget |
|
9 | 10 | { |
@@ -17,6 +18,7 private slots: | |||
|
17 | 18 | void chartTypeChanged(int itemIndex); |
|
18 | 19 | void dataChanged(QString itemText); |
|
19 | 20 | void backgroundChanged(int itemIndex); |
|
21 | void autoScaleChanged(int value); | |
|
20 | 22 | void xMinChanged(int value); |
|
21 | 23 | void xMaxChanged(int value); |
|
22 | 24 | void yMinChanged(int value); |
@@ -24,6 +26,10 private slots: | |||
|
24 | 26 | |
|
25 | 27 | private: |
|
26 | 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 | 35 | #endif // MAINWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now