but_context_manager.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * \file
00003  *
00004  * $Id:
00005  *
00006  * Copyright (C) Brno University of Technology
00007  *
00008  * This file is part of software developed by dcgm-robotics@FIT group.
00009  *
00010  * Author: Tomas Lokaj (xlokaj03@stud.fit.vutbr.cz)
00011  * Supervised by: Michal Spanel (spanel@fit.vutbr.cz)
00012  * Date: 07/02/2012
00013  * 
00014  * This file is free software: you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as published by
00016  * the Free Software Foundation, either version 3 of the License, or
00017  * (at your option) any later version.
00018  * 
00019  * This file is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU Lesser General Public License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this file.  If not, see <http://www.gnu.org/licenses/>.
00026  */
00027 
00028 #pragma once
00029 #ifndef BUT_CONTEXT_MANAGER_H_
00030 #define BUT_CONTEXT_MANAGER_H_
00031 
00032 #include <ros/ros.h>
00033 #include <ros/node_handle.h>
00034 
00035 #include <rviz/display.h>
00036 #include <rviz/view_controller.h>
00037 #include "rviz/properties/forwards.h"
00038 #include "rviz/properties/property.h"
00039 #include "rviz/properties/edit_enum_property.h"
00040 #include "rviz/properties/property_manager.h"
00041 #include <rviz/visualization_manager.h>
00042 #include <rviz/frame_manager.h>
00043 #include "rviz/helpers/color.h"
00044 #include <rviz/render_panel.h>
00045 #include <rviz/window_manager_interface.h>
00046 
00047 #include <OGRE/OgreSceneNode.h>
00048 #include <OGRE/OgreSceneManager.h>
00049 #include <OGRE/OgreManualObject.h>
00050 #include <OGRE/OgreMaterial.h>
00051 #include <OGRE/OgreMaterialManager.h>
00052 #include <ogre_tools/movable_text.h>
00053 #include <srs_ui_but/but_ogre_tools/text_output.h>
00054 
00055 #include <srs_env_model/Context.h>
00056 #include <srs_env_model/ContextChanged.h>
00057 #include <srs_env_model/GetContext.h>
00058 #include <srs_env_model/SetContext.h>
00059 
00060 #include <srs_ui_but/topics_list.h>
00061 #include <srs_env_model/services_list.h>
00062 #include <srs_env_model/topics_list.h>
00063 
00064 #define ID_MESSAGE_RENDERER "txtMessageRenderer"
00065 
00066 namespace srs_ui_but
00067 {
00073 class CButContextManager : public rviz::Display
00074 
00075 {
00076 public:
00080   CButContextManager(const std::string & name, rviz::VisualizationManager * manager);
00081 
00085   virtual ~CButContextManager();
00086 
00090   virtual void targetFrameChanged()
00091   {
00092   }
00096   virtual void fixedFrameChanged()
00097   {
00098   }
00099 
00103   virtual void createProperties();
00104 
00108   virtual void update(float wall_dt, float ros_dt);
00109 
00110 protected:
00115   bool checkContextServer();
00116 
00121   int getContextStatus()
00122   {
00123     return context_.status_tag;
00124   }
00125 
00130   void setContextStatus(int status)
00131   {
00132     context_.status_tag = status;
00133     setContext();
00134     propertyChanged(m_property_status_);
00135   }
00136 
00141   int getContextAction()
00142   {
00143     return context_.action_tag;
00144   }
00145 
00150   void setContextAction(int action)
00151   {
00152     context_.action_tag = action;
00153     setContext();
00154     propertyChanged(m_property_action_);
00155   }
00156 
00161   int getContextConnection()
00162   {
00163     return context_.connection_tag;
00164   }
00165 
00170   void setContextConnection(int connection)
00171   {
00172     context_.connection_tag = connection;
00173     setContext();
00174     propertyChanged(m_property_connection_);
00175   }
00176 
00181   int getContextCollisionHazard()
00182   {
00183     return context_.collision_hazard_tag;
00184   }
00185 
00190   void setContextCollisionHazard(int collision_hazard)
00191   {
00192     context_.collision_hazard_tag = collision_hazard;
00193     setContext();
00194     propertyChanged(m_property_connection_);
00195   }
00196 
00200   void setContext()
00201   {
00202     if (enabled_ && checkContextServer())
00203     {
00204       srs_env_model::SetContext context;
00205       context.request.context = context_;
00206       set_context_client_.call(context);
00207     }
00208   }
00209 
00213   void getContext()
00214   {
00215     srs_env_model::GetContext context;
00216     if (enabled_ && get_context_client_.call(context))
00217     {
00218       context_ = context.response.context;
00219       propertyChanged(m_property_status_);
00220       propertyChanged(m_property_action_);
00221       propertyChanged(m_property_connection_);
00222       propertyChanged(m_property_collision_hazard_);
00223     }
00224   }
00225 
00230   void contextChangedCallback(const srs_env_model::ContextChangedConstPtr &update)
00231   {
00232     context_ = update->context;
00233     propertyChanged(m_property_status_);
00234     propertyChanged(m_property_action_);
00235     propertyChanged(m_property_connection_);
00236     propertyChanged(m_property_collision_hazard_);
00237   }
00238 
00242   virtual void onEnable();
00243 
00247   virtual void onDisable();
00248 
00249   // Display properties
00250   rviz::EnumPropertyWPtr m_property_status_, m_property_action_, m_property_connection_, m_property_collision_hazard_;
00251 
00252   // Properties
00253   srs_env_model::Context context_;
00254 
00255   // Context changed subscriber
00256   ros::Subscriber sub_;
00257 
00258   // Service clients
00259   ros::ServiceClient get_context_client_, set_context_client_;
00260 
00261   // Context server properties
00262   bool context_server_enabled_;
00263 
00264   // Message renderer
00265   ogre_tools::TextOutput* message_renderer_;
00266 };
00267 
00268 } // namespace srs_ui_but
00269 
00270 #endif /* BUT_CONTEXT_MANAGER_H_ */
00271 


srs_ui_but
Author(s): Vit Stancl (stancl@fit.vutbr.cz), Michal Spanel (spanel@fit.vutbr.cz), Tomas Lokaj
autogenerated on Mon Oct 6 2014 08:49:29