TimerGUIPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 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 GAZEBO_PLUGINS_TIMERGUIPLUGIN_HH_
18 #define GAZEBO_PLUGINS_TIMERGUIPLUGIN_HH_
19 
20 #include <mutex>
21 #include <string>
22 #include <vector>
23 #include <ignition/transport/Node.hh>
24 
25 #include <gazebo/common/Events.hh>
26 #include <gazebo/common/Plugin.hh>
27 #include <gazebo/common/Timer.hh>
28 #include <gazebo/gui/GuiPlugin.hh>
29 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
30 # include <gazebo/transport/transport.hh>
31 # include <gazebo/gui/gui.hh>
32 #endif
33 
34 namespace gazebo
35 {
55  {
56  Q_OBJECT
57 
59  public: TimerGUIPlugin();
60 
62  public: virtual ~TimerGUIPlugin();
63 
64  // Documentation inherited
65  public: void Load(sdf::ElementPtr _elem);
66 
69  public: common::Time GetCurrentTime() const;
70 
73  signals: void SetTime(QString _string);
74 
77  signals: void SetStartStopButton(QString _state);
78 
82  private: void OnTimerCtrl(ConstGzStringPtr &_msg);
83 
85  private: void Start();
86 
88  private: void Stop();
89 
91  private: void Reset();
92 
94  private slots: void OnStartStopButton();
95 
98  private slots: void OnSetStartStopButton(QString _state);
99 
101  private slots: void OnResetButton();
102 
104  private: void PreRender();
105 
110  private: bool eventFilter(QObject *_obj, QEvent *_event);
111 
113  private: transport::NodePtr node;
114 
116  private: transport::SubscriberPtr ctrlSub;
117 
119  private: common::Timer timer;
120 
122  private: std::vector<event::ConnectionPtr> connections;
123 
125  private: std::mutex timerMutex;
126 
128  private: QPushButton *startStopButton;
129 
131  private: std::string startStyle;
132 
134  private: std::string stopStyle;
135 
137  private: QPushButton *resetButton;
138 
141  private: int posX;
142 
145  private: int posY;
146 
147  // Place ignition::transport objects at the end of this file to
148  // guarantee they are destructed first.
149 
151  private: ignition::transport::Node nodeIgn;
152  };
153 }
154 
155 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
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:54
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:58
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44