Gazebo Gui

API Reference

6.8.0
Screenshot.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_GUI_PLUGINS_SCREENSHOT_HH_
18 #define GZ_GUI_PLUGINS_SCREENSHOT_HH_
19 
20 #ifdef _MSC_VER
21 #pragma warning(push, 0)
22 #endif
23 #include <gz/msgs/boolean.pb.h>
24 #include <gz/msgs/stringmsg.pb.h>
25 #ifdef _MSC_VER
26 #pragma warning(pop)
27 #endif
28 
29 #include <memory>
30 
31 #include "gz/gui/qt.h"
32 #include "gz/gui/Plugin.hh"
33 
34 namespace ignition
35 {
36 namespace gui
37 {
38 namespace plugins
39 {
40  class ScreenshotPrivate;
41 
48  class Screenshot : public Plugin
49  {
50  Q_OBJECT
51 
53  Q_PROPERTY(
55  READ Directory
56  WRITE SetDirectory
57  NOTIFY DirectoryChanged
58  )
59 
60 
61  Q_PROPERTY(
66  )
67 
69  public: Screenshot();
70 
72  public: ~Screenshot() override;
73 
74  // Documentation inherited
75  public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
76 
78  public slots: void OnScreenshot();
79 
83  private: bool eventFilter(QObject *_obj, QEvent *_event) override;
84 
90  private: bool ScreenshotService(const msgs::StringMsg &_msg,
91  msgs::Boolean &_res);
92 
95  private: void FindUserCamera();
96 
98  private: void SaveScreenshot();
99 
102  public: Q_INVOKABLE QString Directory() const;
103 
107  public: Q_INVOKABLE void SetDirectory(const QString &_dirUrl);
108 
110  signals: void DirectoryChanged();
111 
115  public: Q_INVOKABLE QString SavedScreenshotPath() const;
116 
120  public: Q_INVOKABLE void SetSavedScreenshotPath(const QString &_filename);
121 
123  signals: void SavedScreenshotPathChanged();
124 
126  signals: void savedScreenshot();
127 
130  private: std::unique_ptr<ScreenshotPrivate> dataPtr;
131  };
132 }
133 }
134 }
135 
136 #endif
void DirectoryChanged()
Notify that the directory path has changed.
Q_INVOKABLE void SetDirectory(const QString &_dirUrl)
Set the directory path from a string, for example '/home/Pictures'.
QString savedScreenshotPath
Saved screenshot filepath.
Definition: Screenshot.hh:66
Q_INVOKABLE QString Directory() const
Get the directory path as a string, for example '/home/Pictures'.
Q_INVOKABLE void SetSavedScreenshotPath(const QString &_filename)
Set the filepath of the saved screenshot from a string, for example '/home/Pictures/[timestamp]....
QString directory
Directory to save screenshots.
Definition: Screenshot.hh:58
void savedScreenshot()
Notify that the screenshot has been saved (opens popup)
Base class for Gazebo GUI plugins.
Definition: gz/gui/Plugin.hh:54
Q_INVOKABLE QString SavedScreenshotPath() const
Get the filepath of the saved screenshot as a string, for example '/home/Pictures/[timestamp]....
void OnScreenshot()
Callback when screenshot is requested from the GUI.
STL namespace.
Provides a button and a transport service for taking a screenshot of current 3D scene.
Definition: Screenshot.hh:48
void SavedScreenshotPathChanged()
Notify that the screenshot filename has changed.
Definition: gz/gui/Application.hh:35
void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override
Load the plugin with a configuration file. Override this on custom plugins to handle custom configura...