vector_property.h
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 #ifndef VECTOR_PROPERTY_H
30 #define VECTOR_PROPERTY_H
31 
33 
35 #include <rviz/rviz_export.h>
36 
37 namespace rviz
38 {
39 class RVIZ_EXPORT VectorProperty : public Property
40 {
41  Q_OBJECT
42 public:
43  VectorProperty(const QString& name = QString(),
44  const Ogre::Vector3& default_value = Ogre::Vector3::ZERO,
45  const QString& description = QString(),
46  Property* parent = nullptr);
47 
48  template <typename Func, typename R>
49  VectorProperty(const QString& name,
50  const Ogre::Vector3& default_value,
51  const QString& description,
52  Property* parent,
53  Func&& changed_slot,
54  const R* receiver)
55  : VectorProperty(name, default_value, description, parent)
56  {
57  connect(receiver, std::forward<Func>(changed_slot));
58  }
59 
60  // this variant is required to allow omitting the receiver argument
61  template <typename Func, typename P>
62  VectorProperty(const QString& name,
63  const Ogre::Vector3& default_value,
64  const QString& description,
65  P* parent,
66  Func&& changed_slot)
67  : VectorProperty(name, default_value, description, parent)
68  {
69  connect(parent, std::forward<Func>(changed_slot));
70  }
71 
72  virtual bool setVector(const Ogre::Vector3& vector);
73  virtual Ogre::Vector3 getVector() const
74  {
75  return vector_;
76  }
77  bool add(const Ogre::Vector3& offset)
78  {
79  return setVector(getVector() + offset);
80  }
81 
82  bool setValue(const QVariant& new_value) override;
83 
84  void load(const Config& config) override;
85  void save(Config config) const override;
86 
88  void setReadOnly(bool read_only) override;
89 
90 private Q_SLOTS:
91  void updateFromChildren();
92  void emitAboutToChange();
93 
94 private:
95  void updateString();
96 
97  Ogre::Vector3 vector_;
101 
103 };
104 
105 } // end namespace rviz
106 
107 #endif // VECTOR_PROPERTY_H
property.h
description
description
rviz::VectorProperty::x_
Property * x_
Definition: vector_property.h:98
rviz::VectorProperty::VectorProperty
VectorProperty(const QString &name, const Ogre::Vector3 &default_value, const QString &description, Property *parent, Func &&changed_slot, const R *receiver)
Definition: vector_property.h:49
rviz::VectorProperty::VectorProperty
VectorProperty(const QString &name, const Ogre::Vector3 &default_value, const QString &description, P *parent, Func &&changed_slot)
Definition: vector_property.h:62
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz
Definition: add_display_dialog.cpp:54
rviz::VectorProperty::y_
Property * y_
Definition: vector_property.h:99
ogre_vector.h
rviz::VectorProperty::z_
Property * z_
Definition: vector_property.h:100
default_value
def default_value(type_)
rviz::VectorProperty
Definition: vector_property.h:39
rviz::VectorProperty::ignore_child_updates_
bool ignore_child_updates_
Definition: vector_property.h:102
rviz::VectorProperty::getVector
virtual Ogre::Vector3 getVector() const
Definition: vector_property.h:73
rviz::Config
Configuration data storage class.
Definition: config.h:124
rviz::VectorProperty::vector_
Ogre::Vector3 vector_
Definition: vector_property.h:97
rviz::VectorProperty::add
bool add(const Ogre::Vector3 &offset)
Definition: vector_property.h:77


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:03