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 #ifndef MAPVIZ_MAPVIZ_H_
00031 #define MAPVIZ_MAPVIZ_H_
00032
00033
00034 #include <string>
00035 #include <vector>
00036 #include <map>
00037
00038 #include <boost/shared_ptr.hpp>
00039
00040
00041 #include <QtGui/QtGui>
00042 #include <QDialog>
00043 #include <QMenu>
00044 #include <QTimer>
00045 #include <QString>
00046 #include <QShowEvent>
00047 #include <QCloseEvent>
00048 #include <QListWidgetItem>
00049 #include <QModelIndex>
00050 #include <QColor>
00051 #include <QWidget>
00052 #include <QStringList>
00053 #include <QMainWindow>
00054
00055
00056 #include <ros/ros.h>
00057 #include <pluginlib/class_loader.h>
00058 #include <tf/transform_listener.h>
00059 #include <yaml-cpp/yaml.h>
00060 #include <std_srvs/Empty.h>
00061
00062
00063 #include "ui_mapviz.h"
00064 #include "ui_pluginselect.h"
00065
00066 #include <swri_transform_util/transform_manager.h>
00067 #include <mapviz/AddMapvizDisplay.h>
00068 #include <mapviz/mapviz_plugin.h>
00069 #include <mapviz/map_canvas.h>
00070 #include <mapviz/video_writer.h>
00071
00072 #include "stopwatch.h"
00073
00074 namespace mapviz
00075 {
00076 class Mapviz : public QMainWindow
00077 {
00078 Q_OBJECT
00079
00080 public:
00081 Mapviz(bool is_standalone, int argc, char** argv, QWidget *parent = 0, Qt::WFlags flags = 0);
00082 ~Mapviz();
00083
00084 void Initialize();
00085
00086 public Q_SLOTS:
00087 void AutoSave();
00088 void OpenConfig();
00089 void SaveConfig();
00090 void SelectNewDisplay();
00091 void RemoveDisplay();
00092 void RemoveDisplay(QListWidgetItem* item);
00093 void ReorderDisplays();
00094 void FixedFrameSelected(const QString& text);
00095 void TargetFrameSelected(const QString& text);
00096 void ToggleUseLatestTransforms(bool on);
00097 void UpdateFrames();
00098 void SpinOnce();
00099 void UpdateSizeHints();
00100 void ToggleConfigPanel(bool on);
00101 void ToggleStatusBar(bool on);
00102 void ToggleCaptureTools(bool on);
00103 void ToggleFixOrientation(bool on);
00104 void ToggleRotate90(bool on);
00105 void ToggleEnableAntialiasing(bool on);
00106 void ToggleShowPlugin(QListWidgetItem* item, bool visible);
00107 void ToggleRecord(bool on);
00108 void SetImageTransport(QAction* transport_action);
00109 void UpdateImageTransportMenu();
00110 void CaptureVideoFrame();
00111 void StopRecord();
00112 void Screenshot();
00113 void Force720p(bool on);
00114 void Force480p(bool on);
00115 void SetResizable(bool on);
00116 void SelectBackgroundColor(const QColor &color);
00117 void SetCaptureDirectory();
00118 void Hover(double x, double y, double scale);
00119 void Recenter();
00120 void HandleProfileTimer();
00121 void ClearHistory();
00122
00123 Q_SIGNALS:
00130 void FrameGrabbed(QImage);
00131 void ImageTransportChanged();
00132
00133 protected:
00134 Ui::mapviz ui_;
00135
00136 QMenu* image_transport_menu_;
00137
00138 QTimer frame_timer_;
00139 QTimer spin_timer_;
00140 QTimer save_timer_;
00141 QTimer record_timer_;
00142 QTimer profile_timer_;
00143
00144 QLabel* xy_pos_label_;
00145 QLabel* lat_lon_pos_label_;
00146
00147 QWidget* spacer1_;
00148 QWidget* spacer2_;
00149 QWidget* spacer3_;
00150 QPushButton* recenter_button_;
00151 QPushButton* rec_button_;
00152 QPushButton* stop_button_;
00153 QPushButton* screenshot_button_;
00154
00155 int argc_;
00156 char** argv_;
00157
00158 bool is_standalone_;
00159 bool initialized_;
00160 bool force_720p_;
00161 bool force_480p_;
00162 bool resizable_;
00163 QColor background_;
00164
00165 std::string capture_directory_;
00166 QThread video_thread_;
00167 VideoWriter* vid_writer_;
00168
00169 bool updating_frames_;
00170
00171 ros::NodeHandle* node_;
00172 ros::ServiceServer add_display_srv_;
00173 boost::shared_ptr<tf::TransformListener> tf_;
00174 swri_transform_util::TransformManager tf_manager_;
00175
00176 pluginlib::ClassLoader<MapvizPlugin>* loader_;
00177 MapCanvas* canvas_;
00178 std::map<QListWidgetItem*, MapvizPluginPtr> plugins_;
00179
00180 Stopwatch meas_spin_;
00181
00182 void Open(const std::string& filename);
00183 void Save(const std::string& filename);
00184
00185 MapvizPluginPtr CreateNewDisplay(
00186 const std::string& name,
00187 const std::string& type,
00188 bool visible,
00189 bool collapsed,
00190 int draw_order = 0);
00191
00192 bool AddDisplay(
00193 AddMapvizDisplay::Request& req,
00194 AddMapvizDisplay::Response& resp);
00195
00196 void ClearDisplays();
00197 void AdjustWindowSize();
00198
00199 virtual void showEvent(QShowEvent* event);
00200 virtual void closeEvent(QCloseEvent* event);
00201
00202 static const QString ROS_WORKSPACE_VAR;
00203 static const QString MAPVIZ_CONFIG_FILE;
00204 static const std::string IMAGE_TRANSPORT_PARAM;
00205 };
00206 }
00207
00208 #endif // MAPVIZ_MAPVIZ_H_