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 {
40 
42  Display* display,
43  const QString& name,
44  bool default_value,
45  const QString& description,
46  Property* parent,
47  const char *changed_slot,
48  QObject* receiver )
49 : BoolProperty( name, default_value, description, parent, changed_slot, receiver )
50 , vis_bit_(vis_bit)
51 , display_(display)
52 {
53  custom_name_ = (name.size() != 0);
54  update();
55 }
56 
58 {
59 }
60 
62 {
63  // update name, unless we had a custom name given in the constructor
64  if ( !custom_name_ && getName() != display_->getName() )
65  {
66  setName( display_->getName() );
67  }
68  if ( getBool() &&
69  (getViewFlags( 0 ) & Qt::ItemIsEnabled ) )
70  {
72  }
73  else
74  {
76  }
77 }
78 
79 bool DisplayVisibilityProperty::setValue( const QVariant& new_value )
80 {
81  if ( Property::setValue( new_value ) )
82  {
83  update();
84  return true;
85  }
86  return false;
87 }
88 
90 {
91  if ( !display_->isEnabled() )
92  {
93  return false;
94  }
95  return BoolProperty::getBool();
96 }
97 
98 Qt::ItemFlags DisplayVisibilityProperty::getViewFlags( int column ) const
99 {
100  if ( !display_->isEnabled() )
101  {
102  return Qt::ItemIsSelectable;
103  }
104  return BoolProperty::getViewFlags( column );
105 }
106 
107 
108 }
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:130
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:150
DisplayVisibilityProperty(uint32_t vis_bit, Display *display, const QString &name=QString(), bool default_value=false, const QString &description=QString(), Property *parent=0, const char *changed_slot=0, QObject *receiver=0)
void unsetVisibilityBits(uint32_t bits)
Definition: display.cpp:351
bool isEnabled() const
Return true if this Display is enabled, false if not.
Definition: display.cpp:281
virtual bool getBool() const
virtual bool setValue(const QVariant &new_value)
Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.
void setVisibilityBits(uint32_t bits)
Definition: display.cpp:345
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
virtual QString getName() const
Return the name of this Property as a QString.
Definition: property.cpp:159
virtual Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.
Definition: property.cpp:285


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:50