Gazebo Gui

API Reference

6.8.0
gz/gui/Plugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_PLUGIN_HH_
18 #define GZ_GUI_PLUGIN_HH_
19 
20 #include <tinyxml2.h>
21 #include <memory>
22 #include <string>
23 
24 #include "gz/gui/qt.h"
25 #include "gz/gui/Export.hh"
26 
27 #ifdef _WIN32
28 // Disable warning C4251 which is triggered by
29 // std::unique_ptr
30 #pragma warning(push)
31 #pragma warning(disable: 4251)
32 #endif
33 
34 namespace ignition
35 {
36  namespace gui
37  {
38  class PluginPrivate;
39 
54  class IGNITION_GUI_VISIBLE Plugin : public QObject
55  {
56  Q_OBJECT
57 
59  public: Plugin();
60 
62  public: virtual ~Plugin();
63 
73  public: void Load(const tinyxml2::XMLElement *_pluginElem);
74 
77  public: virtual std::string ConfigStr();
78 
82  public: QQuickItem *CardItem() const;
83 
86  public: QQuickItem *PluginItem() const;
87 
90  public: QQmlContext *Context() const;
91 
94  public: void PostParentChanges();
95 
104  protected: virtual void LoadConfig(
105  const tinyxml2::XMLElement *_pluginElem)
106  {
107  (void)_pluginElem;
108  }
109 
112  public: virtual std::string Title() const {return this->title;}
113 
117  public: bool DeleteLaterRequested() const;
118 
121  protected: void DeleteLater();
122 
124  protected: std::string title = "";
125 
127  protected: std::string configStr;
128 
135  private: virtual void LoadCommonConfig(
136  const tinyxml2::XMLElement *_ignGuiElem);
137 
140  private: void ApplyAnchors();
141 
144  private: std::unique_ptr<PluginPrivate> dataPtr;
145  };
146  }
147 }
148 
149 #ifdef _MSC_VER
150 #pragma warning(pop)
151 #endif
152 
153 #endif
STL class.
bool DeleteLaterRequested() const
Get the value of the the delete_later element from the configuration file, which defaults to false.
void PostParentChanges()
Apply changes which should come after the plugin already has a parent.
virtual ~Plugin()
Destructor.
QQuickItem * CardItem() const
Get the card item which contains this plugin. The item is generated the first time this function is r...
void DeleteLater()
Wait until the plugin has a parent, then close and delete the parent.
std::string configStr
XML configuration.
Definition: gz/gui/Plugin.hh:127
QQuickItem * PluginItem() const
Get the plugin item.
Plugin()
Constructor.
virtual std::string Title() const
Get title.
Definition: gz/gui/Plugin.hh:112
void Load(const tinyxml2::XMLElement *_pluginElem)
Load the plugin with a configuration file. This loads the default parameters and then calls LoadConfi...
Base class for Gazebo GUI plugins.
Definition: gz/gui/Plugin.hh:54
std::string title
Title to be displayed on top of plugin.
Definition: gz/gui/Plugin.hh:124
virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem)
Load the plugin with a configuration file. Override this on custom plugins to handle custom configura...
Definition: gz/gui/Plugin.hh:104
virtual std::string ConfigStr()
Get the configuration XML as a string.
QQmlContext * Context() const
Get the QML context where the plugin was created.