26 #include <qfiledialog.h>
27 #include <qinputdialog.h>
28 #include <qmessagebox.h>
29 #include <qscrollbar.h>
32 #include <igtlStringMessage.h>
33 #include <igtlBindMessage.h>
34 #include <igtlQuaternionTrackingDataMessage.h>
35 #include <igtlTrackingDataMessage.h>
38 #include <Poco/Path.h>
41 "org.mitk.views.igtldevicesetupconnectionwidget";
44 QWidget* parent, Qt::WindowFlags f)
45 : QWidget(parent, f), m_IsClient(false)
77 m_Controls =
new Ui::QmitkIGTLDeviceSetupConnectionWidgetControls;
84 QRegExpValidator *v =
new QRegExpValidator(
this);
85 QRegExp 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})");
89 m_Controls->editPort->setValidator(
new QIntValidator(1, 65535,
this));
102 connect(
m_Controls->butConnect, SIGNAL(clicked()),
104 connect(
m_Controls->editPort, SIGNAL(editingFinished()),
106 connect(
m_Controls->editIP, SIGNAL(editingFinished()),
108 connect(
m_Controls->bufferInMsgCheckBox, SIGNAL(stateChanged(
int)),
110 connect(
m_Controls->bufferOutMsgCheckBox, SIGNAL(stateChanged(
int)),
149 this->
m_Controls->logIncomingMsg->setEnabled(
false);
150 this->
m_Controls->logOutgoingMsg->setEnabled(
false);
151 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
false);
152 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
false);
153 this->
m_Controls->butConnect->setEnabled(
true);
154 this->
m_Controls->fpsInLabel->setEnabled(
false);
155 this->
m_Controls->fpsOutLabel->setEnabled(
false);
156 this->
m_Controls->fpsInDescrLabel->setEnabled(
false);
157 this->
m_Controls->fpsOutDescrLabel->setEnabled(
false);
162 this->
m_Controls->butConnect->setText(
"Disconnect");
166 this->
m_Controls->butConnect->setText(
"Go Offline");
169 this->
m_Controls->editPort->setEnabled(
false);
170 this->
m_Controls->logIncomingMsg->setEnabled(
true);
171 this->
m_Controls->logOutgoingMsg->setEnabled(
true);
172 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
true);
173 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
true);
174 this->
m_Controls->butConnect->setEnabled(
true);
175 this->
m_Controls->fpsInLabel->setEnabled(
true);
176 this->
m_Controls->fpsOutLabel->setEnabled(
true);
177 this->
m_Controls->fpsInDescrLabel->setEnabled(
true);
178 this->
m_Controls->fpsOutDescrLabel->setEnabled(
true);
183 this->
m_Controls->butConnect->setText(
"Disconnect");
187 this->
m_Controls->butConnect->setText(
"Go Offline");
190 this->
m_Controls->editPort->setEnabled(
false);
191 this->
m_Controls->logIncomingMsg->setEnabled(
true);
192 this->
m_Controls->logOutgoingMsg->setEnabled(
true);
193 this->
m_Controls->bufferInMsgCheckBox->setEnabled(
true);
194 this->
m_Controls->bufferOutMsgCheckBox->setEnabled(
true);
195 this->
m_Controls->butConnect->setEnabled(
true);
196 this->
m_Controls->fpsInLabel->setEnabled(
true);
197 this->
m_Controls->fpsOutLabel->setEnabled(
true);
198 this->
m_Controls->fpsInDescrLabel->setEnabled(
true);
199 this->
m_Controls->fpsOutDescrLabel->setEnabled(
true);
215 if (device.IsNotNull())
220 if (dynamic_cast<mitk::IGTLClient*>(
232 typedef itk::SimpleMemberCommand< QmitkIGTLDeviceSetupConnectionWidget > CurCommandType;
234 messageSentCommand->SetCallbackFunction(
237 mitk::MessageSentEvent(), messageSentCommand);
240 messageReceivedCommand->SetCallbackFunction(
243 mitk::MessageReceivedEvent(), messageReceivedCommand);
246 commandReceivedCommand->SetCallbackFunction(
249 mitk::CommandReceivedEvent(), commandReceivedCommand);
252 connectionLostCommand->SetCallbackFunction(
255 mitk::LostConnectionEvent(), connectionLostCommand);
258 newConnectionCommand->SetCallbackFunction(
261 mitk::NewClientConnectionEvent(), newConnectionCommand);
264 stateModifiedCommand->SetCallbackFunction(
267 itk::ModifiedEvent(), stateModifiedCommand);
283 m_Controls->bufferInMsgCheckBox->setEnabled(
false);
284 m_Controls->bufferOutMsgCheckBox->setEnabled(
false);
285 m_Controls->logIncomingMsg->setEnabled(
false);
286 m_Controls->logOutgoingMsg->setEnabled(
false);
295 std::string hostname =
m_Controls->editIP->text().toStdString();
307 MITK_INFO(
"IGTLDeviceSourceManagementWidget")
308 <<
"Successfully connected to " << hostname
309 <<
" on port " << port.toStdString();
314 MITK_ERROR(
"QmitkIGTLDeviceSetupConnectionWidget") <<
315 "Could not start a communication with the"
316 "server because the client is in the wrong state";
321 MITK_ERROR(
"QmitkIGTLDeviceSetupConnectionWidget") <<
322 "Could not connect to the server. "
323 "Please check the hostname and port.";
329 MITK_INFO(
"QmitkIGTLDeviceSetupConnectionWidget") <<
"Closed connection";
333 mitkThrow() <<
"Invalid state of IGTLDevice";
358 if (this->
m_Controls->logIncomingMsg->isChecked())
360 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Received a message: "
361 << this->
m_IGTLDevice->GetMessageQueue()->GetLatestMsgInformationString();
368 if (this->
m_Controls->logOutgoingMsg->isChecked())
370 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Sent a message.";
377 if (this->
m_Controls->logIncomingMsg->isChecked())
379 MITK_INFO(
"IGTLDeviceSetupConnectionWidget") <<
"Received a command: "
380 << this->
m_IGTLDevice->GetMessageQueue()->GetLatestMsgInformationString();
406 this->
m_Controls->fpsInLabel->setText(QString::number(fpsIn));
407 this->
m_Controls->fpsOutLabel->setText(QString::number(fpsOut));
itk::SmartPointer< Self > Pointer
IGTLDeviceState
Type for state variable. The IGTLDevice is always in one of these states.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.