Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the proxy bache back with no conflicts

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
[9656]4 */
[1853]5
[9330]6#ifndef _NETWORK_STATS_WIDGET_H
7#define _NETWORK_STATS_WIDGET_H
[1853]8
[9656]9#include "glgui_fixedposition_box.h"
[8972]10#include "glgui_bar.h"
11#include "glgui_text.h"
[9656]12#include "glgui_pushbutton.h"
[1853]13
[9330]14#include "network/ip.h"
15
[9439]16class NetworkMonitor;
[9656]17class NetworkNode;
18class PeerInfo;
[9330]19
[9437]20class HostWidget : public OrxGui::GLGuiBox
[8972]21{
[9437]22  public:
23    HostWidget(const std::string& name, const IP& ip);
[9656]24    HostWidget(const PeerInfo* peerInfo);
[3543]25
[9437]26    void setName(const std::string& name) { this->_name.setText(name); };
[9656]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:
[9656]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.
[9656]44
45    static Font*      _font;
[9437]46};
[9383]47
48
[9656]49class NodeWidget : public OrxGui::GLGuiBox
[9437]50{
51  public:
[9656]52    NodeWidget(const std::string& proxyName, const IP& ip);
53    NodeWidget(const NetworkNode* node);
[9383]54
[9656]55    void addNode(const NetworkNode* node);
56    void addNode(const std::string& name, const IP& ip);
[9383]57
[9656]58    bool removeNode(const IP& ip);
59    bool removeNode(const std::string& name);
60    bool removeNode(const std::string& name, const IP& ip);
[9383]61
[9656]62    void setNodeNameWidths(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
[9656]73    std::vector<NodeWidget*>  _nodes;
74    float                     _nodeNameWidth;
[9437]75};
[9383]76
77
78
79
[9437]80//! A class to display network Statistics.
[9656]81class NetworkStatsWidget : public OrxGui::GLGuiFixedpositionBox
[9437]82{
83  public:
[9656]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);
[9656]96    void addNode(const NetworkNode* node);
[8974]97
[9656]98    void clearProxies();
[9386]99
[9656]100    void rebuild();
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
[9656]117    OrxGui::GLGuiText      _thisHostIs;
[9437]118    HostWidget             _thisHost;
[9331]119
[9437]120    OrxGui::GLGuiText      _upstreamText;
121    OrxGui::GLGuiText      _downstreamText;
[1853]122
[9656]123    OrxGui::GLGuiBox       _serverBox;
[1853]124
[9656]125    std::vector<NodeWidget*> _proxies;
[9330]126
127
[9656]128    static NetworkStatsWidget*    _statsWidget;
129
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.