transformable_marker_operator.cpp
Go to the documentation of this file.
00001 #include <QLineEdit>
00002 #include <QPushButton>
00003 #include <QVBoxLayout>
00004 #include <QHBoxLayout>
00005 #include <QTabWidget>
00006 #include <QLabel>
00007 
00008 #include "transformable_marker_operator.h"
00009 
00010 using namespace rviz;
00011 namespace jsk_rviz_plugins
00012 {
00013   TransformableMarkerOperatorAction::TransformableMarkerOperatorAction( QWidget* parent )
00014     : rviz::Panel( parent )
00015   {
00016     layout = new QVBoxLayout;
00017 
00018     QVBoxLayout* layout1 = new QVBoxLayout;
00019     QVBoxLayout* layout2 = new QVBoxLayout;
00020 
00021     QTabWidget* tabs = new QTabWidget();
00022 
00023     QWidget* tab_1 = new QWidget();
00024     QWidget* tab_2 = new QWidget();
00025 
00026     //Button to send cancel topic
00027     insert_box_button_ = new QPushButton("Insert New Box Marker");
00028     layout1->addWidget( insert_box_button_ );
00029 
00030     insert_cylinder_button_ = new QPushButton("Insert New Cylinder Marker");
00031     layout1->addWidget( insert_cylinder_button_ );
00032 
00033     insert_torus_button_ = new QPushButton("Insert New Torus Marker");
00034     layout1->addWidget( insert_torus_button_ );
00035 
00036     QHBoxLayout* name_layout = new QHBoxLayout;
00037     name_layout->addWidget( new QLabel( "Name:" ));
00038     name_editor_ = new QLineEdit;
00039     name_layout->addWidget( name_editor_ );
00040     layout1->addLayout( name_layout );
00041 
00042     QHBoxLayout* description_layout = new QHBoxLayout;
00043     description_layout->addWidget( new QLabel( "Description:" ));
00044     description_editor_ = new QLineEdit;
00045     description_layout->addWidget( description_editor_ );
00046     layout1->addLayout( description_layout );
00047 
00048     QHBoxLayout* frame_layout = new QHBoxLayout;
00049     frame_layout->addWidget( new QLabel( "Frame:" ));
00050     frame_editor_ = new QLineEdit;
00051     frame_layout->addWidget( frame_editor_ );
00052     layout1->addLayout( frame_layout );
00053 
00054     erase_with_id_button_ = new QPushButton("Erase with id");
00055     layout2->addWidget( erase_with_id_button_ );
00056 
00057     QHBoxLayout* id_layout = new QHBoxLayout;
00058     id_layout->addWidget( new QLabel( "Id:" ));
00059     id_editor_ = new QLineEdit;
00060     id_layout->addWidget( id_editor_ );
00061     layout2->addLayout( id_layout );
00062 
00063     erase_all_button_ = new QPushButton("Erase all");
00064     layout2->addWidget( erase_all_button_ );
00065 
00066     erase_focus_button_ = new QPushButton("Erase focus");
00067     layout2->addWidget( erase_focus_button_ );
00068 
00069     tab_1->setLayout( layout1 );
00070     tab_2->setLayout( layout2 );
00071 
00072     tabs->addTab(tab_1, QString("Insert"));
00073     tabs->addTab(tab_2, QString("Erase"));
00074 
00075     layout->addWidget( tabs );
00076     setLayout( layout );
00077 
00078     connect( insert_box_button_, SIGNAL( clicked() ), this, SLOT( insertBoxService ()));
00079     connect( insert_cylinder_button_, SIGNAL( clicked() ), this, SLOT( insertCylinderService ()));
00080     connect( insert_torus_button_, SIGNAL( clicked() ), this, SLOT( insertTorusService ()));
00081     connect( erase_with_id_button_, SIGNAL( clicked() ), this, SLOT( eraseWithIdService ()));
00082     connect( erase_all_button_, SIGNAL( clicked() ), this, SLOT( eraseAllService ()));
00083     connect( erase_focus_button_, SIGNAL( clicked() ), this, SLOT( eraseFocusService ()));
00084   }
00085 
00086   void TransformableMarkerOperatorAction::insertBoxService(){
00087     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00088     operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::BOX;
00089     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
00090     operator_srv.request.operate.name = name_editor_->text().toStdString();
00091     operator_srv.request.operate.description = description_editor_->text().toStdString();
00092     operator_srv.request.operate.frame_id = frame_editor_->text().toStdString();
00093     callRequestMarkerOperateService(operator_srv);
00094   };
00095 
00096   void TransformableMarkerOperatorAction::insertCylinderService(){
00097     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00098     operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::CYLINDER;
00099     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
00100     operator_srv.request.operate.name = name_editor_->text().toStdString();
00101     operator_srv.request.operate.description = description_editor_->text().toStdString();
00102     operator_srv.request.operate.frame_id = frame_editor_->text().toStdString();
00103     callRequestMarkerOperateService(operator_srv);
00104   };
00105 
00106   void TransformableMarkerOperatorAction::insertTorusService(){
00107     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00108     operator_srv.request.operate.type = jsk_rviz_plugins::TransformableMarkerOperate::TORUS;
00109     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::INSERT;
00110     operator_srv.request.operate.name = name_editor_->text().toStdString();
00111     operator_srv.request.operate.description = description_editor_->text().toStdString();
00112     operator_srv.request.operate.frame_id = frame_editor_->text().toStdString();
00113     callRequestMarkerOperateService(operator_srv);
00114   };
00115 
00116   void TransformableMarkerOperatorAction::eraseWithIdService(){
00117     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00118     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASE;
00119     operator_srv.request.operate.name = id_editor_->text().toStdString();
00120     callRequestMarkerOperateService(operator_srv);
00121   };
00122 
00123   void TransformableMarkerOperatorAction::eraseAllService(){
00124     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00125     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASEALL;
00126     callRequestMarkerOperateService(operator_srv);
00127   };
00128 
00129   void TransformableMarkerOperatorAction::eraseFocusService(){
00130     jsk_rviz_plugins::RequestMarkerOperate operator_srv;
00131     operator_srv.request.operate.action = jsk_rviz_plugins::TransformableMarkerOperate::ERASEFOCUS;
00132     callRequestMarkerOperateService(operator_srv);
00133   };
00134 
00135   void TransformableMarkerOperatorAction::callRequestMarkerOperateService(jsk_rviz_plugins::RequestMarkerOperate srv){
00136     ros::ServiceClient client = nh_.serviceClient<jsk_rviz_plugins::RequestMarkerOperate>("request_marker_operate", true);
00137     if(client.call(srv))
00138       {
00139         ROS_INFO("Call Success");
00140       }
00141     else{
00142       ROS_ERROR("Service call FAIL");
00143     };
00144   }
00145 
00146   void TransformableMarkerOperatorAction::save( rviz::Config config ) const
00147   {
00148     rviz::Panel::save( config );
00149   }
00150 
00151   void TransformableMarkerOperatorAction::load( const rviz::Config& config )
00152   {
00153     rviz::Panel::load( config );
00154   }
00155 }
00156 
00157 #include <pluginlib/class_list_macros.h>
00158 PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::TransformableMarkerOperatorAction, rviz::Panel )


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sun Sep 13 2015 22:29:03