Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

prevents the gui to act in the SHELL mode

File size: 3.0 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;
18
19
20class HostWidget : public OrxGui::GLGuiBox
21{
22  public:
23    HostWidget(const std::string& name, const IP& ip);
24
25    void setName(const std::string& name) { this->_name.setText(name); };
26    void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; };
27
28    void setNameWidth(float width) { this->_name.setLineWidth(width); };
29
30    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
31    bool operator==(const std::string& name) const { return (this->_name == name); };
32
33  protected:
34    virtual void showing();
35    virtual void hiding();
36
37  private:
38    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
39    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
40    IP                _storedIP;       //!< The ip to compare.
41};
42
43
44class ProxyWidget : public OrxGui::GLGuiBox
45{
46  public:
47    ProxyWidget(const std::string& proxyName, const IP& ip);
48
49    void addClient(const NetworkNode* node);
50    void addClient(const std::string& name, const IP& ip);
51
52    bool removeClient(const IP& ip);
53    bool removeClient(const std::string& name);
54    bool removeClient(const std::string& name, const IP& ip);
55
56    void setClientNameWidths(float width);
57
58
59  protected:
60    virtual void hiding();
61    virtual void showing();
62
63
64  private:
65    HostWidget                _proxyWidget;
66
67    std::vector<HostWidget*>  _clients;
68    float                     _clientNameWidth;
69};
70
71
72
73
74//! A class to display network Statistics.
75class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
76{
77  public:
78    static void toggleGUI();
79
80    NetworkStatsWidget(const NetworkMonitor* monitor);
81    virtual ~NetworkStatsWidget();
82
83    void setUpstream(unsigned int upstream);
84    void setDownstream(unsigned int upstream);
85    void setIP(const IP& ip);
86
87
88
89    void addProxy(const std::string& name, const IP& proxy);
90    void clearProxies();
91
92    void rebuild();
93
94    //void rebuildConnectedHosts(std::vector<hosts> hosts);
95
96    void setMaximum(float max);
97    void setValue(float value);
98
99    virtual void tick(float dt);
100
101  protected:
102    virtual void resize();
103    virtual void showing();
104    virtual void hiding();
105
106  private:
107    const NetworkMonitor*  _monitor;
108
109    OrxGui::GLGuiText      _thisHostIs;
110    HostWidget             _thisHost;
111
112    OrxGui::GLGuiText      _upstreamText;
113    OrxGui::GLGuiText      _downstreamText;
114
115    OrxGui::GLGuiWidget    _serverBox;
116
117    std::vector<HostWidget*> _proxies;
118
119
120    OrxGui::GLGuiPushButton _refreshButton;
121
122    static NetworkStatsWidget*    _statsWidget;
123
124    //OrxGui::GLGuiText       _valueText;
125    //OrxGui::GLGuiBar        _bar;
126};
127
128#endif /* _NETWORK_STATS_WIDGET_H */
Note: See TracBrowser for help on using the repository browser.