Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9437 in orxonox.OLD


Ignore:
Timestamp:
Jul 24, 2006, 4:55:41 PM (18 years ago)
Author:
bensch
Message:

movements

Location:
branches/proxy/src
Files:
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/Makefile.am

    r9406 r9437  
    2828                      proxy/network_settings.cc \
    2929                      \
    30                                   monitor/connection_monitor.cc \
     30                      monitor/connection_monitor.cc \
    3131                      monitor/network_monitor.cc \
    3232                      monitor/network_node.cc \
     33                      monitor/network_stats_widget.cc \
    3334                      \
    3435                      synchronizeable_var/synchronizeable_var.cc \
     
    7778                proxy/network_settings.cc \
    7879                \
    79                 monitor/connection_monitor.h \
    80                 monitor/network_monitor.h \
    81                 monitor/network_node.h \
     80                monitor/connection_monitor.h \
     81                monitor/network_monitor.h \
     82                monitor/network_node.h \
     83                monitor/network_stats_widget.h \
    8284                \
    8385                synchronizeable_var/synchronizeable_var.h \
  • branches/proxy/src/lib/network/monitor/network_stats_widget.cc

    r9435 r9437  
    2323//#include "network_monitor.h"
    2424
    25 namespace OrxGui
    26 {
    27   SHELL_COMMAND(gui, NetworkStatsWidget, gui);
    28 
    29 
    30   HostWidget::HostWidget(const std::string& name, const IP& ip)
    31       : GLGuiBox(Horizontal)
     25SHELL_COMMAND(gui, NetworkStatsWidget, gui);
     26
     27
     28HostWidget::HostWidget(const std::string& name, const IP& ip)
     29  : GLGuiBox(OrxGui::Horizontal)
     30{
     31  this->setName(name);
     32  this->setIP(ip);
     33
     34  this->pack(&this->_name);
     35  this->pack(&this->_ip);
     36}
     37
     38void HostWidget::showing()
     39{
     40  this->_name.show();
     41  this->_ip.show();
     42}
     43
     44void HostWidget::hiding()
     45{
     46  this->_name.hide();
     47  this->_ip.hide();
     48}
     49
     50
     51
     52//======================================================//
     53
     54
     55ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
     56    : _proxyWidget(proxyName, ip)
     57{
     58  this->_clientNameWidth = 100.0f;
     59  this->pack(&_proxyWidget);
     60}
     61
     62void ProxyWidget::addClient(const std::string& name, const IP& ip)
     63{
     64  HostWidget* newClient = new HostWidget(name, ip);
     65  newClient->setNameWidth(this->_clientNameWidth);
     66
     67  this->pack(newClient);
     68
     69  if (this->isVisible())
     70    newClient->show();
     71}
     72
     73bool ProxyWidget::removeClient(const IP& ip)
     74{
     75  std::vector<HostWidget*>::iterator rmIt;
     76  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    3277  {
    33     this->setName(name);
    34     this->setIP(ip);
    35 
    36     this->pack(&this->_name);
    37     this->pack(&this->_ip);
     78    if (*(*rmIt) == ip)
     79    {
     80      delete (*rmIt);
     81      this->_clients.erase(rmIt);
     82      return true;
     83    }
    3884  }
    39 
    40   void HostWidget::showing()
     85  return false;
     86}
     87
     88bool ProxyWidget::removeClient(const std::string& name)
     89{
     90  std::vector<HostWidget*>::iterator rmIt;
     91  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    4192  {
    42     this->_name.show();
    43     this->_ip.show();
     93    if (*(*rmIt) == name)
     94    {
     95      delete (*rmIt);
     96      this->_clients.erase(rmIt);
     97      return true;
     98    }
    4499  }
    45 
    46   void HostWidget::hiding()
     100  return false;
     101
     102}
     103
     104bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
     105{
     106  std::vector<HostWidget*>::iterator rmIt;
     107  for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    47108  {
    48     this->_name.hide();
    49     this->_ip.hide();
     109    if (*(*rmIt) == ip && *(*rmIt) == name)
     110    {
     111      delete (*rmIt);
     112      this->_clients.erase(rmIt);
     113      return true;
     114    }
    50115  }
    51 
    52 
    53 
    54   //======================================================//
    55 
    56 
    57   ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
    58   : _proxyWidget(proxyName, ip)
    59   {
    60     this->_clientNameWidth = 100.0f;
    61     this->pack(&_proxyWidget);
    62   }
    63 
    64   void ProxyWidget::addClient(const std::string& name, const IP& ip)
    65   {
    66     HostWidget* newClient = new HostWidget(name, ip);
    67     newClient->setNameWidth(this->_clientNameWidth);
    68 
    69     this->pack(newClient);
    70 
    71     if (this->isVisible())
    72       newClient->show();
    73   }
    74 
    75   bool ProxyWidget::removeClient(const IP& ip)
    76   {
    77     std::vector<HostWidget*>::iterator rmIt;
    78     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    79     {
    80       if (*(*rmIt) == ip)
    81       {
    82         delete (*rmIt);
    83         this->_clients.erase(rmIt);
    84         return true;
    85       }
    86     }
    87     return false;
    88   }
    89 
    90   bool ProxyWidget::removeClient(const std::string& name)
    91   {
    92     std::vector<HostWidget*>::iterator rmIt;
    93     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    94     {
    95       if (*(*rmIt) == name)
    96       {
    97         delete (*rmIt);
    98         this->_clients.erase(rmIt);
    99         return true;
    100       }
    101     }
    102     return false;
    103 
    104   }
    105 
    106   bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
    107   {
    108     std::vector<HostWidget*>::iterator rmIt;
    109     for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
    110     {
    111       if (*(*rmIt) == ip && *(*rmIt) == name)
    112       {
    113         delete (*rmIt);
    114         this->_clients.erase(rmIt);
    115         return true;
    116       }
    117     }
    118     return false;
    119   }
    120 
    121 
    122   void ProxyWidget::setClientNameWidths(float width)
    123   {
    124     this->_clientNameWidth = width;
    125     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    126       this->_clients[i]->setNameWidth(width);
    127   }
    128 
    129   void ProxyWidget::hiding()
    130   {
    131     this->_proxyWidget.hide();
    132     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    133       this->_clients[i]->hide();
    134   }
    135 
    136   void ProxyWidget::showing()
    137   {
    138     this->_proxyWidget.show();
    139     for (unsigned int i = 0; i < this->_clients.size(); ++i)
    140       this->_clients[i]->show();
    141   }
    142 
    143 
    144   //======================================================//
    145 
    146 
    147   void NetworkStatsWidget::gui()
    148   {
    149     printf("YEAH\n");
    150   }
    151 
    152 
    153   /**
    154    * @brief standard constructor
    155    */
    156   NetworkStatsWidget::NetworkStatsWidget ()
    157   : GLGuiBox(Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
    158   {
    159     //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
    160 
    161     this->_bar.setSize2D(100, 30);
    162     this->pack(&this->_valueText);
    163     this->_bar.setParent2D(&this->_valueText);
    164 
    165     this->_valueText.setChangedTextColor(Color::white);
    166 
    167     //this->setBackgroundTexture("maps/gui_element_background_2.png");
    168     this->setBackgroundColor(Color(.5,.5,.5,1));
    169 
    170     //this->_name.setBackgroundTexture(Texture());
    171     //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
    172     this->_bar.setBackgroundTexture(Texture());
    173     this->_bar.setBackgroundColor(Color(0,0,0,0));
    174     this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
    175     this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
    176     this->_bar.setChangedValueColor(Color::black);
    177   }
    178 
    179 
    180   /**
    181    * @brief standard deconstructor
    182    */
    183   NetworkStatsWidget::~NetworkStatsWidget ()
    184   {}
    185 
    186 
    187   void NetworkStatsWidget::setMaximum(float max)
    188   {
    189     this->_bar.setMaximum(max);
    190   }
    191 
    192   void NetworkStatsWidget::setValue(float value)
    193   {
    194     MultiType val(value);
    195     val.setType(MT_INT);
    196 
    197 
    198     this->_bar.setValue(value);
    199     this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
    200     this->_bar.setFrontColor(Color(1,1,1,1), true);
    201     this->_valueText.setText(val.getString());
    202   }
    203 
    204   void NetworkStatsWidget::resize()
    205   {
    206     GLGuiBox::resize();
    207   }
    208 
    209 
    210   void NetworkStatsWidget::showing()
    211   {
    212     this->_valueText.show();
    213     this->_bar.show();
    214   }
    215 
    216   void NetworkStatsWidget::hiding()
    217   {
    218     this->_valueText.hide();
    219     this->_bar.hide();
    220   }
    221 }
     116  return false;
     117}
     118
     119
     120void ProxyWidget::setClientNameWidths(float width)
     121{
     122  this->_clientNameWidth = width;
     123  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     124    this->_clients[i]->setNameWidth(width);
     125}
     126
     127void ProxyWidget::hiding()
     128{
     129  this->_proxyWidget.hide();
     130  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     131    this->_clients[i]->hide();
     132}
     133
     134void ProxyWidget::showing()
     135{
     136  this->_proxyWidget.show();
     137  for (unsigned int i = 0; i < this->_clients.size(); ++i)
     138    this->_clients[i]->show();
     139}
     140
     141
     142//======================================================//
     143
     144
     145void NetworkStatsWidget::gui()
     146{
     147  printf("YEAH\n");
     148}
     149
     150
     151/**
     152 * @brief standard constructor
     153 */
     154NetworkStatsWidget::NetworkStatsWidget ()
     155  : GLGuiBox(OrxGui::Vertical), _thisHost("myName", IP(127, 0, 0 , 0))
     156{
     157  //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
     158
     159  this->_bar.setSize2D(100, 30);
     160  this->pack(&this->_valueText);
     161  this->_bar.setParent2D(&this->_valueText);
     162
     163  this->_valueText.setChangedTextColor(Color::white);
     164
     165  //this->setBackgroundTexture("maps/gui_element_background_2.png");
     166  this->setBackgroundColor(Color(.5,.5,.5,1));
     167
     168  //this->_name.setBackgroundTexture(Texture());
     169  //this->_valueText.setBackgroundTexture("maps/gui_element_background_2.png");
     170  this->_bar.setBackgroundTexture(Texture());
     171  this->_bar.setBackgroundColor(Color(0,0,0,0));
     172  this->_bar.setForegroundTexture("maps/gui_element_background_faded.png");
     173  this->_bar.setForegroundColor(Color(.5, .5, .5, 1));
     174  this->_bar.setChangedValueColor(Color::black);
     175}
     176
     177
     178/**
     179 * @brief standard deconstructor
     180 */
     181NetworkStatsWidget::~NetworkStatsWidget ()
     182{}
     183
     184
     185void NetworkStatsWidget::setMaximum(float max)
     186{
     187  this->_bar.setMaximum(max);
     188}
     189
     190void NetworkStatsWidget::setValue(float value)
     191{
     192  MultiType val(value);
     193  val.setType(MT_INT);
     194
     195
     196  this->_bar.setValue(value);
     197  this->_bar.setForegroundColor(Color::slerpHSVColor(Color::red, Color::green, value/this->_bar.maximum()));
     198  this->_bar.setFrontColor(Color(1,1,1,1), true);
     199  this->_valueText.setText(val.getString());
     200}
     201
     202void NetworkStatsWidget::resize()
     203{
     204  GLGuiBox::resize();
     205}
     206
     207
     208void NetworkStatsWidget::showing()
     209{
     210  this->_valueText.show();
     211  this->_bar.show();
     212}
     213
     214void NetworkStatsWidget::hiding()
     215{
     216  this->_valueText.hide();
     217  this->_bar.hide();
     218}
  • branches/proxy/src/lib/network/monitor/network_stats_widget.h

    r9435 r9437  
    1414
    1515
    16 namespace OrxGui
     16
     17class HostWidget : public OrxGui::GLGuiBox
    1718{
     19  public:
     20    HostWidget(const std::string& name, const IP& ip);
     21    ~HostWidget() {};
    1822
    19   class HostWidget : public GLGuiBox
    20   {
    21     public:
    22       HostWidget(const std::string& name, const IP& ip);
    23       ~HostWidget() {};
     23    void setName(const std::string& name) { this->_name.setText(name); };
     24    void setIP(const IP& ip) { this->_ip.setText(ip.ipString()); this->_storedIP = ip; };
    2425
    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; };
     26    void setNameWidth(float width) { this->_name.setLineWidth(width); };
    2727
    28       void setNameWidth(float width) { this->_name.setLineWidth(width); };
     28    bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
     29    bool operator==(const std::string& name) const { return (this->_name == name); };
    2930
    30       bool operator==(const IP& ip) const { return (this->_storedIP == ip); };
    31       bool operator==(const std::string& name) const { return (this->_name == name); };
     31  protected:
     32    virtual void showing();
     33    virtual void hiding();
    3234
    33     protected:
    34       virtual void showing();
    35       virtual void hiding();
    36 
    37     private:
    38       GLGuiText        _name;           //!< The Name of the Proxy server to be displayed.
    39       GLGuiText        _ip;             //!< The IP of the proxy server.
    40       IP               _storedIP;       //!< The ip to compare.
    41   };
     35  private:
     36    OrxGui::GLGuiText _name;           //!< The Name of the Proxy server to be displayed.
     37    OrxGui::GLGuiText _ip;             //!< The IP of the proxy server.
     38    IP                _storedIP;       //!< The ip to compare.
     39};
    4240
    4341
    44   class ProxyWidget : public GLGuiBox
    45   {
    46     public:
    47       ProxyWidget(const std::string& proxyName, const IP& ip);
     42class ProxyWidget : public OrxGui::GLGuiBox
     43{
     44  public:
     45    ProxyWidget(const std::string& proxyName, const IP& ip);
    4846
    49       void addClient(const std::string& name, const IP& ip);
     47    void addClient(const std::string& name, const IP& ip);
    5048
    51       bool removeClient(const IP& ip);
    52       bool removeClient(const std::string& name);
    53       bool removeClient(const std::string& name, const IP& ip);
     49    bool removeClient(const IP& ip);
     50    bool removeClient(const std::string& name);
     51    bool removeClient(const std::string& name, const IP& ip);
    5452
    55       void setClientNameWidths(float width);
     53    void setClientNameWidths(float width);
    5654
    5755
    58     protected:
    59       virtual void hiding();
    60       virtual void showing();
     56  protected:
     57    virtual void hiding();
     58    virtual void showing();
    6159
    6260
    63     private:
    64       HostWidget                _proxyWidget;
     61  private:
     62    HostWidget                _proxyWidget;
    6563
    66       std::vector<HostWidget*>  _clients;
    67       float                     _clientNameWidth;
    68   };
     64    std::vector<HostWidget*>  _clients;
     65    float                     _clientNameWidth;
     66};
    6967
    7068
    7169
    7270
    73   //! A class to display network Statistics.
    74   class NetworkStatsWidget : public GLGuiBox
    75   {
    76     public:
    77       static void gui();
     71//! A class to display network Statistics.
     72class NetworkStatsWidget : public OrxGui::GLGuiBox
     73{
     74  public:
     75    void gui();
    7876
    79     public:
    80       NetworkStatsWidget();
    81       virtual ~NetworkStatsWidget();
     77  public:
     78    NetworkStatsWidget();
     79    virtual ~NetworkStatsWidget();
    8280
    83       void setUpstream(unsigned int upstream);
    84       void setDownstream(unsigned int upstream);
    85       void setIP(const IP& ip);
     81    void setUpstream(unsigned int upstream);
     82    void setDownstream(unsigned int upstream);
     83    void setIP(const IP& ip);
    8684
    8785
    8886
    89       void addProxy(const std::string& name, const IP& proxy);
     87    void addProxy(const std::string& name, const IP& proxy);
    9088
    9189
    92       //void rebuildConnectedHosts(std::vector<hosts> hosts);
     90    //void rebuildConnectedHosts(std::vector<hosts> hosts);
    9391
    94       void setMaximum(float max);
    95       void setValue(float value);
     92    void setMaximum(float max);
     93    void setValue(float value);
    9694
    97     protected:
    98       virtual void resize();
    99       virtual void showing();
    100       virtual void hiding();
     95  protected:
     96    virtual void resize();
     97    virtual void showing();
     98    virtual void hiding();
    10199
    102     private:
    103       HostWidget             _thisHost;
     100  private:
     101    HostWidget             _thisHost;
    104102
    105       GLGuiText              _upstreamText;
    106       GLGuiText              _downstreamText;
     103    OrxGui::GLGuiText      _upstreamText;
     104    OrxGui::GLGuiText      _downstreamText;
    107105
    108       std::vector<HostWidget*>_connectedProxies;
     106    std::vector<HostWidget*>_connectedProxies;
    109107
    110       GLGuiText              _serverIP;
     108    OrxGui::GLGuiText       _serverIP;
    111109
    112110
    113       GLGuiText              _valueText;
    114       GLGuiBar               _bar;
    115   };
    116 }
     111    OrxGui::GLGuiText       _valueText;
     112    OrxGui::GLGuiBar        _bar;
     113};
     114
    117115#endif /* _NETWORK_STATS_WIDGET_H */
  • branches/proxy/src/util/Makefile.am

    r9406 r9437  
    2626                        animation/animation_player.cc \
    2727                        \
    28                         track/pilot_node.cc \
    29                         \
    30                         network_stats_widget.cc
     28                        track/pilot_node.cc
    3129
    3230#                       track/track_manager.cc \
     
    5452                        animation/t_animation.h \
    5553                        \
    56                         track/pilot_node.h \
    57                         \
    58                         network_stats_widget.h
    59 
     54                        track/pilot_node.h
    6055
    6156#                       track/track_manager.h \
Note: See TracChangeset for help on using the changeset viewer.