Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/rviz/default_plugin/marker_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ void MarkerDisplay::processAdd(const visualization_msgs::Marker::ConstPtr& messa
}
}

if (!ns_it.value()->isEnabled())
{
return;
}

bool create = true;
MarkerBasePtr marker;

Expand Down Expand Up @@ -355,6 +350,8 @@ void MarkerDisplay::processAdd(const visualization_msgs::Marker::ConstPtr& messa
{
marker->setMessage(message);

marker->setVisible(ns_it.value()->isEnabled());

if (message->lifetime.toSec() > 0.0001f)
{
markers_with_expiration_.insert(marker);
Expand Down Expand Up @@ -445,6 +442,17 @@ void MarkerDisplay::setTopic(const QString& topic, const QString& /*datatype*/)
marker_topic_property_->setString(topic);
}

void MarkerDisplay::setVisibilityForNamespace(const std::string& ns, bool visible)
{
for (auto const &marker_it : markers_)
{
if (marker_it.first.first == ns)
{
marker_it.second->setVisible(visible);
}
}
}

/////////////////////////////////////////////////////////////////////////////////
// MarkerNamespace

Expand All @@ -462,7 +470,11 @@ void MarkerNamespace::onEnableChanged()
{
if (!isEnabled())
{
owner_->deleteMarkersInNamespace(getName().toStdString());
owner_->setVisibilityForNamespace(getName().toStdString(), false);
}
else
{
owner_->setVisibilityForNamespace(getName().toStdString(), true);
}

// Update the configuration that stores the enabled state of all markers
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/default_plugin/marker_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class MarkerDisplay : public Display

void setTopic(const QString& topic, const QString& datatype) override;

void setVisibilityForNamespace(const std::string& ns, bool visible);

protected:
void deleteMarkerInternal(const MarkerID& id);

Expand Down
5 changes: 5 additions & 0 deletions src/rviz/default_plugin/markers/marker_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ const Ogre::Quaternion& MarkerBase::getOrientation() const
return scene_node_->getOrientation();
}

void MarkerBase::setVisible(bool visible)
{
scene_node_->setVisible(visible);
}

void MarkerBase::extractMaterials(Ogre::Entity* entity, S_MaterialPtr& materials)
{
uint32_t num_sub_entities = entity->getNumSubEntities();
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/default_plugin/markers/marker_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class MarkerBase
return S_MaterialPtr();
}

void setVisible(bool visible);

protected:
bool transform(const MarkerConstPtr& message,
Ogre::Vector3& pos,
Expand Down