Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "display_group_visibility_property.h"
00037
00038 #include "rviz/properties/bool_property.h"
00039 #include "rviz/display_context.h"
00040 #include "rviz/bit_allocator.h"
00041 #include "rviz/display.h"
00042 #include "rviz/display_group.h"
00043
00044 namespace rviz
00045 {
00046
00047
00048 DisplayGroupVisibilityProperty::DisplayGroupVisibilityProperty(
00049 uint32_t vis_bit,
00050 DisplayGroup* display_group,
00051 Display* parent_display,
00052 const QString& name,
00053 bool default_value,
00054 const QString& description,
00055 Property* parent,
00056 const char *changed_slot,
00057 QObject* receiver )
00058 : DisplayVisibilityProperty( vis_bit, display_group, name, default_value, description, parent, changed_slot, receiver )
00059 , display_group_(display_group)
00060 , parent_display_(parent_display)
00061 {
00062 connect( display_group, SIGNAL( displayAdded( rviz::Display* ) ), this, SLOT( onDisplayAdded( rviz::Display* ) ));
00063 connect( display_group, SIGNAL( displayRemoved( rviz::Display* ) ), this, SLOT( onDisplayRemoved( rviz::Display* ) ));
00064
00065 for( int i = 0; i < display_group->numDisplays(); i++ )
00066 {
00067 rviz::Display* display = display_group->getDisplayAt( i );
00068 if ( display != parent_display )
00069 {
00070 onDisplayAdded( display );
00071 }
00072 }
00073
00074 setDisableChildrenIfFalse(true);
00075 }
00076
00077 void DisplayGroupVisibilityProperty::update()
00078 {
00079 DisplayVisibilityProperty::update();
00080 std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.begin();
00081 for( ; it != disp_vis_props_.end(); it++ )
00082 {
00083 it->second->update();
00084 }
00085 }
00086
00087 void DisplayGroupVisibilityProperty::sortDisplayList()
00088 {
00089
00090
00091 for( int i = 0; i < display_group_->numDisplays(); i++ )
00092 {
00093 rviz::Display* display = display_group_->getDisplayAt( i );
00094 std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.find( display );
00095 if ( it != disp_vis_props_.end() )
00096 {
00097 takeChild( it->second );
00098 addChild( it->second );
00099 }
00100 }
00101 }
00102
00103 void DisplayGroupVisibilityProperty::onDisplayAdded( Display* display )
00104 {
00105 DisplayGroup* display_group = qobject_cast<DisplayGroup*>( display );
00106 DisplayVisibilityProperty* vis_prop;
00107 if( display_group )
00108 {
00109 vis_prop = new DisplayGroupVisibilityProperty( vis_bit_, display_group, parent_display_, "", true, "Uncheck to hide everything in this Display Group", this );
00110 }
00111 else
00112 {
00113 vis_prop = new DisplayVisibilityProperty( vis_bit_, display, "", true, "Show or hide this Display", this );
00114 }
00115 disp_vis_props_[ display ] = vis_prop;
00116 sortDisplayList();
00117 }
00118
00119 void DisplayGroupVisibilityProperty::onDisplayRemoved( Display* display )
00120 {
00121 std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.find( display );
00122 if ( it != disp_vis_props_.end() )
00123 {
00124 Property* child = takeChild( it->second );
00125 child->setParent( NULL );
00126 delete child;
00127 disp_vis_props_.erase( display );
00128 }
00129 }
00130
00131
00132 DisplayGroupVisibilityProperty::~DisplayGroupVisibilityProperty()
00133 {
00134 }
00135
00136 }