Gazebo Gui

API Reference

7.2.2
gz/gui/Application.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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_APPLICATION_HH_
18 #define GZ_GUI_APPLICATION_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "gz/gui/qt.h"
26 #include "gz/gui/Export.hh"
27 
28 #ifdef _WIN32
29 // Disable warning C4251 which is triggered by
30 // std::unique_ptr
31 #pragma warning(push)
32 #pragma warning(disable: 4251)
33 #endif
34 
35 namespace tinyxml2
36 {
37  class XMLElement;
38 }
39 
40 namespace gz::gui
41 {
42  class ApplicationPrivate;
43  class Dialog;
44  class MainWindow;
45  class Plugin;
46 
48  enum class WindowType : int
49  {
52  kMainWindow = 0,
53 
56  kDialog = 1
57  };
58 
63  class GZ_GUI_VISIBLE Application : public QApplication
64  {
65  Q_OBJECT
66 
71  public: Application(int &_argc, char **_argv,
72  const WindowType _type = WindowType::kMainWindow);
73 
75  public: virtual ~Application();
76 
79  public: QQmlApplicationEngine *Engine() const;
80 
91  public: bool LoadPlugin(const std::string &_filename,
92  const tinyxml2::XMLElement *_pluginElem = nullptr);
93 
102  public: bool LoadConfig(const std::string &_path);
103 
109  public: bool LoadDefaultConfig();
110 
118  public: void SetDefaultConfigPath(const std::string &_path);
119 
124  public: std::string DefaultConfigPath();
125 
129  public: void SetPluginPathEnv(const std::string &_env);
130 
133  public: void AddPluginPath(const std::string &_path);
134 
147  PluginList();
148 
155  public: bool RemovePlugin(const std::string &_pluginName);
156 
161  public: std::shared_ptr<Plugin> PluginByName(
162  const std::string &_pluginName) const;
163 
166  signals: void PluginAdded(const QString &_objectName);
167 
169  public slots: void OnPluginClose();
170 
174  public: bool CreateMainWindow();
175 
182  private: bool InitializeMainWindow();
183 
189  private: bool InitializeDialogs();
190 
193  private: void RemovePlugin(std::shared_ptr<Plugin> _plugin);
194 
199  private: bool AddPluginsToWindow();
200 
204  private: bool ApplyConfig();
205 
208  private: std::unique_ptr<ApplicationPrivate> dataPtr;
209  };
210 
213  GZ_GUI_VISIBLE
214  Application *App();
215 } // namespace gz::gui
216 
217 #ifdef _MSC_VER
218 #pragma warning(pop)
219 #endif
220 
221 #endif // GZ_GUI_APPLICATION_HH_