robot_image_plugin.h
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
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 Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from 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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //
00028 // *****************************************************************************
00029 
00030 #ifndef MAPVIZ_PLUGINS_ROBOT_IMAGE_PLUGIN_H_
00031 #define MAPVIZ_PLUGINS_ROBOT_IMAGE_PLUGIN_H_
00032 
00033 // C++ standard libraries
00034 #include <string>
00035 
00036 #include <mapviz/mapviz_plugin.h>
00037 
00038 // QT libraries
00039 #include <QGLWidget>
00040 #include <QObject>
00041 #include <QWidget>
00042 
00043 // ROS libraries
00044 #include <ros/ros.h>
00045 #include <tf/transform_datatypes.h>
00046 
00047 #include <mapviz/map_canvas.h>
00048 
00049 // QT autogenerated files
00050 #include "ui_robot_image_config.h"
00051 #include "ui_topic_select.h"
00052 
00053 namespace mapviz_plugins
00054 {
00055   class RobotImagePlugin : public mapviz::MapvizPlugin
00056   {
00057     Q_OBJECT
00058 
00059   public:
00060     RobotImagePlugin();
00061     virtual ~RobotImagePlugin();
00062 
00063     bool Initialize(QGLWidget* canvas);
00064     void Shutdown() {}
00065 
00066     void Draw(double x, double y, double scale);
00067 
00068     void Transform();
00069 
00070     void LoadConfig(const YAML::Node& node, const std::string& path);
00071     void SaveConfig(YAML::Emitter& emitter, const std::string& path);
00072 
00073     QWidget* GetConfigWidget(QWidget* parent);
00074 
00075   protected:
00076     void PrintError(const std::string& message);
00077     void PrintInfo(const std::string& message);
00078     void PrintWarning(const std::string& message);
00079 
00080   protected Q_SLOTS:
00081     void SelectFile();
00082     void SelectFrame();
00083     void FrameEdited();
00084     void WidthChanged(double value);
00085     void HeightChanged(double value);
00086 
00087   private:
00088     Ui::robot_image_config ui_;
00089     QWidget* config_widget_;
00090 
00091     double width_;
00092     double height_;
00093 
00094     std::string filename_;
00095     QImage      image_;
00096     int dimension_;
00097     int texture_id_;
00098     bool texture_loaded_;
00099 
00100     bool transformed_;
00101 
00102     tf::Point top_left_;
00103     tf::Point top_right_;
00104     tf::Point bottom_left_;
00105     tf::Point bottom_right_;
00106 
00107     tf::Point top_left_transformed_;
00108     tf::Point top_right_transformed_;
00109     tf::Point bottom_left_transformed_;
00110     tf::Point bottom_right_transformed_;
00111 
00112     void UpdateShape();
00113     void LoadImage();
00114   };
00115 }
00116 
00117 #endif  // MAPVIZ_PLUGINS_ROBOT_IMAGE_PLUGIN_H_


mapviz_plugins
Author(s): Marc Alban
autogenerated on Thu Aug 24 2017 02:46:09