bounding_box_display.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Ryohei Ueda and JSK Lab
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/o2r other materials provided
16  * with the distribution.
17  * * Neither the name of the JSK Lab nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
36 #include "bounding_box_display.h"
38 
39 namespace jsk_rviz_plugins
40 {
41 
43  {
45  "coloring", "Flat color",
46  "coloring method",
47  this, SLOT(updateColoring()));
48  coloring_property_->addOption("Flat color", 0);
49  coloring_property_->addOption("Label", 1);
50  coloring_property_->addOption("Value", 2);
51 
53  "color", QColor(25, 255, 0),
54  "color to draw the bounding boxes",
55  this, SLOT(updateColor()));
57  "alpha", 0.8,
58  "alpha value to draw the bounding boxes",
59  this, SLOT(updateAlpha()));
61  "only edge", false,
62  "show only the edges of the boxes",
63  this, SLOT(updateOnlyEdge()));
65  "line width", 0.005,
66  "line width of the edges",
67  this, SLOT(updateLineWidth()));
69  "show coords", false,
70  "show coordinate of bounding box",
71  this, SLOT(updateShowCoords()));
72  }
73 
75  {
76  delete color_property_;
77  delete alpha_property_;
78  delete only_edge_property_;
79  delete coloring_property_;
80  delete show_coords_property_;
81  }
82 
84  {
86  scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
87 
88  updateColor();
89  updateAlpha();
94  }
95 
97  {
99  if (latest_msg_) {
101  }
102  }
103 
105  {
107  if (latest_msg_) {
109  }
110  }
111 
113  {
115  if (latest_msg_) {
117  }
118  }
119 
121  {
123  if (only_edge_) {
125  }
126  else {
128  }
129  if (latest_msg_) {
131  }
132  }
133 
135  {
136  if (coloring_property_->getOptionInt() == 0) {
137  coloring_method_ = "flat";
139  }
140  else if (coloring_property_->getOptionInt() == 1) {
141  coloring_method_ = "label";
143  }
144  else if (coloring_property_->getOptionInt() == 2) {
145  coloring_method_ = "value";
147  }
148 
149  if (latest_msg_) {
151  }
152  }
153 
155  {
157  // Immediately apply show_coords attribute
158  if (!show_coords_) {
159  hideCoords();
160  }
161  else if (latest_msg_) {
163  }
164  }
165 
167  {
168  MFDClass::reset();
169  shapes_.clear();
170  edges_.clear();
171  coords_nodes_.clear();
172  coords_objects_.clear();
173  latest_msg_.reset();
174  }
175 
177  const jsk_recognition_msgs::BoundingBox::ConstPtr& msg)
178  {
179  // Store latest message
180  latest_msg_ = msg;
181 
182  // Convert bbox to bbox_array to show it
183  jsk_recognition_msgs::BoundingBoxArrayPtr bbox_array_msg(new jsk_recognition_msgs::BoundingBoxArray);
184  bbox_array_msg->header = msg->header;
185  std::vector<jsk_recognition_msgs::BoundingBox> boxes;
186  boxes.push_back(*msg);
187  bbox_array_msg->boxes = boxes;
188 
189  if (!only_edge_) {
190  showBoxes(bbox_array_msg);
191  }
192  else {
193  showEdges(bbox_array_msg);
194  }
195 
196  if (show_coords_) {
197  showCoords(bbox_array_msg);
198  }
199  else {
200  hideCoords();
201  }
202  }
203 
204 } // namespace jsk_rviz_plugins
205 
virtual QColor getColor() const
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
jsk_recognition_msgs::BoundingBox::ConstPtr latest_msg_
virtual float getFloat() const
Ogre::SceneNode * scene_node_
virtual bool getBool() const
virtual void addOption(const QString &option, int value=0)
void processMessage(const jsk_recognition_msgs::BoundingBox::ConstPtr &msg)
Ogre::SceneManager * scene_manager_
void showCoords(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
void showBoxes(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
void showEdges(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
virtual int getOptionInt()


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sat Mar 20 2021 03:03:18