GuiPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 "gazebo/gui/qt.h"
21 #include "gazebo/common/Plugin.hh"
22 
23 namespace gazebo
24 {
26  class GZ_GUI_VISIBLE GUIPlugin : public QWidget, public PluginT<GUIPlugin>
27  {
28  public: GUIPlugin() : QWidget(NULL)
29  {this->type = GUI_PLUGIN;}
30 
40  public: virtual void Load(sdf::ElementPtr /*_sdf*/) {}
41 
42  // \brief must be defined to support style sheets
43  public: virtual void paintEvent(QPaintEvent *)
44  {
45  QStyleOption opt;
46  opt.init(this);
47  QPainter p(this);
48  style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
49  }
50  };
51 
56 #define GZ_REGISTER_GUI_PLUGIN(classname) \
57  extern "C" GZ_PLUGIN_VISIBLE gazebo::GUIPlugin *RegisterPlugin(); \
58  gazebo::GUIPlugin *RegisterPlugin() \
59  {\
60  return new classname();\
61  }
62 }
63 
64 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
A plugin loaded within the gzclient on startup.
Definition: GuiPlugin.hh:26
virtual void Load(sdf::ElementPtr)
Load function.
Definition: GuiPlugin.hh:40
A GUI plugin.
Definition: Plugin.hh:76
#define NULL
Definition: CommonTypes.hh:31
A class which all plugins must inherit from.
Definition: Plugin.hh:83
virtual void paintEvent(QPaintEvent *)
Definition: GuiPlugin.hh:43
GUIPlugin()
Definition: GuiPlugin.hh:28