display_group_visibility_property.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 /*
30  * display_visibility_manager.cpp
31  *
32  * Created on: Aug 27, 2012
33  * Author: gossow
34  */
35 
37 
39 #include <rviz/display_context.h>
40 #include <rviz/bit_allocator.h>
41 #include <rviz/display.h>
42 #include <rviz/display_group.h>
43 
44 namespace rviz
45 {
47  DisplayGroup* display_group,
48  Display* parent_display,
49  const QString& name,
50  bool default_value,
51  const QString& description,
52  Property* parent)
53  : DisplayVisibilityProperty(vis_bit, display_group, name, default_value, description, parent)
54  , display_group_(display_group)
55  , parent_display_(parent_display)
56 {
57  connect(display_group, &DisplayGroup::displayAdded, this,
59  connect(display_group, &DisplayGroup::displayRemoved, this,
61 
62  for (int i = 0; i < display_group->numDisplays(); i++)
63  {
64  rviz::Display* display = display_group->getDisplayAt(i);
65  if (display != parent_display)
66  {
67  onDisplayAdded(display);
68  }
69  }
70 
72 }
73 
75 {
77  std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.begin();
78  for (; it != disp_vis_props_.end(); it++)
79  {
80  it->second->update();
81  }
82 }
83 
85 {
86  // remove and re-add everything in our property list
87  // in the same order as it appears in the display group
88  for (int i = 0; i < display_group_->numDisplays(); i++)
89  {
91  std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.find(display);
92  if (it != disp_vis_props_.end())
93  {
94  takeChild(it->second);
95  addChild(it->second);
96  }
97  }
98 }
99 
101 {
102  DisplayGroup* display_group = qobject_cast<DisplayGroup*>(display);
103  DisplayVisibilityProperty* vis_prop;
104  if (display_group)
105  {
106  vis_prop =
107  new DisplayGroupVisibilityProperty(vis_bit_, display_group, parent_display_, "", true,
108  "Uncheck to hide everything in this Display Group", this);
109  }
110  else
111  {
112  vis_prop =
113  new DisplayVisibilityProperty(vis_bit_, display, "", true, "Show or hide this Display", this);
114  }
115  disp_vis_props_[display] = vis_prop;
116  sortDisplayList();
117 }
118 
120 {
121  std::map<rviz::Display*, DisplayVisibilityProperty*>::iterator it = disp_vis_props_.find(display);
122  if (it != disp_vis_props_.end())
123  {
124  Property* child = takeChild(it->second);
125  child->setParent(nullptr);
126  delete child;
127  disp_vis_props_.erase(display);
128  }
129 }
130 
131 
133 {
134 }
135 
136 } // namespace rviz
bit_allocator.h
rviz::DisplayGroup::displayAdded
void displayAdded(rviz::Display *display)
rviz::DisplayGroupVisibilityProperty::onDisplayAdded
void onDisplayAdded(rviz::Display *display)
Definition: display_group_visibility_property.cpp:100
rviz::DisplayGroupVisibilityProperty::DisplayGroupVisibilityProperty
DisplayGroupVisibilityProperty(uint32_t vis_bit, DisplayGroup *display_group, Display *parent_display, const QString &name=QString(), bool default_value=false, const QString &description=QString(), Property *parent=nullptr)
Definition: display_group_visibility_property.cpp:46
rviz::DisplayGroupVisibilityProperty::update
void update() override
Definition: display_group_visibility_property.cpp:74
rviz::DisplayGroupVisibilityProperty::sortDisplayList
void sortDisplayList()
Definition: display_group_visibility_property.cpp:84
description
description
rviz::DisplayGroup::getDisplayAt
virtual Display * getDisplayAt(int index) const
Return the index-th Display in this group, or NULL if the index is invalid.
Definition: display_group.cpp:211
rviz::Property::addChild
virtual void addChild(Property *child, int index=-1)
Add a child property.
Definition: property.cpp:356
rviz::DisplayVisibilityProperty::update
virtual void update()
Definition: display_visibility_property.cpp:56
rviz::BoolProperty::setDisableChildrenIfFalse
void setDisableChildrenIfFalse(bool disable)
Definition: bool_property.cpp:53
rviz::DisplayVisibilityProperty::DisplayVisibilityProperty
DisplayVisibilityProperty(uint32_t vis_bit, Display *display, const QString &name=QString(), bool default_value=false, const QString &description=QString(), Property *parent=nullptr)
Definition: display_visibility_property.cpp:40
bool_property.h
rviz::Property::connect
QMetaObject::Connection connect(const QObject *receiver, const char *slot, Qt::ConnectionType type=Qt::AutoConnection)
Connect changed() signal to given slot of receiver.
Definition: property.cpp:78
rviz::Display
Definition: display.h:63
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::DisplayGroup::displayRemoved
void displayRemoved(rviz::Display *display)
rviz::DisplayGroupVisibilityProperty::disp_vis_props_
std::map< rviz::Display *, DisplayVisibilityProperty * > disp_vis_props_
Definition: display_group_visibility_property.h:129
rviz
Definition: add_display_dialog.cpp:54
rviz::DisplayGroupVisibilityProperty::display_group_
DisplayGroup * display_group_
Definition: display_group_visibility_property.h:128
rviz::DisplayGroup::numDisplays
virtual int numDisplays() const
Return the number of child Displays.
Definition: display_group.cpp:342
display_group.h
rviz::DisplayVisibilityProperty
Definition: display_visibility_property.h:55
display.h
rviz::Property::setParent
void setParent(Property *new_parent)
Set parent property, without telling the parent.
Definition: property.cpp:236
rviz::DisplayGroupVisibilityProperty::onDisplayRemoved
void onDisplayRemoved(rviz::Display *display)
Definition: display_group_visibility_property.cpp:119
default_value
def default_value(type_)
display_group_visibility_property.h
rviz::DisplayGroupVisibilityProperty::~DisplayGroupVisibilityProperty
~DisplayGroupVisibilityProperty() override
Definition: display_group_visibility_property.cpp:132
display_context.h
rviz::DisplayGroupVisibilityProperty::parent_display_
Display * parent_display_
Definition: display_group_visibility_property.h:130
rviz::Property::takeChild
Property * takeChild(Property *child)
Remove a given child object and return a pointer to it.
Definition: property.cpp:322
rviz::DisplayGroup
A Display object which stores other Displays as children.
Definition: display_group.h:47
rviz::DisplayVisibilityProperty::vis_bit_
uint32_t vis_bit_
Definition: display_visibility_property.h:107


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:09