mapviz.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef MAPVIZ_MAPVIZ_H_
31 #define MAPVIZ_MAPVIZ_H_
32 
33 // C++ standard libraries
34 #include <string>
35 #include <vector>
36 #include <map>
37 
38 #include <boost/shared_ptr.hpp>
39 
40 // QT libraries
41 #include <QtGui/QtGui>
42 #include <QDialog>
43 #include <QMenu>
44 #include <QTimer>
45 #include <QString>
46 #include <QShowEvent>
47 #include <QCloseEvent>
48 #include <QListWidgetItem>
49 #include <QModelIndex>
50 #include <QColor>
51 #include <QWidget>
52 #include <QStringList>
53 #include <QMainWindow>
54 
55 // ROS libraries
56 #include <ros/ros.h>
57 #include <pluginlib/class_loader.h>
58 #include <tf/transform_listener.h>
59 #include <yaml-cpp/yaml.h>
60 #include <std_srvs/Empty.h>
61 
62 // Auto-generated UI files
63 #include "ui_mapviz.h"
64 #include "ui_pluginselect.h"
65 
67 #include <mapviz/AddMapvizDisplay.h>
68 #include <mapviz/mapviz_plugin.h>
69 #include <mapviz/map_canvas.h>
70 #include <mapviz/video_writer.h>
71 
72 #include "stopwatch.h"
73 
74 namespace mapviz
75 {
76  class Mapviz : public QMainWindow
77  {
78  Q_OBJECT
79 
80  public:
81  Mapviz(bool is_standalone, int argc, char** argv, QWidget *parent = 0, Qt::WindowFlags flags = 0);
82  ~Mapviz();
83 
84  void Initialize();
85 
86  public Q_SLOTS:
87  void AutoSave();
88  void OpenConfig();
89  void SaveConfig();
90  void SelectNewDisplay();
91  void RemoveDisplay();
92  void RemoveDisplay(QListWidgetItem* item);
93  void ReorderDisplays();
94  void FixedFrameSelected(const QString& text);
95  void TargetFrameSelected(const QString& text);
96  void ToggleUseLatestTransforms(bool on);
97  void UpdateFrames();
98  void SpinOnce();
99  void UpdateSizeHints();
100  void ToggleConfigPanel(bool on);
101  void ToggleStatusBar(bool on);
102  void ToggleCaptureTools(bool on);
103  void ToggleFixOrientation(bool on);
104  void ToggleRotate90(bool on);
105  void ToggleEnableAntialiasing(bool on);
106  void ToggleShowPlugin(QListWidgetItem* item, bool visible);
107  void ToggleRecord(bool on);
108  void SetImageTransport(QAction* transport_action);
110  void CaptureVideoFrame();
111  void StopRecord();
112  void Screenshot();
113  void Force720p(bool on);
114  void Force480p(bool on);
115  void SetResizable(bool on);
116  void SelectBackgroundColor(const QColor &color);
117  void SetCaptureDirectory();
118  void Hover(double x, double y, double scale);
119  void Recenter();
120  void HandleProfileTimer();
121  void ClearHistory();
122 
123  Q_SIGNALS:
130  void FrameGrabbed(QImage);
131  void ImageTransportChanged();
132 
133  protected:
134  Ui::mapviz ui_;
135 
137 
138  QTimer frame_timer_;
139  QTimer spin_timer_;
140  QTimer save_timer_;
143 
144  QLabel* xy_pos_label_;
146 
147  QWidget* spacer1_;
148  QWidget* spacer2_;
149  QWidget* spacer3_;
150  QPushButton* recenter_button_;
151  QPushButton* rec_button_;
152  QPushButton* stop_button_;
153  QPushButton* screenshot_button_;
154 
155  int argc_;
156  char** argv_;
157 
163  QColor background_;
164 
165  std::string capture_directory_;
166  QThread video_thread_;
168 
170 
175 
178  std::map<QListWidgetItem*, MapvizPluginPtr> plugins_;
179 
181 
182  void Open(const std::string& filename);
183  void Save(const std::string& filename);
184 
186  const std::string& name,
187  const std::string& type,
188  bool visible,
189  bool collapsed,
190  int draw_order = 0);
191 
192  bool AddDisplay(
193  AddMapvizDisplay::Request& req,
194  AddMapvizDisplay::Response& resp);
195 
196  void ClearDisplays();
197  void AdjustWindowSize();
198 
199  virtual void showEvent(QShowEvent* event);
200  virtual void closeEvent(QCloseEvent* event);
201 
202  static const QString ROS_WORKSPACE_VAR;
203  static const QString MAPVIZ_CONFIG_FILE;
204  static const std::string IMAGE_TRANSPORT_PARAM;
205  };
206 }
207 
208 #endif // MAPVIZ_MAPVIZ_H_
VideoWriter * vid_writer_
Definition: mapviz.h:167
void ToggleShowPlugin(QListWidgetItem *item, bool visible)
Definition: mapviz.cpp:1203
bool force_480p_
Definition: mapviz.h:161
void FixedFrameSelected(const QString &text)
Definition: mapviz.cpp:1214
void AdjustWindowSize()
Definition: mapviz.cpp:468
void SpinOnce()
Definition: mapviz.cpp:328
QColor background_
Definition: mapviz.h:163
void FrameGrabbed(QImage)
MapCanvas * canvas_
Definition: mapviz.h:177
void OpenConfig()
Definition: mapviz.cpp:863
bool initialized_
Definition: mapviz.h:159
void HandleProfileTimer()
Definition: mapviz.cpp:1516
QPushButton * stop_button_
Definition: mapviz.h:152
void ToggleUseLatestTransforms(bool on)
Definition: mapviz.cpp:1239
bool resizable_
Definition: mapviz.h:162
QLabel * xy_pos_label_
Definition: mapviz.h:144
void UpdateSizeHints()
Definition: mapviz.cpp:1438
void Recenter()
Definition: mapviz.cpp:1386
QWidget * spacer1_
Definition: mapviz.h:147
QTimer save_timer_
Definition: mapviz.h:140
void CaptureVideoFrame()
Definition: mapviz.cpp:1367
QPushButton * recenter_button_
Definition: mapviz.h:150
void ToggleRecord(bool on)
Definition: mapviz.cpp:1295
void ToggleCaptureTools(bool on)
Definition: mapviz.cpp:1280
void StopRecord()
Definition: mapviz.cpp:1391
void ClearDisplays()
Definition: mapviz.cpp:1472
TFSIMD_FORCE_INLINE const tfScalar & y() const
QWidget * spacer2_
Definition: mapviz.h:148
void UpdateImageTransportMenu()
Definition: mapviz.cpp:1348
virtual void closeEvent(QCloseEvent *event)
Definition: mapviz.cpp:210
pluginlib::ClassLoader< MapvizPlugin > * loader_
Definition: mapviz.h:176
void ToggleEnableAntialiasing(bool on)
Definition: mapviz.cpp:1254
void Force480p(bool on)
Definition: mapviz.cpp:436
Stopwatch meas_spin_
Definition: mapviz.h:180
MapvizPluginPtr CreateNewDisplay(const std::string &name, const std::string &type, bool visible, bool collapsed, int draw_order=0)
Definition: mapviz.cpp:1106
virtual void showEvent(QShowEvent *event)
Definition: mapviz.cpp:205
std::map< QListWidgetItem *, MapvizPluginPtr > plugins_
Definition: mapviz.h:178
void ToggleRotate90(bool on)
Definition: mapviz.cpp:1249
ros::ServiceServer add_display_srv_
Definition: mapviz.h:172
void ImageTransportChanged()
void SetResizable(bool on)
Definition: mapviz.cpp:452
void Force720p(bool on)
Definition: mapviz.cpp:420
QTimer spin_timer_
Definition: mapviz.h:139
bool is_standalone_
Definition: mapviz.h:158
void Save(const std::string &filename)
Definition: mapviz.cpp:752
void ToggleConfigPanel(bool on)
Definition: mapviz.cpp:1259
void Screenshot()
Definition: mapviz.cpp:1409
QTimer profile_timer_
Definition: mapviz.h:142
char ** argv_
Definition: mapviz.h:156
QWidget * spacer3_
Definition: mapviz.h:149
void ReorderDisplays()
Definition: mapviz.cpp:1487
TFSIMD_FORCE_INLINE const tfScalar & x() const
void SaveConfig()
Definition: mapviz.cpp:878
void ClearHistory()
Definition: mapviz.cpp:911
void SelectNewDisplay()
Definition: mapviz.cpp:919
static const std::string IMAGE_TRANSPORT_PARAM
Definition: mapviz.h:204
boost::shared_ptr< tf::TransformListener > tf_
Definition: mapviz.h:173
void TargetFrameSelected(const QString &text)
Definition: mapviz.cpp:1226
void Initialize()
Definition: mapviz.cpp:223
std::string capture_directory_
Definition: mapviz.h:165
void ToggleFixOrientation(bool on)
Definition: mapviz.cpp:1244
Mapviz(bool is_standalone, int argc, char **argv, QWidget *parent=0, Qt::WindowFlags flags=0)
Definition: mapviz.cpp:80
QLabel * lat_lon_pos_label_
Definition: mapviz.h:145
Ui::mapviz ui_
Definition: mapviz.h:134
void SelectBackgroundColor(const QColor &color)
Definition: mapviz.cpp:1497
void Open(const std::string &filename)
Definition: mapviz.cpp:513
static const QString MAPVIZ_CONFIG_FILE
Definition: mapviz.h:203
static const QString ROS_WORKSPACE_VAR
Definition: mapviz.h:202
QTimer frame_timer_
Definition: mapviz.h:138
QPushButton * rec_button_
Definition: mapviz.h:151
QThread video_thread_
Definition: mapviz.h:166
bool AddDisplay(AddMapvizDisplay::Request &req, AddMapvizDisplay::Response &resp)
Definition: mapviz.cpp:958
ros::NodeHandle * node_
Definition: mapviz.h:171
void SetCaptureDirectory()
Definition: mapviz.cpp:1503
void Hover(double x, double y, double scale)
Definition: mapviz.cpp:1027
QTimer record_timer_
Definition: mapviz.h:141
bool updating_frames_
Definition: mapviz.h:169
void SetImageTransport(QAction *transport_action)
Definition: mapviz.cpp:1339
swri_transform_util::TransformManager tf_manager_
Definition: mapviz.h:174
void RemoveDisplay()
Definition: mapviz.cpp:1453
void UpdateFrames()
Definition: mapviz.cpp:342
void AutoSave()
Definition: mapviz.cpp:829
QPushButton * screenshot_button_
Definition: mapviz.h:153
void ToggleStatusBar(bool on)
Definition: mapviz.cpp:1273
bool force_720p_
Definition: mapviz.h:160
QMenu * image_transport_menu_
Definition: mapviz.h:136


mapviz
Author(s): Marc Alban
autogenerated on Thu Jun 6 2019 19:25:08