object_fit_operator.cpp
Go to the documentation of this file.
1 #include <QLineEdit>
2 #include <QToolButton>
3 #include <QVBoxLayout>
4 #include <QHBoxLayout>
5 #include <QTabWidget>
6 #include <QCheckBox>
7 #include <QLabel>
8 #include <ros/package.h>
9 
10 #include "object_fit_operator.h"
11 
12 using namespace rviz;
13 namespace jsk_rviz_plugins
14 {
15  ObjectFitOperatorAction::ObjectFitOperatorAction( QWidget* parent )
16  : rviz::Panel( parent )
17  {
18  layout = new QVBoxLayout;
19 
20  horizontal_layout1_ = new QHBoxLayout();
21  horizontal_layout2_ = new QHBoxLayout();
22 
23  //Button to send cancel topic
24  std::string fit_button_name, reverse_fit_button_name, near_button_name, other_button_name;
25  nh_.param<std::string>("/object_fit_icon", fit_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/fit.jpg"));
26  nh_.param<std::string>("/object_near_icon", near_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/near.jpg"));
27  nh_.param<std::string>("/object_other_icon", other_button_name, ros::package::getPath("jsk_rviz_plugins")+std::string("/icons/other.jpg"));
28 
29  QSize iconSize(150, 150);
30  fit_button_ = new QToolButton();
31  fit_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
32  fit_button_->setIcon(QIcon(QPixmap(QString(fit_button_name.c_str()))));
33  fit_button_->setText("Onto");
34  fit_button_->setIconSize(iconSize);
35  horizontal_layout1_->addWidget( fit_button_ );
36 
37  check_box_ = new QCheckBox(QString("Reverse"));
38  horizontal_layout1_->addWidget(check_box_);
39 
40  near_button_ = new QToolButton();
41  near_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
42  near_button_->setIcon(QIcon(QPixmap(QString(near_button_name.c_str()))));
43  near_button_->setIconSize(iconSize);
44  near_button_->setText("Parallel");
45  horizontal_layout2_->addWidget( near_button_ );
46 
47  other_button_ = new QToolButton();
48  other_button_->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
49  other_button_->setIcon(QIcon(QPixmap(QString(other_button_name.c_str()))));
50  other_button_->setText("Perpendicular");
51  other_button_->setIconSize(iconSize);
52  horizontal_layout2_->addWidget( other_button_ );
53 
54  layout->addLayout(horizontal_layout1_);
55  layout->addLayout(horizontal_layout2_);
56  setLayout( layout );
57 
58  connect( fit_button_, SIGNAL( clicked() ), this, SLOT( commandFit()));
59  connect( check_box_, SIGNAL(clicked(bool)), this, SLOT(checkBoxChanged(bool)));
60  connect( near_button_, SIGNAL( clicked() ), this, SLOT( commandNear()));
61  connect( other_button_, SIGNAL( clicked() ), this, SLOT( commandOther()));
62 
63  pub_ = nh_.advertise<jsk_rviz_plugins::ObjectFitCommand>( "/object_fit_command", 1 );
64  }
65 
67  reverse_ = state;
68  }
69 
71  if(reverse_)
72  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_FIT);
73  else
74  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::FIT);
75  }
76 
78  if(reverse_)
79  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_NEAR);
80  else
81  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::NEAR);
82  }
83 
85  if(reverse_)
86  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::REVERSE_OTHER);
87  else
88  publishObjectFitOder(jsk_rviz_plugins::ObjectFitCommand::OTHER);
89  }
90 
92  jsk_rviz_plugins::ObjectFitCommand msg;
93  msg.command = type;
94  pub_.publish(msg);
95  }
96 
98  {
100  }
101 
103  {
105  }
106 }
107 
msg
msg
ros::package::getPath
ROSLIB_DECL std::string getPath(const std::string &package_name)
object_fit_operator.h
jsk_rviz_plugins::ObjectFitOperatorAction::other_button_
QToolButton * other_button_
Definition: object_fit_operator.h:42
rviz::Panel
jsk_rviz_plugins::ObjectFitOperatorAction::checkBoxChanged
void checkBoxChanged(bool state)
Definition: object_fit_operator.cpp:66
jsk_rviz_plugins::ObjectFitOperatorAction::nh_
ros::NodeHandle nh_
Definition: object_fit_operator.h:50
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
class_list_macros.h
jsk_rviz_plugins::ObjectFitOperatorAction::publishObjectFitOder
void publishObjectFitOder(int type)
Definition: object_fit_operator.cpp:91
jsk_rviz_plugins::ObjectFitOperatorAction::load
virtual void load(const rviz::Config &config)
Definition: object_fit_operator.cpp:102
jsk_rviz_plugins::ObjectFitOperatorAction::reverse_
bool reverse_
Definition: object_fit_operator.h:48
jsk_rviz_plugins::ObjectFitOperatorAction
Definition: object_fit_operator.h:23
jsk_rviz_plugins::ObjectFitOperatorAction::commandNear
void commandNear()
Definition: object_fit_operator.cpp:77
rviz
jsk_rviz_plugins::ObjectFitOperatorAction::horizontal_layout2_
QHBoxLayout * horizontal_layout2_
Definition: object_fit_operator.h:46
jsk_rviz_plugins::ObjectFitOperatorAction::near_button_
QToolButton * near_button_
Definition: object_fit_operator.h:41
jsk_rviz_plugins::ObjectFitOperatorAction::fit_button_
QToolButton * fit_button_
Definition: object_fit_operator.h:40
package.h
jsk_rviz_plugins::ObjectFitOperatorAction::check_box_
QCheckBox * check_box_
Definition: object_fit_operator.h:43
jsk_rviz_plugins::ObjectFitOperatorAction::pub_
ros::Publisher pub_
Definition: object_fit_operator.h:51
contact_state_sample.state
state
Definition: contact_state_sample.py:15
jsk_rviz_plugins::ObjectFitOperatorAction::save
virtual void save(rviz::Config config) const
Definition: object_fit_operator.cpp:97
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
rviz::Panel::load
virtual void load(const Config &config)
jsk_rviz_plugins::ObjectFitOperatorAction::horizontal_layout1_
QHBoxLayout * horizontal_layout1_
Definition: object_fit_operator.h:45
rviz::Panel::save
virtual void save(Config config) const
jsk_rviz_plugins::ObjectFitOperatorAction::layout
QVBoxLayout * layout
Definition: object_fit_operator.h:47
jsk_rviz_plugins::ObjectFitOperatorAction::commandFit
void commandFit()
Definition: object_fit_operator.cpp:70
ros::NodeHandle::param
T param(const std::string &param_name, const T &default_val) const
config
config
jsk_rviz_plugins
Definition: __init__.py:1
rviz::Config
jsk_rviz_plugins::ObjectFitOperatorAction::commandOther
void commandOther()
Definition: object_fit_operator.cpp:84


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Aug 2 2024 08:50:14