ros-visualization / rviz

ROS 3D Robot Visualizer
BSD 3-Clause "New" or "Revised" License
792 stars 459 forks source link

Associated widget which is docked creating a tabbed panels gets disabled if tab is not visible #1738

Closed Levi-Armstrong closed 2 years ago

Levi-Armstrong commented 2 years ago

Currently if I dock my panel on top of another panel creating tabbed panels and then you switched tab it disables the display. Is there a way to disable this functionality?

Levi-Armstrong commented 2 years ago

@rhaschke I believe this is a related issue but the issue shows resolved and this still appears to be happening on the noetic version.

Levi-Armstrong commented 2 years ago

Tab Selected image

Tab Unselected image

Levi-Armstrong commented 2 years ago

Then I can enable the display from the tree and the scene is visible and the tab is not which is the behavior expected. image

Levi-Armstrong commented 2 years ago

~A current work around is to add the following connection enabling the display on any visibility change to the panel.~

connect(getAssociatedWidgetPanel(), SIGNAL( visibilityChanged( bool ) ), this, SLOT( onAssociatedPanelVisibilityChange( bool ) ));
void WorkbenchDisplay::onAssociatedPanelVisibilityChange(bool /*visible*/)
{
  setEnabled(true);
}
Levi-Armstrong commented 2 years ago

Well actually that does not work because now the display cannot be disabled.

Levi-Armstrong commented 2 years ago

Finally was able to create a work around.

I first had to disconnect the following signal.

disconnect(getAssociatedWidgetPanel(), SIGNAL( visibilityChanged(bool) ), this, SLOT( associatedPanelVisibilityChange(bool) ));

Then override the onEnableChanged with the following

void WorkbenchDisplay::onEnableChanged()
{
  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
  queueRender();
  /* We get here, by two different routes:
   * - First, we might have disabled the display.
   *   In this case we want to close/hide the associated widget.
   *   But there is an exception: tabbed DockWidgets shouldn't be hidden, because then we would loose the
   * tab.
   * - Second, the corresponding widget changed visibility and we got here via
   * associatedPanelVisibilityChange().
   *   In this case, it's usually counterproductive to show/hide the widget here.
   *   Typical cases are: main window was minimized/unminimized, tab was switched.
   */
  if (isEnabled())
  {
    scene_node_->setVisible(true);

    if (getAssociatedWidgetPanel() != nullptr)
    {
      getAssociatedWidgetPanel()->show();
      getAssociatedWidgetPanel()->setEnabled(true);
    }
    else if (getAssociatedWidget() != nullptr)
    {
      getAssociatedWidget()->show();
      getAssociatedWidgetPanel()->setEnabled(true);
    }

    if (isEnabled()) // status might have changed, e.g. if show() failed
      onEnable();
  }
  else
  {
    onDisable();

    if (getAssociatedWidgetPanel() != nullptr)
      getAssociatedWidgetPanel()->setDisabled(true);
    else if (getAssociatedWidget())
      getAssociatedWidget()->setDisabled(true);

    scene_node_->setVisible(false);
  }
  QApplication::restoreOverrideCursor();
}

This just disables the widget opposed to hiding and showing.

rhaschke commented 2 years ago

There is a simpler solution: #1739.

Levi-Armstrong commented 2 years ago

There is a simpler solution: #1739.

Thanks for the fix.

rhaschke commented 2 years ago

@Levi-Armstrong, you seem to have implemented a fancy visual interface to Tesseract integrated into rviz. Is that already available somewhere? I couldn't find it. Can you provide a pointer?

Levi-Armstrong commented 2 years ago

Sure, it is under a lot of development at the moment. tesseract_gui