UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-12-04)
usUltrasonixClientWidget.cpp
1 #include <visp3/ustk_gui/usUltrasonixClientWidget.h>
2 
3 #if defined(USTK_HAVE_VTK_QT) && defined(VISP_HAVE_MODULE_USTK_GRABBER)
4 
5 usUltrasonixClientWidget::usUltrasonixClientWidget()
6 {
7  serverIpAdressLabel = new QLabel(QString("Server ip: "), this);
8  probeSelectionLabel = new QLabel(QString("Probe (on top slot) : "), this);
9 
10  connectPushButton = new QPushButton(QString("Connect to server"), this);
11  initPushButton = new QPushButton(QString("Init acquisition"), this);
12 
13  center3Dprobe = new QPushButton(QString("Center 3D probe motor"), this);
14  startPushButton = new QPushButton(QString("Start Acquisition"), this);
15  stopPushButton = new QPushButton(QString("Stop Acquisition"), this);
16 
17  ipTextEdit = new QLineEdit(QString("192.168.100.2"), this);
18  probeSelectComboBox = new QComboBox(this);
19  probeSelectComboBox->addItem(QString("4DC7 (3D)"));
20  probeSelectComboBox->addItem(QString("C5-2 (2D)"));
21 
22  // ip validation
23  QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
24  QRegExp ipRegex("^" + ipRange + "\\." + ipRange + "\\." + ipRange + "\\." + ipRange + "$");
25  ipValidator = new QRegExpValidator(ipRegex, this);
26  ipTextEdit->setValidator(ipValidator);
27 
28  // layout
29  Layout = new QGridLayout;
30  Layout->addWidget(serverIpAdressLabel, 0, 0, Qt::AlignRight);
31  Layout->addWidget(connectPushButton, 1, 0, 1, 2, Qt::AlignCenter);
32  Layout->addWidget(probeSelectionLabel, 2, 0, Qt::AlignRight);
33  Layout->addWidget(initPushButton, 3, 0, 3, 2, Qt::AlignCenter);
34  Layout->addWidget(center3Dprobe, 4, 0, 4, 2, Qt::AlignCenter);
35  Layout->addWidget(startPushButton, 5, 0, 5, 2, Qt::AlignCenter);
36  Layout->addWidget(stopPushButton, 6, 0, 6, 2, Qt::AlignCenter);
37 
38  Layout->addWidget(ipTextEdit, 0, 1, Qt::AlignLeft);
39  Layout->addWidget(probeSelectComboBox, 2, 1, Qt::AlignLeft);
40 
41  this->setLayout(Layout);
42 
43  connect(connectPushButton, SIGNAL(clicked()), this, SLOT(connectToServerSlot()));
44  connect(initPushButton, SIGNAL(clicked()), this, SLOT(initAcquisitionSlot()));
45 
46  connect(center3Dprobe, SIGNAL(clicked()), this, SIGNAL(center3DProbeMotor()));
47 
48  connect(startPushButton, SIGNAL(clicked()), this, SIGNAL(runAcquisition()));
49  connect(stopPushButton, SIGNAL(clicked()), this, SIGNAL(stopAcquisition()));
50 }
51 
52 usUltrasonixClientWidget::~usUltrasonixClientWidget()
53 {
54  delete serverIpAdressLabel;
55  delete probeSelectionLabel;
56  delete connectPushButton;
57  delete initPushButton;
58  delete startPushButton;
59  delete center3Dprobe;
60  delete stopPushButton;
61  delete ipTextEdit;
62  delete probeSelectComboBox;
63  delete ipValidator;
64 }
65 
66 void usUltrasonixClientWidget::initAcquisitionSlot()
67 {
68  initHeader.slotId = 0; // top slot
69  initHeader.imagingMode = 0; // B-mode
70 
71  if (probeSelectComboBox->currentIndex() == 0) { // 4DC7
72  initHeader.probeId = 15;
73  emit(initAcquisition(initHeader));
74  } else if (probeSelectComboBox->currentIndex() == 1) { // C5-2
75  initHeader.probeId = 10;
76  emit(initAcquisition(initHeader));
77  } else {
78  QMessageBox msgBox;
79  msgBox.setText("Wrong probe selection !");
80  msgBox.exec();
81  }
82 }
83 
84 void usUltrasonixClientWidget::connectToServerSlot()
85 {
86  hostAddress.setAddress(ipTextEdit->text());
87  emit(connectToServer(hostAddress));
88 }
89 #endif