Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/monitor/network_stats_widget.h @ 9642

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

node-widget

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 addClient(const NetworkNode* node);
56    void addClient(const std::string& name, const IP& ip);
57
58    bool removeClient(const IP& ip);
59    bool removeClient(const std::string& name);
60    bool removeClient(const std::string& name, const IP& ip);
61
62    void setClientNameWidths(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<HostWidget*>  _clients;
74    float                     _clientNameWidth;
75};
76
77
78
79
80//! A class to display network Statistics.
81class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
82{
83  public:
84    static void toggleGUI();
85
86    NetworkStatsWidget(const NetworkMonitor* monitor);
87    virtual ~NetworkStatsWidget();
88
89    void setUpstream(unsigned int upstream);
90    void setDownstream(unsigned int upstream);
91    void setIP(const IP& ip);
92
93
94
95    void addProxy(const std::string& name, const IP& proxy);
96    void addNode(const NetworkNode* node);
97
98    void clearProxies();
99
100    void rebuild();
101
102    //void rebuildConnectedHosts(std::vector<hosts> hosts);
103
104    void setMaximum(float max);
105    void setValue(float value);
106
107    virtual void tick(float dt);
108
109  protected:
110    virtual void resize();
111    virtual void showing();
112    virtual void hiding();
113
114  private:
115    const NetworkMonitor*  _monitor;
116
117    OrxGui::GLGuiText      _thisHostIs;
118    HostWidget             _thisHost;
119
120    OrxGui::GLGuiText      _upstreamText;
121    OrxGui::GLGuiText      _downstreamText;
122
123    OrxGui::GLGuiWidget    _serverBox;
124
125    std::vector<NodeWidget*> _proxies;
126
127
128    OrxGui::GLGuiPushButton _refreshButton;
129
130    static NetworkStatsWidget*    _statsWidget;
131
132
133    float                   _passedTime;
134    //OrxGui::GLGuiText       _valueText;
135    //OrxGui::GLGuiBar        _bar;
136};
137
138#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.