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 Tool::Tool() : property_container_(new Property())
42 {
43  access_all_keys_ = false;
44  shortcut_key_ = '\0';
45 }
46 
48 {
49  delete property_container_;
50 }
51 
53 {
54  context_ = context;
56 
57  // Let subclasses do initialization if they want.
58  onInitialize();
59 }
60 
61 void Tool::setIcon(const QIcon& icon)
62 {
63  icon_ = icon;
64  cursor_ = makeIconCursor(icon.pixmap(16), "tool_cursor:" + name_);
65 }
66 
67 void Tool::setCursor(const QCursor& cursor)
68 {
69  cursor_ = cursor;
70 }
71 
72 void Tool::setName(const QString& name)
73 {
74  // Early return if the name did not change
75  if (name == name_)
76  return;
77 
78  // Change the name and emit a signal to let slots know
79  name_ = name;
81  Q_EMIT nameChanged(name_);
82 }
83 
84 void Tool::setDescription(const QString& description)
85 {
88 }
89 
90 void Tool::load(const Config& config)
91 {
93 }
94 
95 void Tool::save(Config config) const
96 {
98  config.mapSetValue("Class", getClassId());
99 }
100 
101 void Tool::setStatus(const QString& message)
102 {
103  if (context_)
104  {
105  context_->setStatus(message);
106  }
107 }
108 
109 
110 } // end namespace rviz
window_manager_interface.h
rviz::Property::setName
virtual void setName(const QString &name)
Set the name.
Definition: property.cpp:155
rviz::Tool::load
virtual void load(const Config &config)
Load properties from the given Config.
Definition: tool.cpp:90
rviz::Tool::cursor_
QCursor cursor_
Definition: tool.h:214
rviz::Tool::scene_manager_
Ogre::SceneManager * scene_manager_
Definition: tool.h:206
property.h
description
description
rviz::Tool::context_
DisplayContext * context_
Definition: tool.h:207
rviz::Tool::setCursor
void setCursor(const QCursor &cursor)
Set the cursor for this tool.
Definition: tool.cpp:67
rviz::Tool::setStatus
void setStatus(const QString &message)
Definition: tool.cpp:101
rviz::makeIconCursor
QCursor makeIconCursor(const QString &url, bool fill_cache)
Definition: load_resource.cpp:101
rviz::DisplayContext::getSceneManager
virtual Ogre::SceneManager * getSceneManager() const =0
Returns the Ogre::SceneManager used for the main RenderPanel.
tool.h
rviz::Tool::property_container_
Property * property_container_
Definition: tool.h:218
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::Tool::setDescription
void setDescription(const QString &description)
Definition: tool.cpp:84
rviz::DisplayContext::setStatus
virtual void setStatus(const QString &message)=0
rviz::Tool::shortcut_key_
char shortcut_key_
Definition: tool.h:209
rviz
Definition: add_display_dialog.cpp:54
rviz::Tool::setIcon
void setIcon(const QIcon &icon)
Set the toolbar icon for this tool (will also set its cursor).
Definition: tool.cpp:61
rviz::Tool::nameChanged
void nameChanged(const QString &name)
rviz::Tool::name_
QString name_
Definition: tool.h:219
rviz::Tool::save
virtual void save(Config config) const
Save this entire tool into the given Config node.
Definition: tool.cpp:95
rviz::DisplayContext
Pure-virtual base class for objects which give Display subclasses context in which to work.
Definition: display_context.h:81
package.h
rviz::Property::setDescription
virtual void setDescription(const QString &description)
Set the description.
Definition: property.cpp:169
rviz::Tool::access_all_keys_
bool access_all_keys_
Definition: tool.h:210
rviz::Tool::getClassId
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: tool.h:147
rviz::Tool::setName
void setName(const QString &name)
Set the name of the tool.
Definition: tool.cpp:72
rviz::Tool::Tool
Tool()
Definition: tool.cpp:41
load_resource.h
rviz::Property::save
virtual void save(Config config) const
Write the value of this property and/or its children into the given Config reference.
Definition: property.cpp:495
rviz::Tool::~Tool
~Tool() override
Definition: tool.cpp:47
display_context.h
rviz::Tool::icon_
QIcon icon_
Definition: tool.h:212
rviz::Tool::onInitialize
virtual void onInitialize()
Definition: tool.h:202
rviz::Tool::initialize
void initialize(DisplayContext *context)
Definition: tool.cpp:52
rviz::Tool::description_
QString description_
Definition: tool.h:220
config
config
rviz::Property::load
virtual void load(const Config &config)
Load the value of this property and/or its children from the given Config reference.
Definition: property.cpp:445
rviz::Config
Configuration data storage class.
Definition: config.h:124


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Thu May 16 2024 02:30:49