src
yes_no_button_interface.cpp
Go to the documentation of this file.
1
#include "
yes_no_button_interface.h
"
2
#include <boost/thread.hpp>
3
#include <
rviz/config.h
>
4
#include <
ros/package.h
>
5
#include <QVBoxLayout>
6
#include <QHBoxLayout>
7
#include <QSignalMapper>
8
9
#include <jsk_gui_msgs/YesNo.h>
10
11
12
namespace
jsk_rviz_plugins
13
{
14
15
YesNoButtonInterface::YesNoButtonInterface
(QWidget* parent)
16
:
rviz
::
Panel
(parent)
17
{
18
layout_
=
new
QHBoxLayout;
19
20
yes_button_
=
new
QPushButton(
"Yes"
);
21
layout_
->addWidget(
yes_button_
);
22
yes_button_
->setEnabled(
false
);
23
24
no_button_
=
new
QPushButton(
"No"
);
25
layout_
->addWidget(
no_button_
);
26
no_button_
->setEnabled(
false
);
27
28
connect(
yes_button_
, SIGNAL(clicked()),
this
, SLOT(
respondYes
()));
29
connect(
no_button_
, SIGNAL(clicked()),
this
, SLOT(
respondNo
()));
30
31
setLayout(
layout_
);
32
}
33
34
void
YesNoButtonInterface::onInitialize
()
35
{
36
ros::NodeHandle
nh;
37
if
(!
ros::service::exists
(
"/rviz/yes_no_button"
,
/*print_failure_reason*/
false
)) {
38
yes_no_button_service_
= nh.
advertiseService
(
39
"/rviz/yes_no_button"
,
40
&
YesNoButtonInterface::requested
,
41
this
);
42
}
43
}
44
45
bool
YesNoButtonInterface::requested
(
46
jsk_gui_msgs::YesNo::Request& req,
47
jsk_gui_msgs::YesNo::Response& res)
48
{
49
need_user_input_
=
true
;
50
yes_button_
->setEnabled(
true
);
51
no_button_
->setEnabled(
true
);
52
while
(
need_user_input_
) {
53
QApplication::processEvents(QEventLoop::AllEvents, 100);
54
}
55
yes_button_
->setEnabled(
false
);
56
no_button_
->setEnabled(
false
);
57
res.yes =
yes_
;
58
return
true
;
59
}
60
61
void
YesNoButtonInterface::respondYes
()
62
{
63
boost::mutex::scoped_lock
lock
(
mutex_
);
64
yes_
=
true
;
65
need_user_input_
=
false
;
66
}
67
68
void
YesNoButtonInterface::respondNo
()
69
{
70
boost::mutex::scoped_lock
lock
(
mutex_
);
71
yes_
=
false
;
72
need_user_input_
=
false
;
73
}
74
75
void
YesNoButtonInterface::save
(
rviz::Config
config)
const
76
{
77
rviz::Panel::save
(
config
);
78
}
79
80
void
YesNoButtonInterface::load
(
const
rviz::Config
& config)
81
{
82
rviz::Panel::load
(
config
);
83
}
84
85
}
// namespace jsk_rviz_plugins
86
87
88
#include <
pluginlib/class_list_macros.h
>
89
PLUGINLIB_EXPORT_CLASS
(
jsk_rviz_plugins::YesNoButtonInterface
,
rviz::Panel
)
jsk_rviz_plugins::YesNoButtonInterface::YesNoButtonInterface
YesNoButtonInterface(QWidget *parent=0)
Definition:
yes_no_button_interface.cpp:15
ros::service::exists
ROSCPP_DECL bool exists(const std::string &service_name, bool print_failure_reason)
config.h
rviz::Panel
rviz_mouse_point_to_tablet.lock
lock
Definition:
rviz_mouse_point_to_tablet.py:11
jsk_rviz_plugins::YesNoButtonInterface::onInitialize
virtual void onInitialize()
Definition:
yes_no_button_interface.cpp:34
ros::NodeHandle::advertiseService
ServiceServer advertiseService(AdvertiseServiceOptions &ops)
jsk_rviz_plugins::YesNoButtonInterface::respondNo
void respondNo()
Definition:
yes_no_button_interface.cpp:68
class_list_macros.h
jsk_rviz_plugins::YesNoButtonInterface::load
virtual void load(const rviz::Config &config)
Definition:
yes_no_button_interface.cpp:80
jsk_rviz_plugins::YesNoButtonInterface::layout_
QHBoxLayout * layout_
Definition:
yes_no_button_interface.h:38
jsk_rviz_plugins::YesNoButtonInterface::respondYes
void respondYes()
Definition:
yes_no_button_interface.cpp:61
rviz
jsk_rviz_plugins::YesNoButtonInterface::yes_
bool yes_
Definition:
yes_no_button_interface.h:41
jsk_rviz_plugins::YesNoButtonInterface::yes_button_
QPushButton * yes_button_
Definition:
yes_no_button_interface.h:39
package.h
yes_no_button_interface.h
jsk_rviz_plugins::YesNoButtonInterface::requested
virtual bool requested(jsk_gui_msgs::YesNo::Request &req, jsk_gui_msgs::YesNo::Response &res)
Definition:
yes_no_button_interface.cpp:45
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
jsk_rviz_plugins::YesNoButtonInterface
Definition:
yes_no_button_interface.h:21
rviz::Panel::load
virtual void load(const Config &config)
jsk_rviz_plugins::YesNoButtonInterface::no_button_
QPushButton * no_button_
Definition:
yes_no_button_interface.h:40
jsk_rviz_plugins::YesNoButtonInterface::mutex_
boost::mutex mutex_
Definition:
yes_no_button_interface.h:43
jsk_rviz_plugins::YesNoButtonInterface::save
virtual void save(rviz::Config config) const
Definition:
yes_no_button_interface.cpp:75
rviz::Panel::save
virtual void save(Config config) const
config
config
jsk_rviz_plugins
Definition:
__init__.py:1
rviz::Config
jsk_rviz_plugins::YesNoButtonInterface::need_user_input_
bool need_user_input_
Definition:
yes_no_button_interface.h:42
jsk_rviz_plugins::YesNoButtonInterface::yes_no_button_service_
ros::ServiceServer yes_no_button_service_
Definition:
yes_no_button_interface.h:44
ros::NodeHandle
jsk_rviz_plugins
Author(s): Kei Okada
, Yohei Kakiuchi
, Shohei Fujii
, Ryohei Ueda
autogenerated on Fri Dec 13 2024 03:49:57