Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/network/monitor/network_stats_widget.h @ 9690

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

some network-stuff

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  NewObjectListDeclaration(HostWidget);
23  public:
24    HostWidget(const std::string& name, const IP& ip);
25    HostWidget(const PeerInfo* peerInfo);
26
27    void setName(const std::string& name) { this->_name.setText(name); };
28    void setIP(const IP& ip) { this->_ip.setText(std::string("at ") + ip.ipString()); this->_storedIP = ip; };
29
30    void setNameWidth(float width) { this->_name.setLineWidth(width); };
31
32    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
33    bool operator==(const std::string& name) const { return (this->_name == name); };
34
35  protected:
36    virtual void showing();
37    virtual void hiding();
38
39  private:
40    void init();
41  private:
42    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
43    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
44    IP                _storedIP;       //!< The ip to compare.
45
46    static Font*      _font;
47};
48
49
50class NodeWidget : public OrxGui::GLGuiBox
51{
52  public:
53    NodeWidget(const std::string& proxyName, const IP& ip);
54    NodeWidget(const NetworkNode* node);
55
56    void addNode(const NetworkNode* node);
57    void addNode(const std::string& name, const IP& ip);
58
59    bool removeNode(const IP& ip);
60    bool removeNode(const std::string& name);
61    bool removeNode(const std::string& name, const IP& ip);
62
63    void setNodeNameWidths(float width);
64
65
66  protected:
67    virtual void hiding();
68    virtual void showing();
69
70
71  private:
72    HostWidget                _proxyWidget;
73
74    std::vector<NodeWidget*>  _nodes;
75    float                     _nodeNameWidth;
76};
77
78
79
80
81//! A class to display network Statistics.
82class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
83{
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.