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 SaveConfigAs();
91  void ClearConfig();
92  void SelectNewDisplay();
93  void RemoveDisplay();
94  void RemoveDisplay(QListWidgetItem* item);
95  void ReorderDisplays();
96  void FixedFrameSelected(const QString& text);
97  void TargetFrameSelected(const QString& text);
98  void ToggleUseLatestTransforms(bool on);
99  void UpdateFrames();
100  void SpinOnce();
101  void UpdateSizeHints();
102  void ToggleConfigPanel(bool on);
103  void ToggleStatusBar(bool on);
104  void ToggleCaptureTools(bool on);
105  void ToggleFixOrientation(bool on);
106  void ToggleRotate90(bool on);
107  void ToggleEnableAntialiasing(bool on);
108  void ToggleShowPlugin(QListWidgetItem* item, bool visible);
109  void ToggleRecord(bool on);
110  void SetImageTransport(QAction* transport_action);
112  void CaptureVideoFrame();
113  void StopRecord();
114  void Screenshot();
115  void Force720p(bool on);
116  void Force480p(bool on);
117  void SetResizable(bool on);
118  void SelectBackgroundColor(const QColor &color);
119  void SetCaptureDirectory();
120  void Hover(double x, double y, double scale);
121  void Recenter();
122  void HandleProfileTimer();
123  void ClearHistory();
124 
125  Q_SIGNALS:
132  void FrameGrabbed(QImage);
133  void ImageTransportChanged();
134 
135  protected:
136  Ui::mapviz ui_;
137 
139 
140  QTimer frame_timer_;
141  QTimer spin_timer_;
142  QTimer save_timer_;
145 
146  QLabel* xy_pos_label_;
148 
149  QWidget* spacer1_;
150  QWidget* spacer2_;
151  QWidget* spacer3_;
152  QPushButton* recenter_button_;
153  QPushButton* rec_button_;
154  QPushButton* stop_button_;
155  QPushButton* screenshot_button_;
156 
157  int argc_;
158  char** argv_;
159 
165  QColor background_;
166 
167  std::string save_location_;
168 
169  std::string capture_directory_;
170  QThread video_thread_;
172 
174 
179 
182  std::map<QListWidgetItem*, MapvizPluginPtr> plugins_;
183 
185 
186  void Open(const std::string& filename);
187  void Save(const std::string& filename);
188 
190  const std::string& name,
191  const std::string& type,
192  bool visible,
193  bool collapsed,
194  int draw_order = 0);
195 
196  bool AddDisplay(
197  AddMapvizDisplay::Request& req,
198  AddMapvizDisplay::Response& resp);
199 
200  void ClearDisplays();
201  void AdjustWindowSize();
202 
203  virtual void showEvent(QShowEvent* event);
204  virtual void closeEvent(QCloseEvent* event);
205 
206  static const QString ROS_WORKSPACE_VAR;
207  static const QString MAPVIZ_CONFIG_FILE;
208  static const std::string IMAGE_TRANSPORT_PARAM;
209  };
210 }
211 
212 #endif // MAPVIZ_MAPVIZ_H_
VideoWriter * vid_writer_
Definition: mapviz.h:171
void ToggleShowPlugin(QListWidgetItem *item, bool visible)
Definition: mapviz.cpp:1233
void SaveConfigAs()
Definition: mapviz.cpp:908
bool force_480p_
Definition: mapviz.h:163
void FixedFrameSelected(const QString &text)
Definition: mapviz.cpp:1244
void AdjustWindowSize()
Definition: mapviz.cpp:479
void SpinOnce()
Definition: mapviz.cpp:339
QColor background_
Definition: mapviz.h:165
void FrameGrabbed(QImage)
MapCanvas * canvas_
Definition: mapviz.h:181
void OpenConfig()
Definition: mapviz.cpp:875
bool initialized_
Definition: mapviz.h:161
void HandleProfileTimer()
Definition: mapviz.cpp:1546
QPushButton * stop_button_
Definition: mapviz.h:154
void ToggleUseLatestTransforms(bool on)
Definition: mapviz.cpp:1269
bool resizable_
Definition: mapviz.h:164
QLabel * xy_pos_label_
Definition: mapviz.h:146
void UpdateSizeHints()
Definition: mapviz.cpp:1468
void Recenter()
Definition: mapviz.cpp:1416
QWidget * spacer1_
Definition: mapviz.h:149
QTimer save_timer_
Definition: mapviz.h:142
void CaptureVideoFrame()
Definition: mapviz.cpp:1397
QPushButton * recenter_button_
Definition: mapviz.h:152
void ToggleRecord(bool on)
Definition: mapviz.cpp:1325
void ToggleCaptureTools(bool on)
Definition: mapviz.cpp:1310
void StopRecord()
Definition: mapviz.cpp:1421
void ClearDisplays()
Definition: mapviz.cpp:1502
QWidget * spacer2_
Definition: mapviz.h:150
void UpdateImageTransportMenu()
Definition: mapviz.cpp:1378
virtual void closeEvent(QCloseEvent *event)
Definition: mapviz.cpp:218
pluginlib::ClassLoader< MapvizPlugin > * loader_
Definition: mapviz.h:180
void ToggleEnableAntialiasing(bool on)
Definition: mapviz.cpp:1284
void Force480p(bool on)
Definition: mapviz.cpp:447
Stopwatch meas_spin_
Definition: mapviz.h:184
MapvizPluginPtr CreateNewDisplay(const std::string &name, const std::string &type, bool visible, bool collapsed, int draw_order=0)
Definition: mapviz.cpp:1137
virtual void showEvent(QShowEvent *event)
Definition: mapviz.cpp:213
std::map< QListWidgetItem *, MapvizPluginPtr > plugins_
Definition: mapviz.h:182
void ToggleRotate90(bool on)
Definition: mapviz.cpp:1279
swri_transform_util::TransformManagerPtr tf_manager_
Definition: mapviz.h:178
ros::ServiceServer add_display_srv_
Definition: mapviz.h:176
void ImageTransportChanged()
void SetResizable(bool on)
Definition: mapviz.cpp:463
void Force720p(bool on)
Definition: mapviz.cpp:431
QTimer spin_timer_
Definition: mapviz.h:141
void ClearConfig()
Definition: mapviz.cpp:892
bool is_standalone_
Definition: mapviz.h:160
void Save(const std::string &filename)
Definition: mapviz.cpp:764
void ToggleConfigPanel(bool on)
Definition: mapviz.cpp:1289
void Screenshot()
Definition: mapviz.cpp:1439
QTimer profile_timer_
Definition: mapviz.h:144
char ** argv_
Definition: mapviz.h:158
QWidget * spacer3_
Definition: mapviz.h:151
void ReorderDisplays()
Definition: mapviz.cpp:1517
void SaveConfig()
Definition: mapviz.cpp:897
void ClearHistory()
Definition: mapviz.cpp:941
void SelectNewDisplay()
Definition: mapviz.cpp:950
static const std::string IMAGE_TRANSPORT_PARAM
Definition: mapviz.h:208
boost::shared_ptr< tf::TransformListener > tf_
Definition: mapviz.h:177
void TargetFrameSelected(const QString &text)
Definition: mapviz.cpp:1256
void Initialize()
Definition: mapviz.cpp:231
std::string capture_directory_
Definition: mapviz.h:169
void ToggleFixOrientation(bool on)
Definition: mapviz.cpp:1274
Mapviz(bool is_standalone, int argc, char **argv, QWidget *parent=0, Qt::WindowFlags flags=0)
Definition: mapviz.cpp:87
QLabel * lat_lon_pos_label_
Definition: mapviz.h:147
Ui::mapviz ui_
Definition: mapviz.h:136
void SelectBackgroundColor(const QColor &color)
Definition: mapviz.cpp:1527
void Open(const std::string &filename)
Definition: mapviz.cpp:524
static const QString MAPVIZ_CONFIG_FILE
Definition: mapviz.h:207
static const QString ROS_WORKSPACE_VAR
Definition: mapviz.h:206
QTimer frame_timer_
Definition: mapviz.h:140
QPushButton * rec_button_
Definition: mapviz.h:153
QThread video_thread_
Definition: mapviz.h:170
bool AddDisplay(AddMapvizDisplay::Request &req, AddMapvizDisplay::Response &resp)
Definition: mapviz.cpp:989
ros::NodeHandle * node_
Definition: mapviz.h:175
void SetCaptureDirectory()
Definition: mapviz.cpp:1533
void Hover(double x, double y, double scale)
Definition: mapviz.cpp:1058
QTimer record_timer_
Definition: mapviz.h:143
bool updating_frames_
Definition: mapviz.h:173
void SetImageTransport(QAction *transport_action)
Definition: mapviz.cpp:1369
void RemoveDisplay()
Definition: mapviz.cpp:1483
void UpdateFrames()
Definition: mapviz.cpp:353
void AutoSave()
Definition: mapviz.cpp:841
QPushButton * screenshot_button_
Definition: mapviz.h:155
std::string save_location_
Definition: mapviz.h:167
void ToggleStatusBar(bool on)
Definition: mapviz.cpp:1303
bool force_720p_
Definition: mapviz.h:162
QMenu * image_transport_menu_
Definition: mapviz.h:138


mapviz
Author(s): Marc Alban
autogenerated on Fri Dec 16 2022 03:59:30