All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TopicView.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-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 _TOPICVIEW_HH_
18 #define _TOPICVIEW_HH_
19 
20 #include <string>
21 #include <list>
22 #include <boost/thread/mutex.hpp>
23 
24 #include "gazebo/common/Time.hh"
25 #include "gazebo/msgs/msgs.hh"
26 
27 #include "gazebo/gui/qt.h"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace gui
34  {
38  class GAZEBO_VISIBLE TopicCombo : public QComboBox
39  {
45  public: TopicCombo(QWidget *_w, const std::string &_msgTypeName,
46  const std::string &_viewType, transport::NodePtr _node);
47 
49  public: virtual ~TopicCombo();
50 
53  public: void SetMsgTypeName(const std::string &_type);
54 
57  public: virtual void showPopup();
58 
60  private: void UpdateList();
61 
63  private: std::string msgTypeName;
64 
66  private: std::string viewType;
67 
69  private: transport::NodePtr node;
70 
71  private: boost::mutex mutex;
72  };
74 
76  class GAZEBO_VISIBLE TopicView : public QDialog
77  {
78  Q_OBJECT
79 
86  public: TopicView(QWidget *_parent, const std::string &_msgType,
87  const std::string &_viewType,
88  unsigned int _displayPeriod = 500);
89 
91  public: virtual ~TopicView();
92 
95  public: virtual void SetTopic(const std::string &_topicName);
96 
102  protected: void OnMsg(const common::Time &_dataTime, int _size);
103 
106  protected: virtual void closeEvent(QCloseEvent *_event);
107 
109  private slots: void Update();
110 
113  private: virtual void UpdateImpl();
114 
118  private slots: void OnTopicChanged(int _index);
119 
121  protected: QFrame *frame;
122 
125 
128 
130  protected: std::string msgTypeName;
131 
133  private: TopicCombo *topicCombo;
134 
136  private: common::Time prevTime;
137 
139  private: common::Time prevDisplayTime;
140 
142  private: QLineEdit *hzEdit;
143 
145  private: double hz;
146 
148  private: QLineEdit *bandwidthEdit;
149 
151  private: std::list<int> msgSizes;
152 
154  private: std::list<common::Time> times;
155 
157  private: std::list<common::Time> dataTimes;
158 
160  private: boost::mutex updateMutex;
161  };
162  }
163 }
164 #endif
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:48
Forward declarations for transport.
transport::NodePtr node
Pointer to the node for communication.
Definition: TopicView.hh:127
transport::SubscriberPtr sub
Pointer to the topic subscriber that receives display data.
Definition: TopicView.hh:124
std::string msgTypeName
Typename of the messages that can be displayed.
Definition: TopicView.hh:130
Base class for widgets that display topic data.
Definition: TopicView.hh:76
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:52
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
QFrame * frame
This is the frame that each child class should populate.
Definition: TopicView.hh:121
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43