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  const char* changed_slot,
47  QObject* receiver)
48  : BoolProperty(name, default_value, description, parent, changed_slot, receiver)
49  , vis_bit_(vis_bit)
50  , display_(display)
51 {
52  custom_name_ = (name.size() != 0);
53  update();
54 }
55 
57 {
58 }
59 
61 {
62  // update name, unless we had a custom name given in the constructor
63  if (!custom_name_ && getName() != display_->getName())
64  {
66  }
67  if (getBool() && (getViewFlags(0) & Qt::ItemIsEnabled))
68  {
70  }
71  else
72  {
74  }
75 }
76 
77 bool DisplayVisibilityProperty::setValue(const QVariant& new_value)
78 {
79  if (Property::setValue(new_value))
80  {
81  update();
82  return true;
83  }
84  return false;
85 }
86 
88 {
89  if (!display_->isEnabled())
90  {
91  return false;
92  }
93  return BoolProperty::getBool();
94 }
95 
96 Qt::ItemFlags DisplayVisibilityProperty::getViewFlags(int column) const
97 {
98  if (!display_->isEnabled())
99  {
100  return Qt::ItemIsSelectable;
101  }
102  return BoolProperty::getViewFlags(column);
103 }
104 
105 
106 } // namespace rviz
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
bool setValue(const QVariant &new_value) override
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
virtual void setName(const QString &name)
Set the name.
Definition: property.cpp:155
void unsetVisibilityBits(uint32_t bits)
Definition: display.cpp:355
DisplayVisibilityProperty(uint32_t vis_bit, Display *display, const QString &name=QString(), bool default_value=false, const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
virtual Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.
Definition: property.cpp:289
virtual QString getName() const
Return the name of this Property as a QString.
Definition: property.cpp:164
void setVisibilityBits(uint32_t bits)
Definition: display.cpp:349
Qt::ItemFlags getViewFlags(int column) const override
Return item flags appropriate for the given column (0 or 1) for this Property.
bool isEnabled() const
Return true if this Display is enabled, false if not.
Definition: display.cpp:268
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
virtual bool getBool() const


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24