00001 /* 00002 * Copyright (c) 2012, Willow Garage, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of the Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 #ifndef DISPLAY_H 00030 #define DISPLAY_H 00031 00032 #include <string> 00033 00034 #include <ros/ros.h> 00035 00036 #include "rviz/properties/status_property.h" 00037 #include "rviz/properties/property.h" 00038 00039 namespace Ogre 00040 { 00041 class SceneManager; 00042 } 00043 00044 namespace rviz 00045 { 00046 00047 class StatusList; 00048 class DisplayContext; 00049 00050 class Display: public Property 00051 { 00052 Q_OBJECT 00053 public: 00054 Display(); 00055 00057 void initialize( DisplayContext* context ); 00058 00062 virtual QVariant getViewData( int column, int role ) const; 00063 00066 virtual Qt::ItemFlags getViewFlags( int column ) const; 00067 00071 virtual QString getClassId() const { return class_id_; } 00072 00075 virtual void setClassId( const QString& class_id ) { class_id_ = class_id; } 00076 00084 virtual void load( const YAML::Node& yaml_node ); 00085 00091 virtual void loadChildren( const YAML::Node& yaml_node ); 00092 00097 virtual void save( YAML::Emitter& emitter ); 00098 00101 virtual void saveChildren( YAML::Emitter& emitter ); 00102 00104 bool isEnabled() const; 00105 00107 void setFixedFrame( const QString& fixed_frame ); 00108 00112 virtual void update( float wall_dt, float ros_dt ) {} 00113 00115 virtual void reset(); 00116 00129 virtual void setStatus( StatusProperty::Level level, const QString& name, const QString& text ); 00130 00134 void setStatusStd( StatusProperty::Level level, const std::string& name, const std::string& text ) 00135 { 00136 setStatus( level, QString::fromStdString( name ), QString::fromStdString( text )); 00137 } 00138 00140 virtual void deleteStatus( const QString& name ); 00141 00143 void deleteStatusStd( const std::string& name ) { deleteStatus( QString::fromStdString( name )); } 00144 00145 public Q_SLOTS: 00150 void setEnabled( bool enabled ); 00151 00152 protected: 00159 virtual void onInitialize() {} 00160 00162 virtual void onEnable() {} 00163 00165 virtual void onDisable() {} 00166 00170 virtual void clearStatuses(); 00171 00173 virtual void fixedFrameChanged() {} 00174 00182 DisplayContext* context_; 00183 00187 Ogre::SceneManager* scene_manager_; 00188 00192 ros::NodeHandle update_nh_; 00193 00197 ros::NodeHandle threaded_nh_; 00198 00204 QString fixed_frame_; 00205 00206 private Q_SLOTS: 00207 void onEnableChanged(); 00208 00209 private: 00210 StatusList* status_; 00211 QString class_id_; 00212 bool initialized_; 00213 }; 00214 00215 } // end namespace rviz 00216 00217 #endif // DISPLAY_H