$search
00001 /* 00002 * Copyright (c) 2008, 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 00030 #ifndef RVIZ_DISPLAY_H 00031 #define RVIZ_DISPLAY_H 00032 00033 #include "properties/forwards.h" 00034 #include "status_level.h" 00035 00036 #include <string> 00037 #include <boost/function.hpp> 00038 #include <boost/signals.hpp> 00039 00040 #include <ros/ros.h> 00041 00042 namespace Ogre 00043 { 00044 class SceneManager; 00045 class MovableObject; 00046 } 00047 00048 class wxPanel; 00049 class wxWindow; 00050 class wxPropertyGrid; 00051 class wxPropertyGridEvent; 00052 class wxPGProperty; 00053 class wxConfigBase; 00054 00055 namespace rviz 00056 { 00057 00058 class PropertyManager; 00059 class CategoryProperty; 00060 class BoolProperty; 00061 00062 class VisualizationManager; 00063 00064 class Display; 00065 typedef boost::signal<void(Display*)> DisplaySignal; 00066 00074 class Display 00075 { 00076 public: 00077 Display( const std::string& name, VisualizationManager* manager ); 00078 virtual ~Display(); 00079 00084 void enable( bool force = false ); 00089 void disable( bool force = false ); 00090 00091 bool isEnabled() { return enabled_; } 00092 void setEnabled(bool enable, bool force = false); 00093 00094 const std::string& getName() const { return name_; } 00095 void setName(const std::string& name); 00096 00101 virtual void update( float wall_dt, float ros_dt ) {} 00102 00104 00108 void setRenderCallback( boost::function<void ()> func ); 00109 00111 void setLockRenderCallback( boost::function<void ()> func ); 00113 void setUnlockRenderCallback( boost::function<void ()> func ); 00114 00120 void setPropertyManager( PropertyManager* manager, const CategoryPropertyWPtr& parent ); 00121 00127 virtual void createProperties() {} 00128 00130 void setTargetFrame( const std::string& frame ); 00131 00135 virtual void targetFrameChanged() = 0; 00136 00141 void setFixedFrame( const std::string& frame ); 00142 00146 virtual void fixedFrameChanged() = 0; 00147 00151 virtual void reset(); 00152 00153 DisplaySignal& getStateChangedSignal() { return state_changed_; } 00154 00155 void setStatus(StatusLevel level, const std::string& name, const std::string& text); 00156 void deleteStatus(const std::string& name); 00157 void clearStatuses(); 00158 StatusLevel getStatus(); 00159 00160 protected: 00162 virtual void onEnable() = 0; 00164 virtual void onDisable() = 0; 00165 00167 00171 void causeRender(); 00172 00174 void lockRender(); 00176 void unlockRender(); 00177 00178 VisualizationManager* vis_manager_; 00179 00180 Ogre::SceneManager* scene_manager_; 00181 std::string name_; 00182 bool enabled_; 00183 StatusLevel status_; 00184 00185 ros::NodeHandle update_nh_; 00186 ros::NodeHandle threaded_nh_; 00187 00188 std::string target_frame_; 00189 std::string fixed_frame_; 00190 00191 boost::function<void ()> render_callback_; 00192 boost::function<void ()> render_lock_; 00193 boost::function<void ()> render_unlock_; 00194 00195 std::string property_prefix_; 00196 00197 PropertyManager* property_manager_; 00198 CategoryPropertyWPtr parent_category_; 00199 StatusPropertyWPtr status_property_; 00200 00201 DisplaySignal state_changed_; 00202 00203 friend class RenderAutoLock; 00204 }; 00205 00213 class RenderAutoLock 00214 { 00215 public: 00216 RenderAutoLock( Display* display ) 00217 : display_( display ) 00218 { 00219 display_->lockRender(); 00220 } 00221 00222 ~RenderAutoLock() 00223 { 00224 display_->unlockRender(); 00225 } 00226 00227 private: 00228 Display* display_; 00229 }; 00230 00231 } // namespace rviz 00232 00233 #endif