Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/monitor/network_stats_widget.h @ 9869

Last change on this file since 9869 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.2 KB
Line 
1/*!
2 * @file network_stats_widget.h
3 * @brief Definition of an EnergyWidget, that displays a bar and a Text
4 */
5
6#ifndef _NETWORK_STATS_WIDGET_H
7#define _NETWORK_STATS_WIDGET_H
8
9#include "glgui_fixedposition_box.h"
10#include "glgui_bar.h"
11#include "glgui_text.h"
12#include "glgui_pushbutton.h"
13
14#include "network/ip.h"
15
16class NetworkMonitor;
17class NetworkNode;
18class PeerInfo;
19
20class HostWidget : public OrxGui::GLGuiBox
21{
22  public:
23    HostWidget(const std::string& name, const IP& ip);
24    HostWidget(const PeerInfo* peerInfo);
25
26    void setName(const std::string& name) { this->_name.setText(name); };
27    void setIP(const IP& ip) { this->_ip.setText(std::string("at ") + ip.ipString()); this->_storedIP = ip; };
28
29    void setNameWidth(float width) { this->_name.setLineWidth(width); };
30
31    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
32    bool operator==(const std::string& name) const { return (this->_name == name); };
33
34  protected:
35    virtual void showing();
36    virtual void hiding();
37
38  private:
39    void init();
40  private:
41    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
42    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
43    IP                _storedIP;       //!< The ip to compare.
44
45    static Font*      _font;
46};
47
48
49class NodeWidget : public OrxGui::GLGuiBox
50{
51  public:
52    NodeWidget(const std::string& proxyName, const IP& ip);
53    NodeWidget(const NetworkNode* node);
54
55    void addNode(const NetworkNode* node);
56    void addNode(const std::string& name, const IP& ip);
57
58    bool removeNode(const IP& ip);
59    bool removeNode(const std::string& name);
60    bool removeNode(const std::string& name, const IP& ip);
61
62    void setNodeNameWidths(float width);
63
64
65  protected:
66    virtual void hiding();
67    virtual void showing();
68
69
70  private:
71    HostWidget                _proxyWidget;
72
73    std::vector<NodeWidget*>  _nodes;
74    float                     _nodeNameWidth;
75};
76
77
78
79
80//! A class to display network Statistics.
81class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
82{
83  ObjectListDeclaration(NetworkStatsWidget);
84  public:
85    static void toggleGUI();
86
87    NetworkStatsWidget(const NetworkMonitor* monitor);
88    virtual ~NetworkStatsWidget();
89
90    void setUpstream(unsigned int upstream);
91    void setDownstream(unsigned int upstream);
92    void setIP(const IP& ip);
93
94
95
96    void addProxy(const std::string& name, const IP& proxy);
97    void addNode(const NetworkNode* node);
98
99    void clearProxies();
100
101    void rebuild();
102
103    //void rebuildConnectedHosts(std::vector<hosts> hosts);
104
105    void setMaximum(float max);
106    void setValue(float value);
107
108    virtual void tick(float dt);
109
110  protected:
111    virtual void resize();
112    virtual void showing();
113    virtual void hiding();
114
115  private:
116    const NetworkMonitor*  _monitor;
117
118    OrxGui::GLGuiText      _thisHostIs;
119    HostWidget             _thisHost;
120
121    OrxGui::GLGuiText      _upstreamText;
122    OrxGui::GLGuiText      _downstreamText;
123
124    OrxGui::GLGuiBox       _serverBox;
125
126    std::vector<NodeWidget*> _proxies;
127
128
129    static NetworkStatsWidget*    _statsWidget;
130
131
132    float                   _passedTime;
133    //OrxGui::GLGuiText       _valueText;
134    //OrxGui::GLGuiBar        _bar;
135};
136
137#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.