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 #include <algorithm>
00031
00032 #include "rviz/frame_manager.h"
00033
00034 #include "rviz/properties/tf_frame_property.h"
00035
00036 namespace rviz
00037 {
00038
00039 const QString TfFrameProperty::FIXED_FRAME_STRING = "<Fixed Frame>";
00040
00041 TfFrameProperty::TfFrameProperty( const QString& name,
00042 const QString& default_value,
00043 const QString& description,
00044 Property* parent,
00045 FrameManager* frame_manager,
00046 bool include_fixed_frame_string,
00047 const char *changed_slot,
00048 QObject* receiver )
00049 : EditableEnumProperty( name, default_value, description, parent, changed_slot, receiver )
00050 , frame_manager_( NULL )
00051 , include_fixed_frame_string_( include_fixed_frame_string )
00052 {
00053
00054 connect( this, SIGNAL( requestOptions( EditableEnumProperty* )),
00055 this, SLOT( fillFrameList() ));
00056 setFrameManager( frame_manager );
00057 }
00058
00059 bool TfFrameProperty::setValue( const QVariant& new_value )
00060 {
00061 QString new_string = new_value.toString();
00062 if( new_string.size() > 0 && new_string[ 0 ] == '/' )
00063 {
00064 new_string = new_string.right( new_string.size() - 1 );
00065 }
00066 bool result = EditableEnumProperty::setValue( new_string );
00067
00068 return result;
00069 }
00070
00071 void TfFrameProperty::setFrameManager( FrameManager* frame_manager )
00072 {
00073 if( frame_manager_ && include_fixed_frame_string_ )
00074 {
00075 disconnect( frame_manager_, SIGNAL( fixedFrameChanged() ),
00076 this, SLOT( handleFixedFrameChange() ));
00077 }
00078 frame_manager_ = frame_manager;
00079 if( frame_manager_ && include_fixed_frame_string_ )
00080 {
00081 connect( frame_manager_, SIGNAL( fixedFrameChanged() ),
00082 this, SLOT( handleFixedFrameChange() ));
00083 }
00084 }
00085
00086 void TfFrameProperty::fillFrameList()
00087 {
00088 std::vector<std::string> std_frames;
00089 frame_manager_->getTFClient()->getFrameStrings( std_frames );
00090 std::sort( std_frames.begin(), std_frames.end() );
00091
00092 clearOptions();
00093 if( include_fixed_frame_string_ )
00094 {
00095 addOption( FIXED_FRAME_STRING );
00096 }
00097 for( size_t i = 0; i < std_frames.size(); i++ )
00098 {
00099 addOptionStd( std_frames[ i ]);
00100 }
00101 }
00102
00103 QString TfFrameProperty::getFrame() const
00104 {
00105 QString frame = getValue().toString();
00106 if( frame == FIXED_FRAME_STRING && frame_manager_ )
00107 {
00108 return QString::fromStdString( frame_manager_->getFixedFrame() );
00109 }
00110 return frame;
00111 }
00112
00113 std::string TfFrameProperty::getFrameStd() const
00114 {
00115 return getFrame().toStdString();
00116 }
00117
00118 void TfFrameProperty::handleFixedFrameChange()
00119 {
00120 if( getValue().toString() == FIXED_FRAME_STRING )
00121 {
00122 Q_EMIT changed();
00123 }
00124 }
00125
00126 }