Skip to content

Commit efffa9c

Browse files
committed
Changed electrode setup channel selection method
1 parent a715ff2 commit efffa9c

4 files changed

Lines changed: 202 additions & 265 deletions

File tree

src/gui/ElectrodeCompDlg.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99

1010

1111
ElectrodeCompDlg::ElectrodeCompDlg(QWidget *parent) :
12-
QDialog(parent)
12+
QDialog(parent),
13+
inChnModel(new ChannelListModel(ChannelListModel::AnalogIn, this)),
14+
outChnModel(new ChannelListModel(ChannelListModel::AnalogOut, this))
1315
{
1416
setupUi(this);
1517

18+
connect(parent, SIGNAL(channelsChanged()), inChnModel, SLOT(updateChns()));
19+
connect(parent, SIGNAL(channelsChanged()), outChnModel, SLOT(updateChns()));
20+
1621
calibrator = new Calibrator();
1722

1823
// Get the objects and buttons from each tab and connect the buttons with their slots
@@ -26,11 +31,15 @@ ElectrodeCompDlg::ElectrodeCompDlg(QWidget *parent) :
2631

2732
// compensated voltage checkbox
2833
compVCopyOn[elecNum]= electrodeTabs->widget(elecNum)->findChild<QCheckBox *>(QString("CopyChannelCheckBox_")+QString::number(elecNum+1));
29-
compVCopyChannel[elecNum]= electrodeTabs->widget(elecNum)->findChild<QLineEdit *>(QString("leGenCopyChannelNum_")+QString::number(elecNum+1));
34+
compVCopyChannel[elecNum]= electrodeTabs->widget(elecNum)->findChild<QComboBox *>(QString("leGenCopyChannelNum_")+QString::number(elecNum+1));
35+
outChnModel->subordinate(compVCopyChannel[elecNum]);
36+
3037
// General group box
3138
leGenSamplingRate[elecNum] = electrodeTabs->widget(elecNum)->findChild<QLineEdit *>(QString("leGenSamplingRate_")+QString::number(elecNum+1));
32-
leGenInChannelNum[elecNum] = electrodeTabs->widget(elecNum)->findChild<QLineEdit *>(QString("leGenInChannelNum_")+QString::number(elecNum+1));
33-
leGenOutChannelNum[elecNum] = electrodeTabs->widget(elecNum)->findChild<QLineEdit *>(QString("leGenOutChannelNum_")+QString::number(elecNum+1));
39+
leGenInChannelNum[elecNum] = electrodeTabs->widget(elecNum)->findChild<QComboBox *>(QString("leGenInChannelNum_")+QString::number(elecNum+1));
40+
leGenOutChannelNum[elecNum] = electrodeTabs->widget(elecNum)->findChild<QComboBox *>(QString("leGenOutChannelNum_")+QString::number(elecNum+1));
41+
inChnModel->subordinate(leGenInChannelNum[elecNum]);
42+
outChnModel->subordinate(leGenOutChannelNum[elecNum]);
3443

3544
// Electrode measurement group box
3645
leElecMaxCurrent[elecNum] = electrodeTabs->widget(elecNum)->findChild<QLineEdit *>(QString("leElecMaxCurrent_")+QString::number(elecNum+1));
@@ -108,11 +117,11 @@ void ElectrodeCompDlg::exportData()
108117

109118
// copy channel
110119
elecCalibPs[i].copyChnOn = compVCopyOn[i]->isChecked();
111-
elecCalibPs[i].copyChn = compVCopyChannel[i]->text().toInt();
120+
elecCalibPs[i].copyChn = compVCopyChannel[i]->currentData().toInt();
112121
// General params
113122
elecCalibPs[i].samplingRate = leGenSamplingRate[i]->text().toDouble() * 1e3; // kHz -> Hz
114-
elecCalibPs[i].inputChannelNumber = leGenInChannelNum[i]->text().toInt();
115-
elecCalibPs[i].outputChannelNumber = leGenOutChannelNum[i]->text().toInt();
123+
elecCalibPs[i].inputChannelNumber = leGenInChannelNum[i]->currentData().toInt();
124+
elecCalibPs[i].outputChannelNumber = leGenOutChannelNum[i]->currentData().toInt();
116125

117126
// Calibration params
118127
elecCalibPs[i].hyperpolCurr = leHyperpolCurr[i]->text().toDouble() * 1e-9; // nA -> A
@@ -144,15 +153,12 @@ void ElectrodeCompDlg::importData()
144153

145154
// copy channel
146155
compVCopyOn[i]->setChecked(elecCalibPs[i].copyChnOn);
147-
num.setNum(elecCalibPs[i].copyChn);
148-
compVCopyChannel[i]->setText(num);
156+
compVCopyChannel[i]->setCurrentIndex(outChnModel->index(elecCalibPs[i].copyChn));
149157
// General params
150158
num.setNum(elecCalibPs[i].samplingRate / 1e3); // Hz -> kHz
151159
leGenSamplingRate[i]->setText(num);
152-
num.setNum(elecCalibPs[i].inputChannelNumber);
153-
leGenInChannelNum[i]->setText(num);
154-
num.setNum(elecCalibPs[i].outputChannelNumber);
155-
leGenOutChannelNum[i]->setText(num);
160+
leGenInChannelNum[i]->setCurrentIndex(inChnModel->index(elecCalibPs[i].inputChannelNumber));
161+
leGenOutChannelNum[i]->setCurrentIndex(outChnModel->index(elecCalibPs[i].outputChannelNumber));
156162

157163
// Calibration params
158164
num.setNum(elecCalibPs[i].hyperpolCurr * 1e9); // A -> nA

0 commit comments

Comments
 (0)