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 onPanelDeleted(QObject* dock);
271  void onHelpDestroyed();
272 
273  void hideLeftDock(bool hide);
274  void hideRightDock(bool hide);
275 
276  virtual void onDockPanelVisibilityChange(bool visible);
277 
278  void updateFps();
279 
280 protected:
284  void initConfigs();
285 
286  void initMenus();
287 
290  void initToolbars();
291 
294  bool prepareToExit();
295 
296  void closeEvent(QCloseEvent* event) override;
297 
298  void leaveEvent(QEvent* event) override;
299 
300  void markRecentConfig(const std::string& path);
301  void updateRecentConfigMenu();
302 
304  void loadPanels(const Config& config);
305 
307  void configureToolbars(const Config& config);
308 
310  void saveToolbars(Config config);
311 
313  void savePanels(Config config);
314 
315  void loadPreferences(const Config& config);
316  void savePreferences(Config config);
317 
318  void loadWindowGeometry(const Config& config);
319  void saveWindowGeometry(Config config);
320 
325  void setDisplayConfigFile(const std::string& path);
326 
327  void hideDockImpl(Qt::DockWidgetArea area, bool hide);
328 
329  QApplication* app_;
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;
362  D_string recent_configs_;
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 
387 
390  bool loading_;
392 
394  QLabel* status_label_;
395  QLabel* fps_label_;
396  QStatusBar* original_status_bar_;
397 
400 
401  QString error_message_;
402 
405 };
406 
407 } // namespace rviz
408 
409 #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 May 27 2023 02:06:25