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
00028
00029
00030 #include "marker_selection_handler.h"
00031 #include "marker_base.h"
00032 #include "rviz/default_plugin/marker_display.h"
00033 #include "rviz/properties/property_manager.h"
00034 #include "rviz/properties/property.h"
00035 #include "rviz/default_plugin/interactive_markers/interactive_marker_control.h"
00036
00037
00038 #include <OGRE/OgreVector3.h>
00039 #include <OGRE/OgreQuaternion.h>
00040
00041 #include <boost/bind.hpp>
00042
00043 namespace rviz
00044 {
00045
00046 MarkerSelectionHandler::MarkerSelectionHandler(const MarkerBase* marker, MarkerID id)
00047 : marker_(marker)
00048 , id_(id)
00049 , control_(0)
00050 {
00051 }
00052
00053 MarkerSelectionHandler::~MarkerSelectionHandler()
00054 {
00055 }
00056
00057 Ogre::Vector3 MarkerSelectionHandler::getPosition()
00058 {
00059 return Ogre::Vector3(marker_->getMessage()->pose.position.x, marker_->getMessage()->pose.position.y, marker_->getMessage()->pose.position.z);
00060 }
00061
00062 Ogre::Quaternion MarkerSelectionHandler::getOrientation()
00063 {
00064 return Ogre::Quaternion(marker_->getMessage()->pose.orientation.w, marker_->getMessage()->pose.orientation.x, marker_->getMessage()->pose.orientation.y, marker_->getMessage()->pose.orientation.z);
00065 }
00066
00067 void MarkerSelectionHandler::createProperties(const Picked& obj, PropertyManager* property_manager)
00068 {
00069 std::stringstream prefix;
00070 prefix << "Marker " << id_.first << "/" << id_.second;
00071 CategoryPropertyWPtr cat = property_manager->createCategory(prefix.str(), prefix.str());
00072 properties_.push_back(property_manager->createProperty<StringProperty>("ID", prefix.str(), boost::bind(&MarkerSelectionHandler::getId, this), StringProperty::Setter(), cat));
00073 properties_.push_back(property_manager->createProperty<Vector3Property>("Position", prefix.str(), boost::bind(&MarkerSelectionHandler::getPosition, this), Vector3Property::Setter(), cat));
00074 properties_.push_back(property_manager->createProperty<QuaternionProperty>("Orientation", prefix.str(), boost::bind(&MarkerSelectionHandler::getOrientation, this), QuaternionProperty::Setter(), cat));
00075 properties_.push_back(cat);
00076 }
00077
00078 void MarkerSelectionHandler::setControl( InteractiveMarkerControl* control )
00079 {
00080 control_ = control;
00081 }
00082
00083
00084 bool MarkerSelectionHandler::isInteractive()
00085 {
00086 return control_ && control_->isInteractive();
00087 }
00088
00089 void MarkerSelectionHandler::enableInteraction(bool enable)
00090 {
00091 if ( control_ ) control_->enableInteraction(enable);
00092 }
00093
00094 void MarkerSelectionHandler::handleMouseEvent(const Picked& obj, ViewportMouseEvent& event)
00095 {
00096 if ( control_ ) control_->handleMouseEvent(event);
00097 }
00098
00099 }