Skip to content

Commit

Permalink
Re #39: Updated widget so that the numMessages isn't shown anymore. T…
Browse files Browse the repository at this point in the history
…ables are updated by ReferenceAddedEvent instead of NodeModified. Num messages shows in popup label.
  • Loading branch information
LauraConnolly committed Dec 5, 2022
1 parent 95fc3fb commit 3ca8589
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 112 deletions.
60 changes: 59 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,64 @@
"files.associations": {
"system_error": "cpp",
"typeinfo": "cpp",
"functional": "cpp"
"functional": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"bit": "cpp",
"variant": "cpp"
}
}
16 changes: 11 additions & 5 deletions Logic/vtkSlicerRos2Logic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,23 @@ void vtkSlicerRos2Logic::AddPublisher(void)
{
vtkSmartPointer<vtkMRMLROS2PublisherStringNode> stringPub = vtkMRMLROS2PublisherStringNode::New();
this->GetMRMLScene()->AddNode(stringPub);
stringPub->AddToROS2Node(mROS2Node->GetID(), "/publisher");
stringPub->AddToROS2Node(mROS2Node->GetID(), "/string_pub");

vtkSmartPointer<vtkMRMLROS2PublisherStringNode> stringPub2 = vtkMRMLROS2PublisherStringNode::New();
this->GetMRMLScene()->AddNode(stringPub2);
stringPub2->AddToROS2Node(mROS2Node->GetID(), "/publisher");
}

void vtkSlicerRos2Logic::AddToScene(void)
void vtkSlicerRos2Logic::AddROS2Node(void)
{
mROS2Node = vtkMRMLROS2NODENode::New();
this->GetMRMLScene()->AddNode(mROS2Node);
mROS2Node->Create("testNode");
}

void vtkSlicerRos2Logic::AddToScene(void)
{


vtkSmartPointer<vtkMRMLROS2SubscriberStringNode> subString = vtkMRMLROS2SubscriberStringNode::New();
this->GetMRMLScene()->AddNode(subString);
Expand All @@ -789,9 +798,6 @@ void vtkSlicerRos2Logic::AddToScene(void)

this->CreateAndAddSubscriber("vtkMRMLROS2SubscriberStringNode", "/string_sub_2");

vtkSmartPointer<vtkMRMLROS2PublisherStringNode> stringPub = vtkMRMLROS2PublisherStringNode::New();
this->GetMRMLScene()->AddNode(stringPub);
stringPub->AddToROS2Node(mROS2Node->GetID(), "/string_pub");

// vtkSmartPointer<vtkMRMLROS2SubscriberPoseStamped> sub = vtkNew<vtkMRMLROS2SubscriberPoseStamped>();
// std::string sub_name = "/blah_blah";
Expand Down
1 change: 1 addition & 0 deletions Logic/vtkSlicerRos2Logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class VTK_SLICER_ROS2_MODULE_LOGIC_EXPORT vtkSlicerRos2Logic:
void Clear();
void BroadcastTransform();
void AddToScene(void);
void AddROS2Node(void);
void AddPublisher(void);
vtkMRMLROS2SubscriberNode * CreateAndAddSubscriber(const char * className, const std::string & topic);
vtkMRMLROS2PublisherNode * CreateAndAddPublisher(const char * className, const std::string & topic);
Expand Down
72 changes: 31 additions & 41 deletions Resources/UI/qSlicerRos2ModuleWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@
<string>Devel features:</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0">
<widget class="QPushButton" name="setPublishersButton">
<property name="text">
<string>Setup Publishers</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="setSubscribersButton">
<property name="text">
<string>Setup Subscribers</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QTableWidget" name="rosPublisherTableWidget">
<property name="sizePolicy">
Expand All @@ -114,22 +141,17 @@
<string>Publisher name</string>
</property>
</column>
<column>
<property name="text">
<string>Num messages</string>
</property>
</column>
<column>
<property name="text">
<string>Message type</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="setSubscribersButton">
<item row="0" column="0">
<widget class="QPushButton" name="addNodeButton">
<property name="text">
<string>Setup Subscribers</string>
<string>Add ROS2 Node</string>
</property>
</widget>
</item>
Expand All @@ -145,7 +167,7 @@
<number>0</number>
</property>
<property name="columnCount">
<number>3</number>
<number>2</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
Expand All @@ -158,45 +180,13 @@
<string>Subscriber name</string>
</property>
</column>
<column>
<property name="text">
<string>Num messages</string>
</property>
</column>
<column>
<property name="text">
<string>Message type</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="setPublishersButton">
<property name="text">
<string>Setup Publishers</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Subscribers</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down
Loading

0 comments on commit 3ca8589

Please sign in to comment.