Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9383 in orxonox.OLD


Ignore:
Timestamp:
Jul 21, 2006, 12:51:19 PM (18 years ago)
Author:
bensch
Message:

much more elaborate host and proxy widgets

Location:
branches/proxy/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/gui/gl/glgui_text.h

    r9369 r9383  
    3333    void setChangedTextColor(const Color& color);
    3434
     35    void setLineWidth(float lineWidth) { this->_text.setLineWidth(lineWidth); };
    3536    void setDotsPosition(LimitedWidthText::DotsPosition dotsPosition) { this->_text.setDotsPosition(dotsPosition); };
    3637
  • branches/proxy/src/lib/network/ip.cc

    r9360 r9383  
    130130 * @return true if ip _and_ port match.
    131131 */
    132 bool IP::operator==(const IP& ip)
     132bool IP::operator==(const IP& ip) const
    133133{
    134134  return (this->_ip == ip.host() &&
     
    140140 * @brief comparison operator
    141141 * @param ip the IP to compare
    142  * @return true if ip _and_ port do not match.
    143  */
    144 bool IP::operator!=(const IP& ip)
     142 * @return true if ip _or_ port do not match.
     143 */
     144bool IP::operator!=(const IP& ip) const
    145145{
    146146  return (this->_ip != ip.host() ||
  • branches/proxy/src/lib/network/ip.h

    r9360 r9383  
    3030    const IP& operator=(const IP& ip);
    3131    const IP& operator=(const IPaddress& ip);
    32     bool operator==(const IP& ip);
    33     bool operator!=(const IP& up);
     32    bool operator==(const IP& ip) const;
     33    bool operator!=(const IP& up) const;
    3434
    3535    /// RETRIVEAL
  • branches/proxy/src/util/network_stats_widget.cc

    r9369 r9383  
    2222namespace OrxGui
    2323{
     24  HostWidget::HostWidget(const std::string& name, const IP& ip)
     25      : GLGuiBox(Horizontal)
     26  {
     27    this->setName(name);
     28    this->setIP(ip);
     29
     30    this->pack(&this->_name);
     31    this->pack(&this->_ip);
     32  }
     33
     34  void HostWidget::showing()
     35  {
     36    this->_name.show();
     37    this->_ip.show();
     38  }
     39
     40  void HostWidget::hiding()
     41  {
     42    this->_name.hide();
     43    this->_ip.hide();
     44  }
     45
     46
     47
     48  //======================================================//
     49
     50
     51  ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip)
     52  : _proxyWidget(proxyName, ip)
     53  {
     54    this->pack(&_proxyWidget);
     55  }
     56
     57  void ProxyWidget::addClient(const std::string& name, const IP& ip)
     58  {
     59    HostWidget* newClient = new HostWidget(name, ip);
     60
     61    this->pack(newClient);
     62
     63    if (this->isVisible())
     64      newClient->show();
     65  }
     66
     67  bool ProxyWidget::removeClient(const IP& ip)
     68  {
     69    std::vector<HostWidget*>::iterator rmIt;
     70    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
     71    {
     72      if (*(*rmIt) == ip)
     73      {
     74        delete (*rmIt);
     75        this->_clients.erase(rmIt);
     76        return true;
     77      }
     78    }
     79    return false;
     80  }
     81
     82  bool ProxyWidget::removeClient(const std::string& name)
     83  {
     84    std::vector<HostWidget*>::iterator rmIt;
     85    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
     86    {
     87      if (*(*rmIt) == name)
     88      {
     89        delete (*rmIt);
     90        this->_clients.erase(rmIt);
     91        return true;
     92      }
     93    }
     94    return false;
     95
     96  }
     97
     98  bool ProxyWidget::removeClient(const std::string& name, const IP& ip)
     99  {
     100    std::vector<HostWidget*>::iterator rmIt;
     101    for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt)
     102    {
     103      if (*(*rmIt) == ip && *(*rmIt) == name)
     104      {
     105        delete (*rmIt);
     106        this->_clients.erase(rmIt);
     107        return true;
     108      }
     109    }
     110    return false;
     111  }
     112
     113
     114  void ProxyWidget::hiding()
     115  {
     116    this->_proxyWidget.hide();
     117    for (unsigned int i = 0; i < this->_clients.size(); ++i)
     118      this->_clients[i]->hide();
     119  }
     120
     121  void ProxyWidget::showing()
     122  {
     123    this->_proxyWidget.show();
     124    for (unsigned int i = 0; i < this->_clients.size(); ++i)
     125      this->_clients[i]->show();
     126  }
     127
     128
     129  //======================================================//
     130
     131
     132
    24133  /**
    25134   * @brief standard constructor
    26135   */
    27136  NetworkStatsWidget::NetworkStatsWidget ()
     137      : GLGuiBox(Vertical)
    28138  {
    29139    //   this->setClassID(CL_PROTO_ID, "NetworkStatsWidget");
     
    52162   */
    53163  NetworkStatsWidget::~NetworkStatsWidget ()
    54   {
    55   }
     164  {}
    56165
    57166
  • branches/proxy/src/util/network_stats_widget.h

    r9347 r9383  
    1717{
    1818
     19  class HostWidget : public GLGuiBox
     20  {
     21    public:
     22      HostWidget(const std::string& name, const IP& ip);
     23      ~HostWidget() {};
     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      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  };
     42
     43
     44  class ProxyWidget : public GLGuiBox
     45  {
     46    public:
     47      ProxyWidget(const std::string& proxyName, const IP& ip);
     48
     49      void addClient(const std::string& name, const IP& ip);
     50
     51      bool removeClient(const IP& ip);
     52      bool removeClient(const std::string& name);
     53      bool removeClient(const std::string& name, const IP& ip);
     54
     55
     56    protected:
     57      virtual void hiding();
     58      virtual void showing();
     59
     60
     61    private:
     62      HostWidget       _proxyWidget;
     63
     64      std::vector<HostWidget*>  _clients;
     65  };
     66
     67
     68
     69
    1970  //! A class to display network Statistics.
    2071  class NetworkStatsWidget : public GLGuiBox
    2172  {
     73    public:
     74      NetworkStatsWidget();
     75      virtual ~NetworkStatsWidget();
    2276
    23   public:
    24     NetworkStatsWidget();
    25     virtual ~NetworkStatsWidget();
    26 
    27     void setUpstream(unsigned int upstream);
    28     void setDownstream(unsigned int upstream);
    29     void setIP(const IP& ip);
     77      void setUpstream(unsigned int upstream);
     78      void setDownstream(unsigned int upstream);
     79      void setIP(const IP& ip);
    3080
    3181
    3282
    33     //void rebuildConnectedHosts(std::vector<hosts> hosts);
     83      //void rebuildConnectedHosts(std::vector<hosts> hosts);
    3484
    35     void setMaximum(float max);
    36     void setValue(float value);
     85      void setMaximum(float max);
     86      void setValue(float value);
    3787
    38   protected:
    39     virtual void resize();
    40     virtual void showing();
    41     virtual void hiding();
     88    protected:
     89      virtual void resize();
     90      virtual void showing();
     91      virtual void hiding();
    4292
    43   private:
    44     IP                     _ip;
    45     GLGuiText              _ipText;
     93    private:
     94      IP                     _ip;
     95      GLGuiText              _ipText;
    4696
    47     GLGuiText              _upstreamText;
    48     GLGuiText              _downstreamText;
     97      GLGuiText              _upstreamText;
     98      GLGuiText              _downstreamText;
    4999
    50     std::vector<GLGuiText> _connectedHosts;
     100      std::vector<GLGuiText> _connectedHosts;
    51101
    52     GLGuiText              _serverIP;
     102      GLGuiText              _serverIP;
    53103
    54104
    55     GLGuiText              _valueText;
    56     GLGuiBar               _bar;
     105      GLGuiText              _valueText;
     106      GLGuiBar               _bar;
    57107  };
    58108}
Note: See TracChangeset for help on using the changeset viewer.