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  [[deprecated("setApp() not needed anymore")]] 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 
145  bool loadDisplayConfigHelper(const std::string& full_path, const bool discard_changes = false);
146 
153  bool saveDisplayConfig(const QString& path);
154 
155  QString getErrorMessage() const
156  {
157  return error_message_;
158  }
159 
166  virtual void load(const Config& config);
167 
175  virtual void save(Config config);
176 
178  void setHideButtonVisibility(bool visible);
179 
180 public Q_SLOTS:
183  void setDisplayConfigModified();
184 
186  void setStatus(const QString& message) override;
187 
189  void setFullScreen(bool full_screen);
190 
192  void exitFullScreen();
193 
194 Q_SIGNALS:
196  void statusUpdate(const QString& message);
197 
199  void fullScreenChange(bool hidden);
200 
202  void displayConfigFileChanged(const QString& fullpath);
203 
204 protected Q_SLOTS:
205  void onOpen();
206  void onSave();
207  void onSaveAs();
208  void onSaveImage();
209  void onRecentConfigSelected();
210  void onHelpWiki();
211  void onHelpAbout();
212  void openNewPanelDialog();
213  void openNewToolDialog();
214  void openPreferencesDialog();
215  void showHelpPanel();
216  void onDockPanelChange();
217 
219  void onToolbarRemoveTool(QAction* remove_tool_menu_action);
220 
222  void onButtonStyleTool(QAction* button_style_tool_menu_action);
223 
226  void onToolbarActionTriggered(QAction* action);
227 
233  void addTool(Tool* tool);
234 
236  void onToolNameChanged(const QString& name);
237 
239  void removeTool(Tool* tool);
240 
244  void refreshTool(Tool* tool);
245 
250  void indicateToolIsCurrent(Tool* tool);
251 
255  void changeMaster();
256 
261  void onDeletePanel();
262 
263 protected Q_SLOTS:
265  void markLoadingDone();
266 
268  void setImageSaveDirectory(const QString& directory);
269 
270  void reset();
271 
272  void onPanelDeleted(QObject* dock);
273  void onHelpDestroyed();
274 
275  void hideLeftDock(bool hide);
276  void hideRightDock(bool hide);
277 
278  virtual void onDockPanelVisibilityChange(bool visible);
279 
280  void updateFps();
281 
282 protected:
286  void initConfigs();
287 
288  void initMenus();
289 
292  void initToolbars();
293 
296  bool prepareToExit();
297 
298  void closeEvent(QCloseEvent* event) override;
299 
300  void leaveEvent(QEvent* event) override;
301 
302  void markRecentConfig(const std::string& path);
303  void updateRecentConfigMenu();
304 
306  void loadPanels(const Config& config);
307 
309  void configureToolbars(const Config& config);
310 
312  void saveToolbars(Config config);
313 
315  void savePanels(Config config);
316 
317  void loadPreferences(const Config& config);
318  void savePreferences(Config config);
319 
320  void loadWindowGeometry(const Config& config);
321  void saveWindowGeometry(Config config);
322 
327  void setDisplayConfigFile(const std::string& path);
328 
329  void hideDockImpl(Qt::DockWidgetArea area, bool hide);
330 
332 
334 
335  std::string config_dir_;
337  std::string display_config_file_;
339  std::string last_config_dir_;
340  std::string last_image_dir_;
341  std::string home_dir_;
342 
344 
345  QMenu* file_menu_;
347  QMenu* view_menu_;
350 
351  QToolBar* toolbar_;
352 
354 
355  std::string package_path_;
356  QString help_path_;
357  QString splash_path_;
358 
359  QSplashScreen* splash_;
360 
361  typedef std::deque<std::string> D_string;
363 
364  QActionGroup* toolbar_actions_;
365  std::map<QAction*, Tool*> action_to_tool_map_;
366  std::map<Tool*, QAction*> tool_to_action_map_;
368 
371 
373 
374  struct PanelRecord
375  {
378  QString name;
379  QString class_id;
380  QAction* delete_action;
381  };
382  QList<PanelRecord> custom_panels_;
383 
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
rviz::VisualizationFrame::PanelRecord::class_id
QString class_id
Definition: visualization_frame.h:379
rviz::VisualizationFrame::home_dir_
std::string home_dir_
Definition: visualization_frame.h:341
rviz::VisualizationFrame::config_dir_
std::string config_dir_
Definition: visualization_frame.h:335
rviz::VisualizationFrame::splash_
QSplashScreen * splash_
Definition: visualization_frame.h:359
window_manager_interface.h
rviz::VisualizationFrame::manager_
VisualizationManager * manager_
Definition: visualization_frame.h:353
rviz::Tool
Definition: tool.h:56
boost::shared_ptr
rviz::VisualizationFrame::file_menu_
QMenu * file_menu_
Definition: visualization_frame.h:345
rviz::Panel
Definition: panel.h:41
rviz::VisualizationFrame::toolbar_actions_
QActionGroup * toolbar_actions_
Definition: visualization_frame.h:364
rviz::PanelFactory
Definition: panel_factory.h:37
rviz::VisualizationManager
The VisualizationManager class is the central manager class of rviz, holding all the Displays,...
Definition: visualization_manager.h:96
time.h
rviz::VisualizationFrame::package_path_
std::string package_path_
Definition: visualization_frame.h:355
rviz::VisualizationFrame::custom_panels_
QList< PanelRecord > custom_panels_
Definition: visualization_frame.h:382
rviz::PanelDockWidget
Dock widget class for docking widgets into VisualizationFrame.
Definition: panel_dock_widget.h:46
rviz::VisualizationFrame::geom_change_detector_
WidgetGeometryChangeDetector * geom_change_detector_
Definition: visualization_frame.h:388
rviz::VisualizationFrame::toolbar_
QToolBar * toolbar_
Definition: visualization_frame.h:351
rviz::VisualizationFrame::delete_view_menu_
QMenu * delete_view_menu_
Definition: visualization_frame.h:348
rviz::VisualizationFrame::show_choose_new_master_option_
bool show_choose_new_master_option_
Definition: visualization_frame.h:367
rviz::VisualizationFrame::PanelRecord::panel
Panel * panel
Definition: visualization_frame.h:376
rviz::VisualizationFrame::last_fps_calc_time_
ros::WallTime last_fps_calc_time_
Definition: visualization_frame.h:398
rviz::VisualizationFrame::remove_tool_menu_
QMenu * remove_tool_menu_
Definition: visualization_frame.h:385
rviz::VisualizationFrame::recent_configs_
D_string recent_configs_
Definition: visualization_frame.h:362
rviz::VisualizationFrame::hide_left_dock_button_
QToolButton * hide_left_dock_button_
Definition: visualization_frame.h:369
rviz::VisualizationFrame::PanelRecord::delete_action
QAction * delete_action
Definition: visualization_frame.h:380
rviz::VisualizationFrame::tool_to_action_map_
std::map< Tool *, QAction * > tool_to_action_map_
Definition: visualization_frame.h:366
rviz::VisualizationFrame::loading_
bool loading_
True just when loading a display config file, false all other times.
Definition: visualization_frame.h:389
rviz::VisualizationFrame::last_config_dir_
std::string last_config_dir_
Definition: visualization_frame.h:339
rviz::VisualizationFrame::PanelRecord::name
QString name
Definition: visualization_frame.h:378
rviz::VisualizationFrame::plugins_menu_
QMenu * plugins_menu_
Definition: visualization_frame.h:349
rviz::VisualizationFrame
The main rviz window.
Definition: visualization_frame.h:74
rviz::VisualizationFrame::D_string
std::deque< std::string > D_string
Definition: visualization_frame.h:361
rviz::VisualizationFrame::frame_count_
int frame_count_
Definition: visualization_frame.h:397
rviz
Definition: add_display_dialog.cpp:54
rviz::VisualizationFrame::help_path_
QString help_path_
Definition: visualization_frame.h:356
rviz::VisualizationFrame::getManager
VisualizationManager * getManager()
Definition: visualization_frame.h:107
rviz::VisualizationFrame::error_message_
QString error_message_
Error message (if any) from most recent saveDisplayConfig() call.
Definition: visualization_frame.h:400
rviz::VisualizationFrame::view_menu_
QMenu * view_menu_
Definition: visualization_frame.h:347
rviz::VisualizationFrame::show_help_action_
QAction * show_help_action_
Definition: visualization_frame.h:333
rviz::VisualizationFrame::default_display_config_file_
std::string default_display_config_file_
Definition: visualization_frame.h:338
rviz::VisualizationFrame::PanelRecord::dock
PanelDockWidget * dock
Definition: visualization_frame.h:377
rviz::WidgetGeometryChangeDetector
Utility class for watching for events which indicate that widget geometry has changed.
Definition: widget_geometry_change_detector.h:37
rviz::VisualizationFrame::hide_right_dock_button_
QToolButton * hide_right_dock_button_
Definition: visualization_frame.h:370
rviz::VisualizationFrame::persistent_settings_file_
std::string persistent_settings_file_
Definition: visualization_frame.h:336
rviz::VisualizationFrame::original_status_bar_
QStatusBar * original_status_bar_
Definition: visualization_frame.h:395
ros::WallTime
app
app
rviz::VisualizationFrame::recent_configs_menu_
QMenu * recent_configs_menu_
Definition: visualization_frame.h:346
rviz::VisualizationFrame::panel_factory_
PanelFactory * panel_factory_
Definition: visualization_frame.h:372
rviz::VisualizationFrame::render_panel_
RenderPanel * render_panel_
Definition: visualization_frame.h:331
rviz::VisualizationFrame::action_to_tool_map_
std::map< QAction *, Tool * > action_to_tool_map_
Definition: visualization_frame.h:365
rviz::VisualizationFrame::initialized_
bool initialized_
Definition: visualization_frame.h:387
rviz::VisualizationFrame::post_load_timer_
QTimer * post_load_timer_
Definition: visualization_frame.h:390
initialize
ROSCONSOLE_DECL void initialize()
rviz::VisualizationFrame::preferences_
boost::shared_ptr< Preferences > preferences_
Definition: visualization_frame.h:343
rviz::VisualizationFrame::PanelRecord
Definition: visualization_frame.h:374
rviz::VisualizationFrame::toolbar_separator_
QAction * toolbar_separator_
Definition: visualization_frame.h:384
rviz::VisualizationFrame::display_config_file_
std::string display_config_file_
Definition: visualization_frame.h:337
config.h
rviz::VisualizationFrame::getErrorMessage
QString getErrorMessage() const
Definition: visualization_frame.h:155
rviz::VisualizationFrame::fps_label_
QLabel * fps_label_
Definition: visualization_frame.h:394
rviz::WindowManagerInterface
Definition: window_manager_interface.h:40
rviz::RenderPanel
Definition: render_panel.h:74
rviz::VisualizationFrame::last_image_dir_
std::string last_image_dir_
Definition: visualization_frame.h:340
rviz::VisualizationFrame::status_label_
QLabel * status_label_
Definition: visualization_frame.h:393
rviz::Config
Configuration data storage class.
Definition: config.h:124
panel.h
rviz::VisualizationFrame::toolbar_visible_
bool toolbar_visible_
Indicates if the toolbar should be visible outside of fullscreen mode.
Definition: visualization_frame.h:403
rviz::VisualizationFrame::splash_path_
QString splash_path_
Definition: visualization_frame.h:357


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:03