tool.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 
30 #ifndef RVIZ_TOOL_H
31 #define RVIZ_TOOL_H
32 
33 #include <QString>
34 #include <QIcon>
35 #include <QCursor>
36 #include <QObject>
37 
38 #include "rviz/config.h"
39 #include "rviz/rviz_export.h"
40 
41 class QMouseEvent;
42 class QKeyEvent;
43 
44 namespace Ogre
45 {
46 class SceneManager;
47 }
48 
49 namespace rviz
50 {
51 class DisplayContext;
52 class Property;
53 class RenderPanel;
54 class ViewportMouseEvent;
55 
56 class RVIZ_EXPORT Tool : public QObject
57 {
58  Q_OBJECT
59 public:
68  Tool();
69  ~Tool() override;
70 
73  void initialize(DisplayContext* context);
74 
76  virtual Property* getPropertyContainer() const
77  {
78  return property_container_;
79  }
80 
82  {
83  return shortcut_key_;
84  }
85 
87  {
88  return access_all_keys_;
89  }
90 
91  virtual void activate() = 0;
92  virtual void deactivate() = 0;
93 
94  virtual void update(float wall_dt, float ros_dt)
95  {
96  (void)wall_dt;
97  (void)ros_dt;
98  }
99 
100  enum
101  {
102  Render = 1,
103  Finished = 2
104  };
105 
109  {
110  (void)event;
111  return 0;
112  }
113 
117  virtual int processKeyEvent(QKeyEvent* event, RenderPanel* panel)
118  {
119  (void)event;
120  (void)panel;
121  return 0;
122  }
123 
124  QString getName() const
125  {
126  return name_;
127  }
128 
134  void setName(const QString& name);
135 
138  QString getDescription() const
139  {
140  return description_;
141  }
142  void setDescription(const QString& description);
143 
147  virtual QString getClassId() const
148  {
149  return class_id_;
150  }
151 
154  virtual void setClassId(const QString& class_id)
155  {
156  class_id_ = class_id;
157  }
158 
164  virtual void load(const Config& config);
165 
171  virtual void save(Config config) const;
172 
174  void setIcon(const QIcon& icon);
175 
177  const QIcon& getIcon()
178  {
179  return icon_;
180  }
181 
183  void setCursor(const QCursor& cursor);
184 
186  const QCursor& getCursor()
187  {
188  return cursor_;
189  }
190 
191  void setStatus(const QString& message);
192 
193 Q_SIGNALS:
194  void close();
195  void nameChanged(const QString& name);
196 
197 protected:
202  virtual void onInitialize()
203  {
204  }
205 
206  Ogre::SceneManager* scene_manager_;
208 
211 
212  QIcon icon_;
213 
214  QCursor cursor_;
215 
216 private:
217  QString class_id_;
219  QString name_;
220  QString description_;
221 };
222 
223 } // namespace rviz
224 
225 #endif
QString name_
Definition: tool.h:219
Ogre::SceneManager * scene_manager_
Definition: tool.h:206
virtual int processMouseEvent(ViewportMouseEvent &event)
Definition: tool.h:108
bool accessAllKeys()
Definition: tool.h:86
virtual Property * getPropertyContainer() const
Return the container for properties of this Tool.
Definition: tool.h:76
ROSCONSOLE_DECL void initialize()
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
config
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: tool.h:147
virtual void onInitialize()
Definition: tool.h:202
char shortcut_key_
Definition: tool.h:209
char getShortcutKey()
Definition: tool.h:81
const QCursor & getCursor()
Get current cursor of this tool.
Definition: tool.h:186
QIcon icon_
Definition: tool.h:212
Configuration data storage class.
Definition: config.h:124
Pure-virtual base class for objects which give Display subclasses context in which to work...
description
virtual void setClassId(const QString &class_id)
Set the class identifier used to create this instance. Typically this will be set by the factory obje...
Definition: tool.h:154
QString description_
Definition: tool.h:220
QCursor cursor_
Definition: tool.h:214
const QIcon & getIcon()
Get the icon of this tool.
Definition: tool.h:177
DisplayContext * context_
Definition: tool.h:207
Property * property_container_
Definition: tool.h:218
QString getDescription() const
Set the description of the tool. This is called by ToolManager during tool initialization.
Definition: tool.h:138
bool access_all_keys_
Definition: tool.h:210
virtual void update(float wall_dt, float ros_dt)
Definition: tool.h:94
QString class_id_
Definition: tool.h:217
virtual int processKeyEvent(QKeyEvent *event, RenderPanel *panel)
Definition: tool.h:117
QString getName() const
Definition: tool.h:124


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