TimerGUIPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2016 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 _GUI_TIMER_PLUGIN_HH_
18 #define _GUI_TIMER_PLUGIN_HH_
19 
20 #include <string>
21 #include <vector>
22 #include <boost/thread/mutex.hpp>
23 
24 #include <gazebo/common/Events.hh>
25 #include <gazebo/common/Plugin.hh>
26 #include <gazebo/common/Timer.hh>
27 #include <gazebo/gui/GuiPlugin.hh>
28 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
29 # include <gazebo/transport/transport.hh>
30 # include <gazebo/gui/gui.hh>
31 #endif
32 
33 namespace gazebo
34 {
54  {
55  Q_OBJECT
56 
58  public: TimerGUIPlugin();
59 
61  public: virtual ~TimerGUIPlugin();
62 
63  // Documentation inherited
64  public: void Load(sdf::ElementPtr _elem);
65 
68  public: common::Time GetCurrentTime() const;
69 
72  signals: void SetTime(QString _string);
73 
76  signals: void SetStartStopButton(QString _state);
77 
81  private: void OnTimerCtrl(ConstGzStringPtr &_msg);
82 
84  private: void Start();
85 
87  private: void Stop();
88 
90  private: void Reset();
91 
93  private slots: void OnStartStopButton();
94 
97  private slots: void OnSetStartStopButton(QString _state);
98 
100  private slots: void OnResetButton();
101 
103  private: void PreRender();
104 
109  private: bool eventFilter(QObject *_obj, QEvent *_event);
110 
112  private: transport::NodePtr node;
113 
115  private: transport::SubscriberPtr ctrlSub;
116 
118  private: common::Timer timer;
119 
121  private: std::vector<event::ConnectionPtr> connections;
122 
124  private: boost::mutex timerMutex;
125 
127  private: QPushButton *startStopButton;
128 
130  private: std::string startStyle;
131 
133  private: std::string stopStyle;
134 
136  private: QPushButton *resetButton;
137 
140  private: int posX;
141 
144  private: int posY;
145  };
146 }
147 
148 #endif
A plugin loaded within the gzclient on startup.
Definition: GuiPlugin.hh:26
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
A GUI plugin that displays a timer.
Definition: TimerGUIPlugin.hh:53
A timer class, used to time things in real world walltime.
Definition: Timer.hh:38
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44