Skip to content

Commit

Permalink
ABI compatible implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Aug 30, 2019
1 parent 44d70b9 commit b6362c1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/rviz/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Display::Display()
, visibility_bits_( 0xFFFFFFFF )
, associated_widget_( NULL )
, associated_widget_panel_( NULL )
, associated_widget_visible_( false )
{
// Needed for timeSignal (see header) to work across threads
qRegisterMetaType<ros::Time>();
Expand Down Expand Up @@ -293,6 +292,17 @@ void Display::reset()
clearStatuses();
}

static std::map<PanelDockWidget*, bool> associated_widgets_visibility;
inline void setVisible(PanelDockWidget* widget, bool visible)
{
associated_widgets_visibility[widget] = visible;
}
inline bool isVisible(PanelDockWidget* widget)
{
auto it = associated_widgets_visibility.find(widget);
return it != associated_widgets_visibility.end() && it->second;
}

void Display::onEnableChanged()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Expand All @@ -311,7 +321,7 @@ void Display::onEnableChanged()

if( associated_widget_panel_ )
{
if (!associated_widget_visible_)
if (!isVisible(associated_widget_panel_))
associated_widget_panel_->show();
}
else if( associated_widget_ )
Expand All @@ -326,7 +336,7 @@ void Display::onEnableChanged()

if( associated_widget_panel_ )
{
if( associated_widget_visible_ )
if (isVisible(associated_widget_panel_))
associated_widget_panel_->hide();
}
else if( associated_widget_ )
Expand Down Expand Up @@ -364,7 +374,7 @@ void Display::setAssociatedWidget( QWidget* widget )
if( wm )
{
associated_widget_panel_ = wm->addPane( getName(), associated_widget_ );
associated_widget_visible_ = true;
setVisible(associated_widget_panel_, true);
connect( associated_widget_panel_, SIGNAL( visibilityChanged( bool ) ), this, SLOT( associatedPanelVisibilityChange( bool ) ));
connect( associated_widget_panel_, SIGNAL( closed( ) ), this, SLOT( disable( )));
associated_widget_panel_->setIcon( getIcon() );
Expand All @@ -383,7 +393,7 @@ void Display::setAssociatedWidget( QWidget* widget )

void Display::associatedPanelVisibilityChange( bool visible )
{
associated_widget_visible_ = visible;
setVisible(associated_widget_panel_, visible);
// If something external makes the panel visible/invisible, make sure to enable/disable the display
setEnabled(visible);
// Remark: vice versa, in Display::onEnableChanged(),
Expand Down
1 change: 0 additions & 1 deletion src/rviz/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ private Q_SLOTS:
uint32_t visibility_bits_;
QWidget* associated_widget_;
PanelDockWidget* associated_widget_panel_;
bool associated_widget_visible_;
};

} // end namespace rviz
Expand Down

0 comments on commit b6362c1

Please sign in to comment.