TopicView.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 _TOPICVIEW_HH_
18 #define _TOPICVIEW_HH_
19 
20 #include <list>
21 #include <string>
22 
23 #include <boost/thread/mutex.hpp>
24 
25 #include "gazebo/common/Time.hh"
26 
27 #include "gazebo/gui/qt.h"
28 
30 
31 #include "gazebo/util/system.hh"
32 
33 namespace gazebo
34 {
35  namespace gui
36  {
40  class GZ_GUI_VISIBLE TopicCombo : public QComboBox
41  {
47  public: TopicCombo(QWidget *_w, const std::string &_msgTypeName,
48  const std::string &_viewType, transport::NodePtr _node);
49 
51  public: virtual ~TopicCombo();
52 
55  public: void SetMsgTypeName(const std::string &_type);
56 
59  public: virtual void showPopup();
60 
62  private: void UpdateList();
63 
65  private: std::string msgTypeName;
66 
68  private: std::string viewType;
69 
71  private: transport::NodePtr node;
72 
73  private: boost::mutex mutex;
74  };
76 
78  class GZ_GUI_VISIBLE TopicView : public QDialog
79  {
80  Q_OBJECT
81 
88  public: TopicView(QWidget *_parent, const std::string &_msgType,
89  const std::string &_viewType,
90  unsigned int _displayPeriod = 500);
91 
93  public: virtual ~TopicView();
94 
97  public: virtual void SetTopic(const std::string &_topicName);
98 
104  protected: void OnMsg(const common::Time &_dataTime, int _size);
105 
108  protected: virtual void closeEvent(QCloseEvent *_event);
109 
111  private slots: void Update();
112 
115  private: virtual void UpdateImpl();
116 
120  private slots: void OnTopicChanged(int _index);
121 
123  protected: QFrame *frame;
124 
127 
130 
132  protected: std::string msgTypeName;
133 
135  private: TopicCombo *topicCombo;
136 
138  private: common::Time prevTime;
139 
141  private: common::Time prevDisplayTime;
142 
144  private: QLineEdit *hzEdit;
145 
147  private: double hz;
148 
150  private: QLineEdit *bandwidthEdit;
151 
153  private: std::list<int> msgSizes;
154 
156  private: std::list<common::Time> times;
157 
159  private: std::list<common::Time> dataTimes;
160 
162  private: boost::mutex updateMutex;
163  };
164  }
165 }
166 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Forward declarations for transport.
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
QFrame * frame
This is the frame that each child class should populate.
Definition: TopicView.hh:123
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
transport::NodePtr node
Pointer to the node for communication.
Definition: TopicView.hh:129
std::string msgTypeName
Typename of the messages that can be displayed.
Definition: TopicView.hh:132
Base class for widgets that display topic data.
Definition: TopicView.hh:78
transport::SubscriberPtr sub
Pointer to the topic subscriber that receives display data.
Definition: TopicView.hh:126
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44