object_fit_operator.cpp
Go to the documentation of this file.
00001 #include <QLineEdit>
00002 #include <QToolButton>
00003 #include <QVBoxLayout>
00004 #include <QHBoxLayout>
00005 #include <QTabWidget>
00006 #include <QCheckBox>
00007 #include <QLabel>
00008 #include <ros/package.h>
00009 
00010 #include "object_fit_operator.h"
00011 
00012 using namespace rviz;
00013 namespace jsk_rviz_plugins
00014 {
00015   ObjectFitOperatorAction::ObjectFitOperatorAction( QWidget* parent )
00016     : rviz::Panel( parent )
00017   {
00018     layout = new QVBoxLayout;
00019 
00020     horizontal_layout1_ = new QHBoxLayout();
00021     horizontal_layout2_ = new QHBoxLayout();
00022 
00023     //Button to send cancel topic
00024     std::string fit_button_name, reverse_fit_button_name, near_button_name, other_button_name;
00025     nh_.param<std::string>("/object_fit_icon", fit_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/fit.jpg"));
00026     nh_.param<std::string>("/object_near_icon", near_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/near.jpg"));
00027     nh_.param<std::string>("/object_other_icon", other_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/other.jpg"));
00028 
00029     QSize iconSize(150, 150);
00030     fit_button_ = new QToolButton();
00031     fit_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
00032     fit_button_->setIcon(QIcon(QPixmap(QString(fit_button_name.c_str()))));
00033     fit_button_->setText("Onto");
00034     fit_button_->setIconSize(iconSize);
00035     horizontal_layout1_->addWidget( fit_button_ );
00036 
00037     check_box_ = new QCheckBox(QString("Reverse"));
00038     horizontal_layout1_->addWidget(check_box_);
00039 
00040     near_button_ = new QToolButton();
00041     near_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
00042     near_button_->setIcon(QIcon(QPixmap(QString(near_button_name.c_str()))));
00043     near_button_->setIconSize(iconSize);
00044     near_button_->setText("Parallel");
00045     horizontal_layout2_->addWidget( near_button_ );
00046 
00047     other_button_ = new QToolButton();
00048     other_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
00049     other_button_->setIcon(QIcon(QPixmap(QString(other_button_name.c_str()))));
00050     other_button_->setText("Perpendicular");
00051     other_button_->setIconSize(iconSize);
00052     horizontal_layout2_->addWidget( other_button_ );
00053 
00054     layout->addLayout(horizontal_layout1_);
00055     layout->addLayout(horizontal_layout2_);
00056     setLayout( layout );
00057 
00058     connect( fit_button_, SIGNAL( clicked() ), this, SLOT( commandFit()));
00059     connect( check_box_, SIGNAL(clicked(bool)), this, SLOT(checkBoxChanged(bool)));
00060     connect( near_button_, SIGNAL( clicked() ), this, SLOT( commandNear()));
00061     connect( other_button_, SIGNAL( clicked() ), this, SLOT( commandOther()));
00062 
00063     pub_ = nh_.advertise<jsk_rviz_plugins::ObjectFitCommand>( "/object_fit_command", 1 );
00064   }
00065 
00066   void ObjectFitOperatorAction::checkBoxChanged(bool state){
00067     reverse_ = state;
00068   }
00069 
00070   void ObjectFitOperatorAction::commandFit(){
00071     if(reverse_)
00072       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_FIT);
00073     else
00074       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::FIT);
00075   }
00076 
00077   void ObjectFitOperatorAction::commandNear(){
00078     if(reverse_)
00079       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_NEAR);
00080     else
00081       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::NEAR);
00082   }
00083 
00084   void ObjectFitOperatorAction::commandOther(){
00085     if(reverse_)
00086       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_OTHER);
00087     else
00088       publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::OTHER);
00089   }
00090 
00091   void ObjectFitOperatorAction::publishObjectFitOder(int type){
00092     jsk_rviz_plugins::ObjectFitCommand msg;
00093     msg.command = type;
00094     pub_.publish(msg);
00095   }
00096 
00097   void ObjectFitOperatorAction::save( rviz::Config config ) const
00098   {
00099     rviz::Panel::save( config );
00100   }
00101 
00102   void ObjectFitOperatorAction::load( const rviz::Config& config )
00103   {
00104     rviz::Panel::load( config );
00105   }
00106 }
00107 
00108 #include <pluginlib/class_list_macros.h>
00109 PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::ObjectFitOperatorAction, rviz::Panel )


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