Skip to content

Commit a6423f1

Browse files
Qt: OpenIGTLink: allow custom device names
1 parent c25f58a commit a6423f1

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

examples/solum_qt/solum/openigtlink.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ void SolumIGTL::close()
2828
server_->CloseSocket();
2929
}
3030

31+
void SolumIGTL::setNodeName(const QString &name)
32+
{
33+
nodeName_ = name.toStdString();
34+
}
35+
3136
void SolumIGTL::disconnectClient()
3237
{
3338
clientConnectTimer_.stop();

examples/solum_qt/solum/openigtlink.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class SolumIGTL : public QObject
1313
bool serve(uint16_t port); /// Returns `false` on failure.
1414
void close();
1515

16+
void setNodeName(const QString& name);
17+
1618
bool isServing() const;
1719
bool isClientConnected() const;
1820

@@ -26,4 +28,5 @@ class SolumIGTL : public QObject
2628
igtl::ServerSocket::Pointer server_;
2729
igtl::Socket::Pointer client_;
2830
QTimer clientConnectTimer_;
31+
std::string nodeName_;
2932
};

examples/solum_qt/solum/solumqt.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Solum::Solum(QWidget *parent) : QMainWindow(parent), imaging_(false)
1212
_me = this;
1313
ui_.setupUi(this);
1414

15+
connect(ui_.igtlnode, &QLineEdit::textChanged, [this](auto& text)
16+
{
17+
igtl_.setNodeName(text);
18+
settings_->setValue("OpenIGTLink/node", text);
19+
});
20+
1521
// Job button labels
1622
ui_.retrieve->setLabels(tr("Retrieve from Clarius cloud"), tr("Retrieving..."));
1723
ui_.blesearch->setLabels(tr("Search"), tr("Searching..."));
@@ -67,6 +73,8 @@ Solum::Solum(QWidget *parent) : QMainWindow(parent), imaging_(false)
6773
auto igtlport = settings_->value("OpenIGTLink/port").toString();
6874
if (!igtlport.isEmpty())
6975
ui_.igtlport->setText(igtlport);
76+
auto igtlnode = settings_->value("OpenIGTLink/node").toString();
77+
ui_.igtlnode->setText(igtlnode.isEmpty() ? "Ultrasound" : igtlnode);
7078

7179
ui_.certtable->setColumnCount(4);
7280
ui_.certtable->setHorizontalHeaderLabels({tr("Serial number"),

examples/solum_qt/solum/solumqt.ui

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ After clicking the button, wait for the SSID to be published via BLE, then conne
985985
<property name="text">
986986
<string>Port</string>
987987
</property>
988+
<property name="alignment">
989+
<set>Qt::AlignRight</set>
990+
</property>
988991
<property name="buddy">
989992
<cstring>igtlport</cstring>
990993
</property>
@@ -993,6 +996,22 @@ After clicking the button, wait for the SSID to be published via BLE, then conne
993996
<item row="0" column="1">
994997
<widget class="QLineEdit" name="igtlport"/>
995998
</item>
999+
<item row="1" column="0">
1000+
<widget class="QLabel" name="_igtlnode_label">
1001+
<property name="text">
1002+
<string>Node name</string>
1003+
</property>
1004+
<property name="alignment">
1005+
<set>Qt::AlignRight</set>
1006+
</property>
1007+
<property name="buddy">
1008+
<cstring>igtlnode</cstring>
1009+
</property>
1010+
</widget>
1011+
</item>
1012+
<item row="1" column="1" colspan="2">
1013+
<widget class="QLineEdit" name="igtlnode"/>
1014+
</item>
9961015
<item row="2" column="0" colspan="3">
9971016
<layout class="QGridLayout">
9981017
<item row="0" column="0">

0 commit comments

Comments
 (0)