MNE-CPP  beta 1.0
neuromagsetupwidget.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //*************************************************************************************************************
37 //=============================================================================================================
38 // INCLUDES
39 //=============================================================================================================
40 
41 #include "neuromagsetupwidget.h"
42 #include "neuromagaboutwidget.h"
43 
44 #include "../neuromag.h"
45 
46 
47 //*************************************************************************************************************
48 //=============================================================================================================
49 // QT INCLUDES
50 //=============================================================================================================
51 
52 #include <QDir>
53 #include <QDebug>
54 #include <QComboBox>
55 
56 
57 //*************************************************************************************************************
58 //=============================================================================================================
59 // USED NAMESPACES
60 //=============================================================================================================
61 
62 using namespace MneRtClientPlugin;
63 
64 
65 //*************************************************************************************************************
66 //=============================================================================================================
67 // DEFINE MEMBER METHODS
68 //=============================================================================================================
69 
70 NeuromagSetupWidget::NeuromagSetupWidget(Neuromag* p_pNeuromag, QWidget* parent)
71 : QWidget(parent)
72 , m_pNeuromag(p_pNeuromag)
73 , m_bIsInit(false)
74 {
75  ui.setupUi(this);
76 
77  //Record data checkbox
78  connect(ui.m_qCheckBox_RecordData, &QCheckBox::stateChanged, this, &NeuromagSetupWidget::checkedRecordDataChanged);
79 
80  //Fiff record file
81  connect(ui.m_qPushButton_FiffRecordFile, &QPushButton::released, this, &NeuromagSetupWidget::pressedFiffRecordFile);
82 
83  //rt server connection
84  this->ui.m_qLineEdit_Ip->setText(m_pNeuromag->m_sNeuromagIP);
85 
86  connect(ui.m_qPushButton_Connect, &QPushButton::released, this, &NeuromagSetupWidget::pressedConnect);
87 
88  connect(m_pNeuromag, &Neuromag::cmdConnectionChanged, this, &NeuromagSetupWidget::cmdConnectionChanged);
89 
90  //rt server fiffInfo received
92 
93  //Buffer
94  connect(ui.m_qLineEdit_BufferSize, &QLineEdit::editingFinished, this, &NeuromagSetupWidget::bufferSizeEdited);
95 
96  //CLI
97  connect(ui.m_qPushButton_SendCLI, &QPushButton::released, this, &NeuromagSetupWidget::pressedSendCLI);
98 
99  //About
100  connect(ui.m_qPushButton_About, &QPushButton::released, this, &NeuromagSetupWidget::showAboutDialog);
101 
102 // //SQUID Control
103 // connect(ui.m_qPushButton_SQUIDControl, &QPushButton::released, this, &NeuromagSetupWidget::SQUIDControlDialog);
104 
105  this->init();
106 }
107 
108 
109 //*************************************************************************************************************
110 
112 {
113 
114 }
115 
116 
117 //*************************************************************************************************************
118 
120 {
122  cmdConnectionChanged(m_pNeuromag->m_bCmdClientIsConnected);
123 }
124 
125 
126 //*************************************************************************************************************
127 
129 {
130  bool t_bSuccess = false;
131  qint32 t_iBufferSize = ui.m_qLineEdit_BufferSize->text().toInt(&t_bSuccess);
132 
133  if(t_bSuccess && t_iBufferSize > 0)
134  m_pNeuromag->m_iBufferSize = t_iBufferSize;
135  else
136  ui.m_qLineEdit_BufferSize->setText(QString("%1").arg(m_pNeuromag->m_iBufferSize));
137 }
138 
139 
140 //*************************************************************************************************************
141 
143 {
144  if(ui.m_qCheckBox_RecordData->checkState() == Qt::Checked)
145  {
146  ui.m_qComboBox_SubjectSelection->setEnabled(true);
147  ui.m_qPushButton_NewSubject->setEnabled(true);
148  ui.m_qLineEdit_FiffRecordFile->setEnabled(true);
149  ui.m_qPushButton_FiffRecordFile->setEnabled(true);
150  }
151  else
152  {
153  ui.m_qComboBox_SubjectSelection->setEnabled(false);
154  ui.m_qPushButton_NewSubject->setEnabled(false);
155  ui.m_qLineEdit_FiffRecordFile->setEnabled(false);
156  ui.m_qPushButton_FiffRecordFile->setEnabled(false);
157  }
158 }
159 
160 
161 //*************************************************************************************************************
162 
164 {
165  QString fileName = QFileDialog::getSaveFileName(this, tr("Save Fiff Record File"), "", tr("Fiff Record File (*.fif)"));
166 
167  ui.m_qLineEdit_FiffRecordFile->setText(fileName);
168 }
169 
170 
171 //*************************************************************************************************************
172 
174 {
175  if(m_pNeuromag->m_bCmdClientIsConnected)
176  m_pNeuromag->disconnectCmdClient();
177  else
178  {
179  m_pNeuromag->m_sNeuromagIP = this->ui.m_qLineEdit_Ip->text();
180  m_pNeuromag->connectCmdClient();
181  }
182 }
183 
184 
185 //*************************************************************************************************************
186 
188 {
189  if(m_pNeuromag->m_bCmdClientIsConnected)
190  {
191  this->printToLog(this->ui.m_qLineEdit_SendCLI->text());
192  QString t_sReply = m_pNeuromag->m_pRtCmdClient->sendCLICommand(this->ui.m_qLineEdit_SendCLI->text());
193  this->printToLog(t_sReply);
194  }
195 }
196 
197 
198 //*************************************************************************************************************
199 
201 {
202  ui.m_qTextBrowser_ServerMessage->insertPlainText(logMsg+"\n");
203  //scroll down to the newest entry
204  QTextCursor c = ui.m_qTextBrowser_ServerMessage->textCursor();
205  c.movePosition(QTextCursor::End);
206  ui.m_qTextBrowser_ServerMessage->setTextCursor(c);
207 }
208 
209 
210 //*************************************************************************************************************
211 
212 void NeuromagSetupWidget::cmdConnectionChanged(bool p_bConnectionStatus)
213 {
214  m_bIsInit = false;
215 
216  if(p_bConnectionStatus)
217  {
218  //
219  // set frequency txt
220  //
221  if(m_pNeuromag->m_pFiffInfo)
222  this->ui.m_qLabel_sps->setText(QString("%1").arg(m_pNeuromag->m_pFiffInfo->sfreq));
223 
224  //
225  // set buffer size txt
226  //
227  this->ui.m_qLineEdit_BufferSize->setText(QString("%1").arg(m_pNeuromag->m_iBufferSize));
228 
229  //
230  // set connectors
231  //
232 // QMap<qint32, QString>::ConstIterator it = m_pNeuromag->m_qMapConnectors.begin();
233 // qint32 idx = 0;
234 
235 // for(; it != m_pNeuromag->m_qMapConnectors.end(); ++it)
236 // {
237 // if(this->ui.m_qComboBox_Connector->findData(it.key()) == -1)
238 // {
239 // this->ui.m_qComboBox_Connector->insertItem(idx, it.value(), it.key());
240 // ++idx;
241 // }
242 // else
243 // idx = this->ui.m_qComboBox_Connector->findData(it.key()) + 1;
244 // }
245 // this->ui.m_qComboBox_Connector->setCurrentIndex(this->ui.m_qComboBox_Connector->findData(m_pNeuromag->m_iActiveConnectorId));
246 
247  //UI enables/disables
248  this->ui.m_qLabel_ConnectionStatus->setText(QString("Connected"));
249  this->ui.m_qLineEdit_Ip->setEnabled(false);
250  this->ui.m_qPushButton_Connect->setText(QString("Disconnect"));
251  this->ui.m_qLineEdit_SendCLI->setEnabled(true);
252  this->ui.m_qPushButton_SendCLI->setEnabled(true);
253 
254  m_bIsInit = true;
255  }
256  else
257  {
258  //clear connectors --> ToDO create a clear function
259  m_pNeuromag->m_qMapConnectors.clear();
260 // this->ui.m_qComboBox_Connector->clear();
261  m_pNeuromag->m_iBufferSize = -1;
262 
263  //UI enables/disables
264  this->ui.m_qLabel_ConnectionStatus->setText(QString("Not connected"));
265  this->ui.m_qLineEdit_Ip->setEnabled(true);
266  this->ui.m_qPushButton_Connect->setText(QString("Connect"));
267  this->ui.m_qLineEdit_SendCLI->setEnabled(false);
268  this->ui.m_qPushButton_SendCLI->setEnabled(false);
269 
270  this->ui.m_qLineEdit_BufferSize->setText(QString(""));
271 
272  }
273 }
274 
275 
276 //*************************************************************************************************************
277 
279 {
280  if(m_pNeuromag->m_pFiffInfo)
281  this->ui.m_qLabel_sps->setText(QString("%1").arg(m_pNeuromag->m_pFiffInfo->sfreq));
282 }
283 
284 
285 //*************************************************************************************************************
286 
287 void NeuromagSetupWidget::showAboutDialog()
288 {
289  NeuromagAboutWidget aboutDialog(this);
290  aboutDialog.exec();
291 }
292 
Contains the declaration of the NeuromagAboutWidget class.
void cmdConnectionChanged(bool p_bStatus)
NeuromagSetupWidget(Neuromag *p_pNeuromag, QWidget *parent=0)
The Neuromag class provides a RT server connection.
Definition: neuromag.h:115
The NeuromagAboutWidget class provides the about dialog for the Neuromag.
Contains the declaration of the NeuromagSetupWidget class.