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 <QLabel>
00032 #include <QLineEdit>
00033 #include <QPushButton>
00034 #include <QHBoxLayout>
00035
00036 #include "visualization_manager.h"
00037
00038 #include "time_panel.h"
00039
00040 namespace rviz
00041 {
00042
00043 TimePanel::TimePanel( QWidget* parent )
00044 : QWidget( parent )
00045 , manager_( NULL )
00046 {
00047 wall_time_label_ = makeTimeLabel();
00048 wall_elapsed_label_ = makeTimeLabel();
00049 ros_time_label_ = makeTimeLabel();
00050 ros_elapsed_label_ = makeTimeLabel();
00051
00052 QPushButton* reset_button = new QPushButton( "Reset" );
00053
00054 QHBoxLayout* layout = new QHBoxLayout;
00055 layout->addWidget( new QLabel( "Wall Time:" ));
00056 layout->addWidget( wall_time_label_ );
00057 layout->addStretch( 1000 );
00058 layout->addWidget( new QLabel( "Wall Elapsed:" ));
00059 layout->addWidget( wall_elapsed_label_ );
00060 layout->addStretch( 1000 );
00061 layout->addWidget( new QLabel( "ROS Time:" ));
00062 layout->addWidget( ros_time_label_ );
00063 layout->addStretch( 1000 );
00064 layout->addWidget( new QLabel( "ROS Elapsed:" ));
00065 layout->addWidget( ros_elapsed_label_ );
00066 layout->addStretch( 1000 );
00067 layout->addWidget( reset_button );
00068 layout->setContentsMargins( 11, 5, 11, 5 );
00069 setLayout( layout );
00070
00071 connect( reset_button, SIGNAL( clicked( bool )), this, SLOT( reset() ));
00072 }
00073
00074 QLineEdit* TimePanel::makeTimeLabel()
00075 {
00076 QLineEdit* label = new QLineEdit;
00077 label->setReadOnly( true );
00078 return label;
00079 }
00080
00081 void TimePanel::initialize(VisualizationManager* manager)
00082 {
00083 manager_ = manager;
00084
00085 connect( manager_, SIGNAL( timeChanged() ), this, SLOT( update() ));
00086 }
00087
00088 void TimePanel::fillTimeLabel( QLineEdit* label, double time )
00089 {
00090 label->setText( QString::number( time, 'f', 2 ));
00091 }
00092
00093 void TimePanel::update()
00094 {
00095 fillTimeLabel( wall_time_label_, manager_->getWallClock() );
00096 fillTimeLabel( wall_elapsed_label_, manager_->getWallClockElapsed() );
00097 fillTimeLabel( ros_time_label_, manager_->getROSTime() );
00098 fillTimeLabel( ros_elapsed_label_, manager_->getROSTimeElapsed() );
00099 }
00100
00101 void TimePanel::reset()
00102 {
00103 manager_->resetTime();
00104 }
00105
00106 }
00107