Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #pragma once
00028 #ifndef BUT_DISTANCE_CIRCULAR_INDICATOR_H_
00029 #define BUT_DISTANCE_CIRCULAR_INDICATOR_H_
00030
00031 #include <rviz/display.h>
00032 #include <rviz/view_controller.h>
00033 #include "rviz/properties/forwards.h"
00034 #include "rviz/properties/property.h"
00035 #include "rviz/properties/edit_enum_property.h"
00036 #include "rviz/properties/property_manager.h"
00037 #include <rviz/visualization_manager.h>
00038 #include <rviz/frame_manager.h>
00039 #include "rviz/helpers/color.h"
00040 #include <rviz/render_panel.h>
00041 #include <rviz/window_manager_interface.h>
00042
00043 #include <OGRE/OgreSceneNode.h>
00044 #include <OGRE/OgreSceneManager.h>
00045 #include <OGRE/OgreManualObject.h>
00046 #include <OGRE/OgreMaterial.h>
00047 #include <OGRE/OgreMaterialManager.h>
00048 #include <ogre_tools/movable_text.h>
00049
00050 #include <math.h>
00051
00052 #include <srs_ui_but/but_ogre_tools/static_text.h>
00053
00054 namespace srs_ui_but
00055 {
00056
00062 class CButDistanceCircularIndicator : public rviz::Display
00063
00064 {
00065 public:
00069 CButDistanceCircularIndicator(const std::string & name, rviz::VisualizationManager * manager);
00070
00074 virtual ~CButDistanceCircularIndicator();
00075
00079 virtual void targetFrameChanged()
00080 {
00081 }
00085 virtual void fixedFrameChanged()
00086 {
00087 }
00088
00092 virtual void createProperties();
00093
00097 virtual void update(float wall_dt, float ros_dt);
00098
00099 protected:
00103 bool createGeometry();
00104
00108 void destroyGeometry();
00109
00113 virtual void onEnable();
00114
00118 virtual void onDisable();
00119
00124 const std::string getLinkString()
00125 {
00126 return robot_link_;
00127 }
00128
00133 Ogre::Vector3 getOrientation()
00134 {
00135 return orientation_;
00136 }
00137
00142 rviz::Color getColor()
00143 {
00144 return color_;
00145 }
00146
00151 float getAlpha()
00152 {
00153 return alpha_;
00154 }
00155
00160 float getThickness()
00161 {
00162 return thickness_;
00163 }
00164
00169 int getLevels()
00170 {
00171 return levels_;
00172 }
00173
00178 float getRadius()
00179 {
00180 return radius_;
00181 }
00182
00187 bool getShowDistance()
00188 {
00189 return show_distance_;
00190 }
00191
00196 void setLinkString(std::string link)
00197 {
00198 if (isEnabled())
00199 m_sceneNode_->setVisible(true);
00200 robot_link_ = link;
00201 propertyChanged(m_property_link_);
00202 }
00203
00208 void setOrientation(Ogre::Vector3 orientation)
00209 {
00210 orientation_ = orientation;
00211 propertyChanged(m_property_orientation_);
00212 }
00213
00218 void setColor(rviz::Color color)
00219 {
00220 color_ = color;
00221 material_->getTechnique(0)->setAmbient(color_.r_, color_.g_, color_.b_);
00222 propertyChanged(m_property_color_);
00223 }
00224
00229 void setAlpha(float alpha)
00230 {
00231 alpha_ = alpha;
00232
00233 material_->getTechnique(0)->setDiffuse(color_.r_, color_.g_, color_.b_, alpha_);
00234 propertyChanged(m_property_alpha_);
00235 }
00236
00241 void setThickness(float thickness)
00242 {
00243 thickness_ = thickness;
00244 propertyChanged(m_property_thickness_);
00245 }
00246
00251 void setShowDistance(bool show_distance)
00252 {
00253 show_distance_ = show_distance;
00254 propertyChanged(m_property_show_distance_);
00255 }
00256
00261 void setLevels(int levels)
00262 {
00263 if (levels < 1)
00264 levels_ = 1;
00265 else
00266 levels_ = levels;
00267 propertyChanged(m_property_levels_);
00268 }
00269
00274 void setRadius(float radius)
00275 {
00276 radius_ = radius;
00277 propertyChanged(m_property_radius_);
00278 }
00279
00280
00281 std::string robot_link_;
00282
00283
00284 Ogre::SceneNode * m_sceneNode_, *m_sceneNode_flipped_;
00285
00286
00287 Ogre::ManualObject * circle_manual_object_;
00288
00289
00290 Ogre::MaterialPtr material_;
00291
00292
00293 rviz::ColorPropertyWPtr m_property_color_;
00294 rviz::TFFramePropertyWPtr m_property_link_;
00295 rviz::FloatPropertyWPtr m_property_alpha_, m_property_thickness_, m_property_radius_;
00296 rviz::IntPropertyWPtr m_property_levels_;
00297 rviz::BoolPropertyWPtr m_property_show_distance_;
00298 rviz::Vector3PropertyWPtr m_property_orientation_;
00299
00300
00301 Ogre::Vector3 orientation_;
00302
00303
00304 float radius_, thickness_, accuracy_;
00305 unsigned int levels_;
00306
00307
00308 rviz::Color color_;
00309
00310
00311 float alpha_;
00312
00313 bool show_distance_;
00314
00315 };
00316
00317 }
00318
00319 #endif