visualization_frame.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
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 the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * 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 THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_VISUALIZATION_FRAME_H
31 #define RVIZ_VISUALIZATION_FRAME_H
32 
33 #include <boost/shared_ptr.hpp>
34 
35 #include <QMainWindow>
36 #include <QList>
37 
38 #include <string>
39 #include <deque>
40 
41 #include "rviz/config.h"
43 #include "rviz/panel.h"
44 #include "rviz/rviz_export.h"
45 
46 #include <ros/time.h>
47 
48 class QSplashScreen;
49 class QAction;
50 class QActionGroup;
51 class QTimer;
52 class QDockWidget;
53 class QLabel;
54 class QToolButton;
55 
56 namespace rviz
57 {
58 class PanelFactory;
59 struct Preferences;
60 class RenderPanel;
61 class VisualizationManager;
62 class Tool;
63 class WidgetGeometryChangeDetector;
64 
74 class RVIZ_EXPORT VisualizationFrame : public QMainWindow, public WindowManagerInterface
75 {
76  Q_OBJECT
77 public:
78  VisualizationFrame(QWidget* parent = nullptr);
79  ~VisualizationFrame() override;
80 
81  void setApp(QApplication* app);
82 
84  void setShowChooseNewMaster(bool show);
85 
88  void setHelpPath(const QString& help_path);
89 
94  void setSplashPath(const QString& splash_path);
95 
105  void initialize(const QString& display_config_file = "");
106 
108  {
109  return manager_;
110  }
111 
112  // overrides from WindowManagerInterface
113  QWidget* getParentWindow() override;
114  PanelDockWidget* addPane(const QString& name,
115  QWidget* panel,
116  Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
117  bool floating = false) override;
118 
119  QDockWidget* addPanelByName(const QString& name,
120  const QString& class_lookup_name,
121  Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
122  bool floating = false);
123 
128  void loadPersistentSettings();
129 
134  void savePersistentSettings();
135 
139  void loadDisplayConfig(const QString& path);
140 
143  bool loadDisplayConfigHelper(const std::string& full_path);
144 
151  bool saveDisplayConfig(const QString& path);
152 
153  QString getErrorMessage() const
154  {
155  return error_message_;
156  }
157 
164  virtual void load(const Config& config);
165 
173  virtual void save(Config config);
174 
176  void setHideButtonVisibility(bool visible);
177 
178 public Q_SLOTS:
181  void setDisplayConfigModified();
182 
184  void setStatus(const QString& message) override;
185 
187  void setFullScreen(bool full_screen);
188 
190  void exitFullScreen();
191 
192 Q_SIGNALS:
194  void statusUpdate(const QString& message);
195 
197  void fullScreenChange(bool hidden);
198 
200  void displayConfigFileChanged(const QString& fullpath);
201 
202 protected Q_SLOTS:
203  void onOpen();
204  void onSave();
205  void onSaveAs();
206  void onSaveImage();
207  void onRecentConfigSelected();
208  void onHelpWiki();
209  void onHelpAbout();
210  void openNewPanelDialog();
211  void openNewToolDialog();
212  void openPreferencesDialog();
213  void showHelpPanel();
214  void onDockPanelChange();
215 
217  void onToolbarRemoveTool(QAction* remove_tool_menu_action);
218 
220  void onButtonStyleTool(QAction* button_style_tool_menu_action);
221 
224  void onToolbarActionTriggered(QAction* action);
225 
231  void addTool(Tool* tool);
232 
234  void onToolNameChanged(const QString& name);
235 
237  void removeTool(Tool* tool);
238 
242  void refreshTool(Tool* tool);
243 
248  void indicateToolIsCurrent(Tool* tool);
249 
253  void changeMaster();
254 
259  void onDeletePanel();
260 
261 protected Q_SLOTS:
263  void markLoadingDone();
264 
266  void setImageSaveDirectory(const QString& directory);
267 
268  void reset();
269 
270  void onHelpDestroyed();
271 
272  void hideLeftDock(bool hide);
273  void hideRightDock(bool hide);
274 
275  virtual void onDockPanelVisibilityChange(bool visible);
276 
277  void updateFps();
278 
279 protected:
283  void initConfigs();
284 
285  void initMenus();
286 
289  void initToolbars();
290 
293  bool prepareToExit();
294 
295  void closeEvent(QCloseEvent* event) override;
296 
297  void leaveEvent(QEvent* event) override;
298 
299  void markRecentConfig(const std::string& path);
300  void updateRecentConfigMenu();
301 
303  void loadPanels(const Config& config);
304 
306  void configureToolbars(const Config& config);
307 
309  void saveToolbars(Config config);
310 
312  void savePanels(Config config);
313 
314  void loadPreferences(const Config& config);
315  void savePreferences(Config config);
316 
317  void loadWindowGeometry(const Config& config);
318  void saveWindowGeometry(Config config);
319 
324  void setDisplayConfigFile(const std::string& path);
325 
326  void hideDockImpl(Qt::DockWidgetArea area, bool hide);
327 
328  QApplication* app_;
329 
331 
333 
334  std::string config_dir_;
336  std::string display_config_file_;
338  std::string last_config_dir_;
339  std::string last_image_dir_;
340  std::string home_dir_;
341 
343 
344  QMenu* file_menu_;
346  QMenu* view_menu_;
349 
350  QToolBar* toolbar_;
351 
353 
354  std::string package_path_;
355  QString help_path_;
356  QString splash_path_;
357 
358  QSplashScreen* splash_;
359 
360  typedef std::deque<std::string> D_string;
361  D_string recent_configs_;
362 
363  QActionGroup* toolbar_actions_;
364  std::map<QAction*, Tool*> action_to_tool_map_;
365  std::map<Tool*, QAction*> tool_to_action_map_;
367 
370 
372 
373  struct PanelRecord
374  {
377  QString name;
378  QString class_id;
379  QAction* delete_action;
380  };
381  QList<PanelRecord> custom_panels_;
382 
386 
389  bool loading_;
391 
393  QLabel* status_label_;
394  QLabel* fps_label_;
395  QStatusBar* original_status_bar_;
396 
399 
400  QString error_message_;
401 
404 };
405 
406 } // namespace rviz
407 
408 #endif // RVIZ_VISUALIZATION_FRAME_H
boost::shared_ptr< Preferences > preferences_
app
VisualizationManager * getManager()
QString error_message_
Error message (if any) from most recent saveDisplayConfig() call.
ROSCONSOLE_DECL void initialize()
config
bool toolbar_visible_
Indicates if the toolbar should be visible outside of fullscreen mode.
std::map< Tool *, QAction * > tool_to_action_map_
Configuration data storage class.
Definition: config.h:124
QList< PanelRecord > custom_panels_
VisualizationManager * manager_
The VisualizationManager class is the central manager class of rviz, holding all the Displays...
std::deque< std::string > D_string
action
bool loading_
True just when loading a display config file, false all other times.
Utility class for watching for events which indicate that widget geometry has changed.
WidgetGeometryChangeDetector * geom_change_detector_
The main rviz window.
Dock widget class for docking widgets into VisualizationFrame.
std::map< QAction *, Tool * > action_to_tool_map_


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat Nov 6 2021 02:06:35