Mercurial > hg > octave-nkf
comparison gui/src/Plot2dWidget.cpp @ 13474:3b7573c783cc
Build data source selection.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Wed, 20 Apr 2011 11:35:29 +0200 |
parents | ba1f40c33359 |
children | d65b8f5373b4 |
comparison
equal
deleted
inserted
replaced
13473:ba1f40c33359 | 13474:3b7573c783cc |
---|---|
1 #include "Plot2dWidget.h" | 1 #include "Plot2dWidget.h" |
2 #include <QVBoxLayout> | 2 #include <QVBoxLayout> |
3 #include <QHBoxLayout> | 3 #include <QHBoxLayout> |
4 #include <QPushButton> | 4 #include <QPushButton> |
5 #include <QTimer> | 5 #include <QTimer> |
6 #include <QLabel> | |
6 #include <math.h> | 7 #include <math.h> |
7 | 8 |
8 Plot2dView::Plot2dView(QWidget *parent) | 9 Plot2dView::Plot2dView(QWidget *parent) |
9 : QGLWidget(parent) { | 10 : QGLWidget(parent) { |
10 construct(); | 11 construct(); |
119 Plot2dWidget::Plot2dWidget(QWidget *parent) | 120 Plot2dWidget::Plot2dWidget(QWidget *parent) |
120 : QWidget(parent) { | 121 : QWidget(parent) { |
121 construct(); | 122 construct(); |
122 } | 123 } |
123 | 124 |
125 void Plot2dWidget::dataSourceTypeChanged(QString type) { | |
126 if(type == "Sampled") { | |
127 m_dataSourceStackedWidget->setCurrentIndex(0); | |
128 } else if(type == "Parameterized") { | |
129 m_dataSourceStackedWidget->setCurrentIndex(1); | |
130 } | |
131 } | |
132 | |
124 void Plot2dWidget::construct() { | 133 void Plot2dWidget::construct() { |
125 QVBoxLayout *layout = new QVBoxLayout(); | 134 QVBoxLayout *layout = new QVBoxLayout(); |
126 m_plot2dView = new Plot2dView(this); | 135 m_plot2dView = new Plot2dView(this); |
127 m_plot2dView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 136 m_plot2dView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
128 layout->addWidget(m_plot2dView); | 137 layout->addWidget(m_plot2dView); |
129 | 138 |
130 m_tabWidget = new QTabWidget(this); | 139 m_tabWidget = new QTabWidget(this); |
131 m_tabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); | 140 m_tabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); |
132 layout->addWidget(m_tabWidget); | 141 layout->addWidget(m_tabWidget); |
133 | 142 |
143 m_generalTab = new QWidget(this); | |
134 m_dataSourceTab = new QWidget(this); | 144 m_dataSourceTab = new QWidget(this); |
135 m_verticalAxisTab = new QWidget(this); | 145 m_verticalAxisTab = new QWidget(this); |
136 m_horizontalAxisTab = new QWidget(this); | 146 m_horizontalAxisTab = new QWidget(this); |
147 m_tabWidget->addTab(m_generalTab, tr("General")); | |
137 m_tabWidget->addTab(m_dataSourceTab, tr("Data Source")); | 148 m_tabWidget->addTab(m_dataSourceTab, tr("Data Source")); |
138 m_tabWidget->addTab(m_verticalAxisTab, tr("Vertical Axis")); | 149 m_tabWidget->addTab(m_verticalAxisTab, tr("Vertical Axis")); |
139 m_tabWidget->addTab(m_horizontalAxisTab, tr("Horizontal Axis")); | 150 m_tabWidget->addTab(m_horizontalAxisTab, tr("Horizontal Axis")); |
140 | 151 |
152 // Build general tab. | |
153 QHBoxLayout *generalTabLayout = new QHBoxLayout(); | |
154 m_generalTab->setLayout(generalTabLayout); | |
155 | |
141 // Build data source tab. | 156 // Build data source tab. |
142 QHBoxLayout *dataSourceTabLayout = new QHBoxLayout(); | 157 QHBoxLayout *dataSourceTabLayout = new QHBoxLayout(); |
143 | |
144 m_dataSourceTypeComboBox = new QComboBox(this); | 158 m_dataSourceTypeComboBox = new QComboBox(this); |
159 m_dataSourceTypeComboBox->addItem(tr("Sampled")); | |
145 m_dataSourceTypeComboBox->addItem(tr("Parameterized")); | 160 m_dataSourceTypeComboBox->addItem(tr("Parameterized")); |
146 m_dataSourceTypeComboBox->addItem(tr("Sampled")); | 161 |
162 m_dataSourceStackedWidget = new QStackedWidget(this); | |
163 m_sampledFromLineEdit = new QLineEdit("0", this); | |
164 m_sampledToLineEdit = new QLineEdit("4096", this); | |
165 m_parameterizedFromLineEdit = new QLineEdit("0.0", this); | |
166 m_parameterizedToLineEdit = new QLineEdit("1.0", this); | |
167 | |
168 m_sampledFromLineEdit->setAlignment(Qt::AlignRight); | |
169 m_sampledToLineEdit->setAlignment(Qt::AlignRight); | |
170 m_parameterizedFromLineEdit->setAlignment(Qt::AlignRight); | |
171 m_parameterizedToLineEdit->setAlignment(Qt::AlignRight); | |
172 | |
173 QWidget *sampledDataSourceRange = new QWidget(this); | |
174 QHBoxLayout *sampledDataSourceLayout = new QHBoxLayout(); | |
175 sampledDataSourceLayout->addWidget(new QLabel(tr("From sample"), this)); | |
176 sampledDataSourceLayout->addWidget(m_sampledFromLineEdit); | |
177 sampledDataSourceLayout->addWidget(new QLabel(tr("to sample"), this)); | |
178 sampledDataSourceLayout->addWidget(m_sampledToLineEdit); | |
179 sampledDataSourceLayout->addWidget(new QLabel(".", this)); | |
180 sampledDataSourceLayout->setMargin(0); | |
181 sampledDataSourceRange->setLayout(sampledDataSourceLayout); | |
182 | |
183 QWidget *parameterizedDataSourceRange = new QWidget(this); | |
184 QHBoxLayout *parameterizedDataSourceLayout = new QHBoxLayout(); | |
185 parameterizedDataSourceLayout->addWidget(new QLabel(tr("From value"), this)); | |
186 parameterizedDataSourceLayout->addWidget(m_parameterizedFromLineEdit); | |
187 parameterizedDataSourceLayout->addWidget(new QLabel(tr("to value"), this)); | |
188 parameterizedDataSourceLayout->addWidget(m_parameterizedToLineEdit); | |
189 parameterizedDataSourceLayout->addWidget(new QLabel(".", this)); | |
190 parameterizedDataSourceLayout->setMargin(0); | |
191 parameterizedDataSourceRange->setLayout(parameterizedDataSourceLayout); | |
192 | |
193 m_dataSourceStackedWidget->addWidget(sampledDataSourceRange); | |
194 m_dataSourceStackedWidget->addWidget(parameterizedDataSourceRange); | |
195 | |
196 m_refreshDataRangeButton = new QPushButton(tr("Refresh"), this); | |
197 dataSourceTabLayout->addWidget(new QLabel(tr("Type:"), this)); | |
147 dataSourceTabLayout->addWidget(m_dataSourceTypeComboBox); | 198 dataSourceTabLayout->addWidget(m_dataSourceTypeComboBox); |
148 dataSourceTabLayout->addStretch(); | 199 dataSourceTabLayout->addWidget(m_dataSourceStackedWidget); |
200 dataSourceTabLayout->addWidget(m_refreshDataRangeButton); | |
149 m_dataSourceTab->setLayout(dataSourceTabLayout); | 201 m_dataSourceTab->setLayout(dataSourceTabLayout); |
150 | 202 |
151 layout->setMargin(0); | 203 layout->setMargin(0); |
152 setLayout(layout); | 204 setLayout(layout); |
153 | 205 |
154 } | 206 connect(m_dataSourceTypeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(dataSourceTypeChanged(QString))); |
207 } |