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 #include <QTimer>
00032
00033 #include "visualization_manager.h"
00034 #include "selection/selection_manager.h"
00035 #include "properties/property.h"
00036 #include "properties/property_manager.h"
00037
00038 #include "selection_panel.h"
00039
00040 namespace rviz
00041 {
00042
00043 SelectionPanel::SelectionPanel( QWidget* parent )
00044 : PropertyTreeWidget( parent )
00045 , manager_( NULL )
00046 , setting_( false )
00047 {
00048
00049
00050
00051 setIgnoreChanges( true );
00052
00053 property_manager_ = new PropertyManager();
00054 property_manager_->setPropertyTreeWidget( this );
00055 }
00056
00057 SelectionPanel::~SelectionPanel()
00058 {
00059 delete property_manager_;
00060 }
00061
00062 void SelectionPanel::initialize(VisualizationManager* manager)
00063 {
00064 manager_ = manager;
00065
00066 SelectionManager* sel_man = manager_->getSelectionManager();
00067
00068 connect( sel_man, SIGNAL( selectionAdded( const M_Picked& )), this, SLOT( onSelectionAdded( const M_Picked& )));
00069 connect( sel_man, SIGNAL( selectionRemoved( const M_Picked& )), this, SLOT( onSelectionRemoved( const M_Picked& )));
00070 connect( sel_man, SIGNAL( selectionSet( const M_Picked&, const M_Picked& )), this, SLOT( onSelectionSet() ));
00071 connect( sel_man, SIGNAL( selectionSetting() ), this, SLOT( onSelectionSetting() ));
00072
00073 QTimer* timer = new QTimer( this );
00074 connect( timer, SIGNAL( timeout() ), this, SLOT( onUpdate() ));
00075 timer->start( 200 );
00076 }
00077
00078 void SelectionPanel::onSelectionRemoved( const M_Picked& removed )
00079 {
00080 if (setting_)
00081 {
00082 return;
00083 }
00084
00085 SelectionManager* sel_manager = manager_->getSelectionManager();
00086
00087 M_Picked::const_iterator it = removed.begin();
00088 M_Picked::const_iterator end = removed.end();
00089 for (; it != end; ++it)
00090 {
00091 const Picked& picked = it->second;
00092 SelectionHandlerPtr handler = sel_manager->getHandler(picked.handle);
00093 ROS_ASSERT(handler);
00094
00095 handler->destroyProperties(picked, property_manager_);
00096 }
00097
00098
00099 }
00100
00101 void SelectionPanel::onSelectionAdded( const M_Picked& added )
00102 {
00103 SelectionManager* sel_manager = manager_->getSelectionManager();
00104
00105 M_Picked::const_iterator it = added.begin();
00106 M_Picked::const_iterator end = added.end();
00107 for (; it != end; ++it)
00108 {
00109 const Picked& picked = it->second;
00110 SelectionHandlerPtr handler = sel_manager->getHandler(picked.handle);
00111 ROS_ASSERT(handler);
00112
00113 handler->createProperties(picked, property_manager_);
00114 }
00115 sortItems( 0, Qt::AscendingOrder );
00116 }
00117
00118 void SelectionPanel::onSelectionSetting()
00119 {
00120 setting_ = true;
00121
00122 property_manager_->clear();
00123 }
00124
00125 void SelectionPanel::onSelectionSet()
00126 {
00127 setting_ = false;
00128 }
00129
00130 void SelectionPanel::onUpdate()
00131 {
00132 SelectionManager* sel_manager = manager_->getSelectionManager();
00133 const M_Picked& selection = sel_manager->getSelection();
00134 M_Picked::const_iterator it = selection.begin();
00135 M_Picked::const_iterator end = selection.end();
00136 for (; it != end; ++it)
00137 {
00138 CollObjectHandle handle = it->first;
00139 SelectionHandlerPtr handler = sel_manager->getHandler(handle);
00140
00141 handler->updateProperties();
00142 }
00143
00144 property_manager_->update();
00145
00146 }
00147
00148 }