tool.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 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 #include <ros/package.h>
31 
32 #include "rviz/display_context.h"
34 #include "rviz/load_resource.h"
36 
37 #include "rviz/tool.h"
38 
39 namespace rviz
40 {
41 
43  : property_container_( new Property() )
44 {
45  access_all_keys_ = false;
46  shortcut_key_ = '\0';
47 }
48 
50 {
51  delete property_container_;
52 }
53 
55 {
56  context_ = context;
58 
59  // Let subclasses do initialization if they want.
60  onInitialize();
61 }
62 
63 void Tool::setIcon( const QIcon& icon )
64 {
65  icon_=icon;
66  cursor_=makeIconCursor( icon.pixmap(16), "tool_cursor:"+name_ );
67 }
68 
69 void Tool::setCursor( const QCursor& cursor )
70 {
71  cursor_=cursor;
72 }
73 
74 void Tool::setName( const QString& name )
75 {
76  name_ = name;
78 }
79 
80 void Tool::setDescription( const QString& description )
81 {
82  description_ = description;
84 }
85 
86 void Tool::load( const Config& config )
87 {
88  property_container_->load( config );
89 }
90 
91 void Tool::save( Config config ) const
92 {
93  property_container_->save( config );
94  config.mapSetValue( "Class", getClassId() );
95 }
96 
97 void Tool::setStatus( const QString & message )
98 {
99  if ( context_ )
100  {
101  context_->setStatus( message );
102  }
103 }
104 
105 
106 } // end namespace rviz
virtual void setStatus(const QString &message)=0
QString name_
Definition: tool.h:187
Ogre::SceneManager * scene_manager_
Definition: tool.h:174
QCursor makeIconCursor(QString url, bool fill_cache)
virtual void load(const Config &config)
Load the value of this property and/or its children from the given Config reference.
Definition: property.cpp:426
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
virtual void onInitialize()
Definition: tool.h:172
char shortcut_key_
Definition: tool.h:177
virtual void setDescription(const QString &description)
Set the description.
Definition: property.cpp:164
QIcon icon_
Definition: tool.h:180
void mapSetValue(const QString &key, QVariant value)
Set a named child to the given value.
Definition: config.cpp:185
Configuration data storage class.
Definition: config.h:125
Pure-virtual base class for objects which give Display subclasses context in which to work...
virtual void save(Config config) const
Write the value of this property and/or its children into the given Config reference.
Definition: property.cpp:467
virtual void save(Config config) const
Save this entire tool into the given Config node.
Definition: tool.cpp:91
virtual void load(const Config &config)
Load properties from the given Config.
Definition: tool.cpp:86
void setName(const QString &name)
Set the name of the tool.
Definition: tool.cpp:74
Tool()
Definition: tool.cpp:42
void initialize(DisplayContext *context)
Definition: tool.cpp:54
QString description_
Definition: tool.h:188
virtual Ogre::SceneManager * getSceneManager() const =0
Returns the Ogre::SceneManager used for the main RenderPanel.
QCursor cursor_
Definition: tool.h:182
DisplayContext * context_
Definition: tool.h:175
void setIcon(const QIcon &icon)
Set the toolbar icon for this tool (will also set its cursor).
Definition: tool.cpp:63
void setStatus(const QString &message)
Definition: tool.cpp:97
void setCursor(const QCursor &cursor)
Set the cursor for this tool.
Definition: tool.cpp:69
Property * property_container_
Definition: tool.h:186
virtual ~Tool()
Definition: tool.cpp:49
void setDescription(const QString &description)
Definition: tool.cpp:80
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


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat Apr 27 2019 02:33:42