Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

nicer proxy

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