tool_manager.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 TOOL_MANAGER_H
30 #define TOOL_MANAGER_H
31 
32 #include <QList>
33 #include <QObject>
34 #include <QStringList>
35 
36 #include "rviz/pluginlib_factory.h"
37 #include "rviz/tool.h"
38 
39 class QKeyEvent;
40 
41 namespace rviz
42 {
43 class DisplayContext;
44 class PropertyTreeModel;
45 class RenderPanel;
46 
47 class ToolManager: public QObject
48 {
49 Q_OBJECT
50 public:
51  ToolManager( DisplayContext* context );
52  virtual ~ToolManager();
53 
56  void initialize();
57 
58  void load( const Config& config );
59  void save( Config config ) const;
61 
63  Tool* addTool( const QString& tool_class_lookup_name );
64 
70 
76  Tool* getTool( int index );
77 
78  int numTools() { return tools_.size(); }
79  void removeTool( int index );
80 
81  void removeAll();
82 
84  void refreshTool( Tool* tool );
85 
93  void setCurrentTool( Tool* tool );
94 
106  void setDefaultTool( Tool* tool );
107 
113 
114  QStringList getToolClasses();
115 
116  void handleChar( QKeyEvent* event, RenderPanel* panel );
117 
119 
120 Q_SIGNALS:
122  void configChanged();
123 
125  void toolAdded( Tool* );
126 
129  void toolChanged( Tool* );
130 
131  void toolRemoved( Tool* );
132 
134  void toolRefreshed( Tool* );
135 
136 private Q_SLOTS:
139  void updatePropertyVisibility( Property* property );
140 
142  void closeTool();
143 
144 private:
145 
146  bool toKey( QString const& str, uint& key_out );
149  QList<Tool*> tools_;
153  std::map<int,Tool*> shortkey_to_tool_map_;
154 
155 };
156 
157 } // end namespace rviz
158 
159 #endif // TOOL_MANAGER_H
void toolChanged(Tool *)
Emitted by setCurrentTool() after the newly chosen tool is activated.
PluginlibFactory< Tool > * factory_
Definition: tool_manager.h:147
virtual ~ToolManager()
void load(const Config &config)
void setDefaultTool(Tool *tool)
Set the default tool.
void removeTool(int index)
void toolRefreshed(Tool *)
Emitted by refreshTool() to gedraw the tool&#39;s icon in the toolbar&#39;.
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
config
Tool * getCurrentTool()
Return the tool currently in use.
Definition: tool_manager.h:69
Tool * getTool(int index)
Return the tool at a given index in the Tool list. If index is less than 0 or greater than the number...
ToolManager(DisplayContext *context)
void initialize()
Initialization for after the DisplayContext is created. Loads standard RViz tools.
void setCurrentTool(Tool *tool)
Set the current tool. The current tool is given all mouse and keyboard events which VisualizationMana...
Configuration data storage class.
Definition: config.h:125
void toolRemoved(Tool *)
void configChanged()
Emitted when anything changes which will change the saved config file contents.
void updatePropertyVisibility(Property *property)
If property has children, it is added to the tool property tree, and if it does not, it is removed.
Pure-virtual base class for objects which give Display subclasses context in which to work...
QStringList getToolClasses()
void toolAdded(Tool *)
Emitted by addTool() after the tool is added to the list of tools.
QList< Tool * > tools_
Definition: tool_manager.h:149
PropertyTreeModel * getPropertyModel() const
Definition: tool_manager.h:60
DisplayContext * context_
Definition: tool_manager.h:150
Tool * addTool(const QString &tool_class_lookup_name)
Create a tool by class lookup name, add it to the list, and return it.
PropertyTreeModel * property_tree_model_
Definition: tool_manager.h:148
std::map< int, Tool * > shortkey_to_tool_map_
Definition: tool_manager.h:153
bool toKey(QString const &str, uint &key_out)
void handleChar(QKeyEvent *event, RenderPanel *panel)
void save(Config config) const
void closeTool()
Deactivates the current tool and sets the default tool.
PluginlibFactory< Tool > * getFactory()
Definition: tool_manager.h:118
void refreshTool(Tool *tool)
Triggers redrawing the tool&#39;s icon/text in the toolbar.
Tool * getDefaultTool()
Get the default tool.
Definition: tool_manager.h:112


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