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 
40 class QMouseEvent;
41 class QKeyEvent;
42 
43 namespace Ogre
44 {
45 class SceneManager;
46 }
47 
48 namespace rviz
49 {
50 class DisplayContext;
51 class Property;
52 class RenderPanel;
53 class ViewportMouseEvent;
54 
55 class Tool : public QObject
56 {
57 Q_OBJECT
58 public:
67  Tool();
68  virtual ~Tool();
69 
72  void initialize( DisplayContext* context );
73 
75  virtual Property* getPropertyContainer() const { return property_container_; }
76 
77  char getShortcutKey() { return shortcut_key_; }
78 
79  bool accessAllKeys() { return access_all_keys_; }
80 
81  virtual void activate() = 0;
82  virtual void deactivate() = 0;
83 
84  virtual void update(float wall_dt, float ros_dt)
85  {
86  (void) wall_dt;
87  (void) ros_dt;
88  }
89 
90  enum {
91  Render = 1,
92  Finished = 2
93  };
94 
97  virtual int processMouseEvent( ViewportMouseEvent& event )
98  {
99  (void) event;
100  return 0;
101  }
102 
106  virtual int processKeyEvent( QKeyEvent* event, RenderPanel* panel )
107  {
108  (void) event;
109  (void) panel;
110  return 0;
111  }
112 
113  QString getName() const { return name_; }
114 
120  void setName( const QString& name );
121 
124  QString getDescription() const { return description_; }
125  void setDescription( const QString& description );
126 
130  virtual QString getClassId() const { return class_id_; }
131 
134  virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
135 
141  virtual void load( const Config& config );
142 
148  virtual void save( Config config ) const;
149 
151  void setIcon( const QIcon& icon );
152 
154  const QIcon& getIcon() { return icon_; }
155 
157  void setCursor( const QCursor& cursor );
158 
160  const QCursor& getCursor() { return cursor_; }
161 
162  void setStatus( const QString & message );
163 
164 Q_SIGNALS:
165  void close();
166 
167 protected:
172  virtual void onInitialize() {}
173 
174  Ogre::SceneManager* scene_manager_;
176 
179 
180  QIcon icon_;
181 
182  QCursor cursor_;
183 
184 private:
185  QString class_id_;
187  QString name_;
188  QString description_;
189 };
190 
191 }
192 
193 #endif
QString name_
Definition: tool.h:187
Ogre::SceneManager * scene_manager_
Definition: tool.h:174
virtual int processMouseEvent(ViewportMouseEvent &event)
Definition: tool.h:97
bool accessAllKeys()
Definition: tool.h:79
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 void onInitialize()
Definition: tool.h:172
char shortcut_key_
Definition: tool.h:177
char getShortcutKey()
Definition: tool.h:77
const QCursor & getCursor()
Get current cursor of this tool.
Definition: tool.h:160
QIcon icon_
Definition: tool.h:180
Configuration data storage class.
Definition: config.h:125
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:134
QString description_
Definition: tool.h:188
QString getDescription() const
Set the description of the tool. This is called by ToolManager during tool initialization.
Definition: tool.h:124
QCursor cursor_
Definition: tool.h:182
const QIcon & getIcon()
Get the icon of this tool.
Definition: tool.h:154
DisplayContext * context_
Definition: tool.h:175
QString getName() const
Definition: tool.h:113
Property * property_container_
Definition: tool.h:186
virtual Property * getPropertyContainer() const
Return the container for properties of this Tool.
Definition: tool.h:75
bool access_all_keys_
Definition: tool.h:178
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: tool.h:130
virtual void update(float wall_dt, float ros_dt)
Definition: tool.h:84
QString class_id_
Definition: tool.h:185
virtual int processKeyEvent(QKeyEvent *event, RenderPanel *panel)
Definition: tool.h:106


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