bounding_box_array_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/or 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 
37 #include <jsk_topic_tools/color_utils.h>
38 
39 namespace jsk_rviz_plugins
40 {
41 
43  {
45  "coloring", "Auto",
46  "coloring method",
47  this, SLOT(updateColoring()));
48  coloring_property_->addOption("Flat color", 1);
49  coloring_property_->addOption("Label", 2);
50  coloring_property_->addOption("Value", 3);
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  // Imediately apply attribute
130  if (latest_msg_) {
131  if (only_edge_) {
133  }
134  else {
136  }
137  }
138  }
139 
141  {
142  if (coloring_property_->getOptionInt() == 0) {
143  coloring_method_ = "auto";
145  }
146  else if (coloring_property_->getOptionInt() == 1) {
147  coloring_method_ = "flat";
149  }
150  else if (coloring_property_->getOptionInt() == 2) {
151  coloring_method_ = "label";
153  }
154  else if (coloring_property_->getOptionInt() == 3) {
155  coloring_method_ = "value";
157  }
158 
159  if (latest_msg_) {
161  }
162  }
163 
165  {
167  // Immediately apply show_coords attribute
168  if (!show_coords_) {
169  hideCoords();
170  }
171  else if (show_coords_ && latest_msg_) {
173  }
174  }
175 
177  {
178  MFDClass::reset();
179  shapes_.clear();
180  edges_.clear();
181  coords_nodes_.clear();
182  coords_objects_.clear();
183  latest_msg_.reset();
184  }
185 
187  const jsk_recognition_msgs::BoundingBoxArray::ConstPtr& msg)
188  {
189  // Store latest message
190  latest_msg_ = msg;
191 
192  if (!only_edge_) {
193  showBoxes(msg);
194  }
195  else {
196  showEdges(msg);
197  }
198 
199  if (show_coords_) {
200  showCoords(msg);
201  }
202  else {
203  hideCoords();
204  }
205  }
206 
207 } // namespace jsk_rviz_plugins
208 
rviz::BoolProperty::getBool
virtual bool getBool() const
jsk_rviz_plugins::BoundingBoxArrayDisplay::BoundingBoxArrayDisplay
BoundingBoxArrayDisplay()
Definition: bounding_box_array_display.cpp:74
rviz::EnumProperty::getOptionInt
virtual int getOptionInt()
jsk_rviz_plugins::BoundingBoxArrayDisplay::latest_msg_
jsk_recognition_msgs::BoundingBoxArray::ConstPtr latest_msg_
Definition: bounding_box_array_display.h:140
rviz::ColorProperty::getColor
virtual QColor getColor() const
rviz::MessageFilterDisplay< MessageType >::reset
void reset() override
msg
msg
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showCoords
void showCoords(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:411
rviz::Property::show
void show()
jsk_rviz_plugins::BoundingBoxArrayDisplay::show_coords_
bool show_coords_
Definition: bounding_box_array_display.h:131
bounding_box_array_display.h
jsk_rviz_plugins::BoundingBoxArrayDisplay::line_width_property_
rviz::FloatProperty * line_width_property_
Definition: bounding_box_array_display.h:137
rviz::BoolProperty
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coords_objects_
std::vector< std::vector< ArrowPtr > > coords_objects_
Definition: bounding_box_display_common.h:143
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateColor
void updateColor()
Definition: bounding_box_array_display.cpp:136
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateLineWidth
void updateLineWidth()
Definition: bounding_box_array_display.cpp:128
jsk_rviz_plugins::BoundingBoxArrayDisplay::processMessage
void processMessage(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_array_display.cpp:218
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coords_nodes_
std::vector< Ogre::SceneNode * > coords_nodes_
Definition: bounding_box_display_common.h:144
rviz::ColorProperty
rviz::Display
rviz::EnumProperty
rviz::FloatProperty
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateColoring
void updateColoring()
Definition: bounding_box_array_display.cpp:172
class_list_macros.h
rviz::Property::hide
void hide()
jsk_rviz_plugins::BoundingBoxArrayDisplay::only_edge_
bool only_edge_
Definition: bounding_box_array_display.h:130
jsk_rviz_plugins::BoundingBoxArrayDisplay::alpha_property_
rviz::FloatProperty * alpha_property_
Definition: bounding_box_array_display.h:135
jsk_rviz_plugins::BoundingBoxArrayDisplay::~BoundingBoxArrayDisplay
virtual ~BoundingBoxArrayDisplay()
Definition: bounding_box_array_display.cpp:106
jsk_rviz_plugins::BoundingBoxArrayDisplay::coloring_property_
rviz::EnumProperty * coloring_property_
Definition: bounding_box_array_display.h:133
rviz::FloatProperty::getFloat
virtual float getFloat() const
rviz::EnumProperty::addOption
virtual void addOption(const QString &option, int value=0)
bounding_box_display_common.h
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showEdges
void showEdges(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:316
rviz::Display::scene_node_
Ogre::SceneNode * scene_node_
jsk_rviz_plugins::BoundingBoxArrayDisplay::show_coords_property_
rviz::BoolProperty * show_coords_property_
Definition: bounding_box_array_display.h:138
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::edges_
std::vector< BillboardLinePtr > edges_
Definition: bounding_box_display_common.h:145
rviz::Display::scene_manager_
Ogre::SceneManager * scene_manager_
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::alpha_
double alpha_
Definition: bounding_box_display_common.h:140
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::hideCoords
void hideCoords()
Definition: bounding_box_display_common.h:493
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::showBoxes
void showBoxes(const jsk_recognition_msgs::BoundingBoxArray::ConstPtr &msg)
Definition: bounding_box_display_common.h:257
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateOnlyEdge
void updateOnlyEdge()
Definition: bounding_box_array_display.cpp:152
jsk_rviz_plugins::BoundingBoxArrayDisplay::only_edge_property_
rviz::BoolProperty * only_edge_property_
Definition: bounding_box_array_display.h:136
rviz::MessageFilterDisplay< MessageType >::onInitialize
void onInitialize() override
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::line_width_
double line_width_
Definition: bounding_box_display_common.h:141
PLUGINLIB_EXPORT_CLASS
PLUGINLIB_EXPORT_CLASS(jsk_rviz_plugins::PictogramArrayDisplay, rviz::Display)
jsk_rviz_plugins::BoundingBoxArrayDisplay::color_property_
rviz::ColorProperty * color_property_
Definition: bounding_box_array_display.h:134
jsk_rviz_plugins::BoundingBoxArrayDisplay::reset
virtual void reset()
Definition: bounding_box_array_display.cpp:208
jsk_rviz_plugins::BoundingBoxArrayDisplay::onInitialize
void onInitialize()
Definition: bounding_box_array_display.cpp:115
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::color_
QColor color_
Definition: bounding_box_display_common.h:138
jsk_rviz_plugins::BoundingBoxArrayDisplay
Definition: bounding_box_array_display.h:88
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateAlpha
void updateAlpha()
Definition: bounding_box_array_display.cpp:144
jsk_rviz_plugins
Definition: __init__.py:1
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::shapes_
std::vector< ShapePtr > shapes_
Definition: bounding_box_display_common.h:146
jsk_rviz_plugins::BoundingBoxDisplayCommon< jsk_recognition_msgs::BoundingBoxArray >::coloring_method_
std::string coloring_method_
Definition: bounding_box_display_common.h:139
jsk_rviz_plugins::BoundingBoxArrayDisplay::updateShowCoords
void updateShowCoords()
Definition: bounding_box_array_display.cpp:196


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