Gazebo Gui

API Reference

9.0.0~pre1
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#include <gz/utils/ImplPtr.hh>
29
30namespace tinyxml2
31{
32 class XMLElement;
33}
34
35namespace gz::gui
36{
37 class Dialog;
38 class MainWindow;
39 class Plugin;
40
42 enum class WindowType : int
43 {
46 kMainWindow = 0,
47
50 kDialog = 1
51 };
52
57 class GZ_GUI_VISIBLE Application : public QApplication
58 {
59 Q_OBJECT
60
67 public: Application(int &_argc, char **_argv,
68 const WindowType _type = WindowType::kMainWindow,
69 const char *_renderEngineGuiApiBackend = nullptr);
70
72 public: virtual ~Application();
73
76 public: QQmlApplicationEngine *Engine() const;
77
88 public: bool LoadPlugin(const std::string &_filename,
89 const tinyxml2::XMLElement *_pluginElem = nullptr);
90
99 public: bool LoadConfig(const std::string &_path);
100
105 public: bool LoadWindowConfig(const tinyxml2::XMLElement &_window);
106
112 public: bool LoadDefaultConfig();
113
121 public: void SetDefaultConfigPath(const std::string &_path);
122
128
134 public: std::string ResolveConfigFile(const std::string &_path) const;
135
139 public: void SetPluginPathEnv(const std::string &_env);
140
143 public: void AddPluginPath(const std::string &_path);
144
158
165 public: bool RemovePlugin(const std::string &_pluginName);
166
172 const std::string &_pluginName) const;
173
176 signals: void PluginAdded(const QString &_objectName);
177
179 public slots: void OnPluginClose();
180
184 public: bool CreateMainWindow();
185
192 private: bool InitializeMainWindow();
193
199 private: bool InitializeDialogs();
200
203 private: void RemovePlugin(std::shared_ptr<Plugin> _plugin);
204
209 private: bool AddPluginsToWindow();
210
214 private: bool ApplyConfig();
215
218 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
219 };
220
223 GZ_GUI_VISIBLE
225} // namespace gz::gui
226#endif // GZ_GUI_APPLICATION_HH_