16#include <mitkSurface.h>
18#include <mitkDataStorage.h>
22#include <qfiledialog.h>
23#include <qinputdialog.h>
24#include <qmessagebox.h>
25#include <qscrollbar.h>
28#include <igtlStringMessage.h>
29#include <igtlBindMessage.h>
30#include <igtlQuaternionTrackingDataMessage.h>
31#include <igtlTrackingDataMessage.h>
36#include <QRegularExpressionValidator>
39"org.mitk.views.igtldevicesetupconnectionwidget";
42 QWidget* parent, Qt::WindowFlags f)
43 : QWidget(parent, f), m_IsClient(false)
75 m_Controls =
new Ui::QmitkIGTLDeviceSetupConnectionWidgetControls;
82 auto v =
new QRegularExpressionValidator(
this);
83 QRegularExpression rx(
"((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})");
84 v->setRegularExpression(rx);
87 m_Controls->editPort->setValidator(
new QIntValidator(1, 65535,
this));
100 connect(
m_Controls->butConnect, SIGNAL(clicked()),
102 connect(
m_Controls->editPort, SIGNAL(editingFinished()),
104 connect(
m_Controls->editIP, SIGNAL(editingFinished()),
106 connect(
m_Controls->bufferInMsgCheckBox, SIGNAL(stateChanged(
int)),
108 connect(
m_Controls->bufferOutMsgCheckBox, SIGNAL(stateChanged(
int)),
112 connect(
m_Controls->logMessageDetailsCheckBox, SIGNAL(clicked()),
149 this->
m_Controls->logMessageStatusCheckBox->setChecked(
false);
150 this->
m_Controls->logMessageDetailsCheckBox->setChecked(
false);
151 this->
m_Controls->logMessageStatusCheckBox->setEnabled(
false);
152 this->
m_Controls->logMessageDetailsCheckBox->setEnabled(
false);
153 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
false);
154 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
false);
155 this->
m_Controls->butConnect->setEnabled(
true);
156 this->
m_Controls->fpsInLabel->setEnabled(
false);
157 this->
m_Controls->fpsOutLabel->setEnabled(
false);
158 this->
m_Controls->fpsInDescrLabel->setEnabled(
false);
159 this->
m_Controls->fpsOutDescrLabel->setEnabled(
false);
170 this->
m_Controls->butConnect->setText(
"Disconnect");
174 this->
m_Controls->butConnect->setText(
"Go Offline");
177 this->
m_Controls->editPort->setEnabled(
false);
178 this->
m_Controls->logMessageStatusCheckBox->setEnabled(
true);
179 this->
m_Controls->logMessageDetailsCheckBox->setEnabled(
true);
180 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
true);
181 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
true);
182 this->
m_Controls->butConnect->setEnabled(
true);
183 this->
m_Controls->fpsInLabel->setEnabled(
true);
184 this->
m_Controls->fpsOutLabel->setEnabled(
true);
185 this->
m_Controls->fpsInDescrLabel->setEnabled(
true);
186 this->
m_Controls->fpsOutDescrLabel->setEnabled(
true);
191 this->
m_Controls->butConnect->setText(
"Disconnect");
195 this->
m_Controls->butConnect->setText(
"Go Offline");
198 this->
m_Controls->editPort->setEnabled(
false);
199 this->
m_Controls->logMessageStatusCheckBox->setEnabled(
true);
200 this->
m_Controls->logMessageDetailsCheckBox->setEnabled(
true);
201 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
true);
202 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
true);
203 this->
m_Controls->butConnect->setEnabled(
true);
204 this->
m_Controls->fpsInLabel->setEnabled(
true);
205 this->
m_Controls->fpsOutLabel->setEnabled(
true);
206 this->
m_Controls->fpsInDescrLabel->setEnabled(
true);
207 this->
m_Controls->fpsOutDescrLabel->setEnabled(
true);
210 mitkThrow() <<
"Invalid Device State";
216 mitk::IGTLDevice::Pointer device)
223 if (device.IsNotNull())
240 typedef itk::SimpleMemberCommand< QmitkIGTLDeviceSetupConnectionWidget > CurCommandType;
241 CurCommandType::Pointer messageSentCommand = CurCommandType::New();
242 messageSentCommand->SetCallbackFunction(
245 mitk::MessageSentEvent(), messageSentCommand);
247 CurCommandType::Pointer messageReceivedCommand = CurCommandType::New();
248 messageReceivedCommand->SetCallbackFunction(
251 mitk::MessageReceivedEvent(), messageReceivedCommand);
253 CurCommandType::Pointer commandReceivedCommand = CurCommandType::New();
254 commandReceivedCommand->SetCallbackFunction(
257 mitk::CommandReceivedEvent(), commandReceivedCommand);
259 CurCommandType::Pointer connectionLostCommand = CurCommandType::New();
260 connectionLostCommand->SetCallbackFunction(
263 mitk::LostConnectionEvent(), connectionLostCommand);
265 CurCommandType::Pointer newConnectionCommand = CurCommandType::New();
266 newConnectionCommand->SetCallbackFunction(
269 mitk::NewClientConnectionEvent(), newConnectionCommand);
271 CurCommandType::Pointer stateModifiedCommand = CurCommandType::New();
272 stateModifiedCommand->SetCallbackFunction(
275 itk::ModifiedEvent(), stateModifiedCommand);
291 m_Controls->bufferInMsgCheckBox->setEnabled(
false);
292 m_Controls->bufferOutMsgCheckBox->setEnabled(
false);
293 this->
m_Controls->logMessageStatusCheckBox->setChecked(
false);
294 this->
m_Controls->logMessageDetailsCheckBox->setChecked(
false);
295 this->
m_Controls->logMessageStatusCheckBox->setEnabled(
false);
296 this->
m_Controls->logMessageDetailsCheckBox->setEnabled(
false);
310 std::string hostname =
m_Controls->editIP->text().toStdString();
322 MITK_INFO(
"IGTLDeviceSourceManagementWidget")
323 <<
"Successfully connected to " << hostname
324 <<
" on port " << port.toStdString();
329 MITK_ERROR(
"QmitkIGTLDeviceSetupConnectionWidget") <<
330 "Could not start a communication with the"
331 "server because the client is in the wrong state";
336 MITK_ERROR(
"QmitkIGTLDeviceSetupConnectionWidget") <<
337 "Could not connect to the server. "
338 "Please check the hostname and port.";
344 MITK_INFO(
"QmitkIGTLDeviceSetupConnectionWidget") <<
"Closed connection";
348 mitkThrow() <<
"Invalid state of IGTLDevice";
373 if( this->
m_Controls->logMessageStatusCheckBox->isChecked() )
375 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Received a message.";
382 if( this->
m_Controls->logMessageStatusCheckBox->isChecked() )
384 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Sent a message.";
391 if( this->
m_Controls->logMessageStatusCheckBox->isChecked() )
393 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Received a command.";
419 this->
m_Controls->fpsInLabel->setText(QString::number(fpsIn));
420 this->
m_Controls->fpsOutLabel->setText(QString::number(fpsOut));
429 MITK_WARN <<
"Logging information not passed down to Message Provider.";
Superclass for OpenIGTLink clients.
IGTLDeviceState
Type for state variable. The IGTLDevice is always in one of these states.