display_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 
31 
33 #include <rviz/display_context.h>
34 #include <rviz/bit_allocator.h>
35 #include <rviz/display.h>
36 #include <rviz/display_group.h>
37 
38 namespace rviz
39 {
41  Display* display,
42  const QString& name,
43  bool default_value,
44  const QString& description,
45  Property* parent)
46  : BoolProperty(name, default_value, description, parent), vis_bit_(vis_bit), display_(display)
47 {
48  custom_name_ = (name.size() != 0);
50 }
51 
53 {
54 }
55 
57 {
58  // update name, unless we had a custom name given in the constructor
59  if (!custom_name_ && getName() != display_->getName())
60  {
62  }
63  if (getBool() && (getViewFlags(0) & Qt::ItemIsEnabled))
64  {
66  }
67  else
68  {
70  }
71 }
72 
73 bool DisplayVisibilityProperty::setValue(const QVariant& new_value)
74 {
75  if (Property::setValue(new_value))
76  {
77  update();
78  return true;
79  }
80  return false;
81 }
82 
84 {
85  if (!display_->isEnabled())
86  {
87  return false;
88  }
89  return BoolProperty::getBool();
90 }
91 
92 Qt::ItemFlags DisplayVisibilityProperty::getViewFlags(int column) const
93 {
94  if (!display_->isEnabled())
95  {
96  return Qt::ItemIsSelectable;
97  }
98  return BoolProperty::getViewFlags(column);
99 }
100 
101 
102 } // namespace rviz
bit_allocator.h
rviz::BoolProperty::getBool
virtual bool getBool() const
Definition: bool_property.cpp:48
rviz::Display::isEnabled
bool isEnabled() const
Return true if this Display is enabled, false if not.
Definition: display.cpp:271
rviz::Property::setName
virtual void setName(const QString &name)
Set the name.
Definition: property.cpp:155
rviz::DisplayVisibilityProperty::setValue
bool setValue(const QVariant &new_value) override
Definition: display_visibility_property.cpp:73
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
description
description
rviz::DisplayVisibilityProperty::update
virtual void update()
Definition: display_visibility_property.cpp:56
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::Display::setVisibilityBits
void setVisibilityBits(uint32_t bits)
Definition: display.cpp:338
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
display_visibility_property.h
rviz::DisplayVisibilityProperty::~DisplayVisibilityProperty
~DisplayVisibilityProperty() override
Definition: display_visibility_property.cpp:52
rviz::Property::setValue
virtual bool setValue(const QVariant &new_value)
Set the new value for this property. Returns true if the new value is different from the old value,...
Definition: property.cpp:134
rviz
Definition: add_display_dialog.cpp:54
display_group.h
rviz::Display::unsetVisibilityBits
void unsetVisibilityBits(uint32_t bits)
Definition: display.cpp:344
rviz::Property::getViewFlags
virtual Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.
Definition: property.cpp:290
display.h
rviz::Property::getName
virtual QString getName() const
Return the name of this Property as a QString.
Definition: property.cpp:164
rviz::DisplayVisibilityProperty::custom_name_
bool custom_name_
Definition: display_visibility_property.h:109
rviz::DisplayVisibilityProperty::display_
Display * display_
Definition: display_visibility_property.h:108
default_value
def default_value(type_)
display_context.h
rviz::DisplayVisibilityProperty::getBool
bool getBool() const override
Definition: display_visibility_property.cpp:83
rviz::DisplayVisibilityProperty::getViewFlags
Qt::ItemFlags getViewFlags(int column) const override
Return item flags appropriate for the given column (0 or 1) for this Property.
Definition: display_visibility_property.cpp:92
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