Changeset 9437 in orxonox.OLD for branches/proxy
- Timestamp:
- Jul 24, 2006, 4:55:41 PM (18 years ago)
- Location:
- branches/proxy/src
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/Makefile.am
r9406 r9437 28 28 proxy/network_settings.cc \ 29 29 \ 30 30 monitor/connection_monitor.cc \ 31 31 monitor/network_monitor.cc \ 32 32 monitor/network_node.cc \ 33 monitor/network_stats_widget.cc \ 33 34 \ 34 35 synchronizeable_var/synchronizeable_var.cc \ … … 77 78 proxy/network_settings.cc \ 78 79 \ 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 \ 82 84 \ 83 85 synchronizeable_var/synchronizeable_var.h \ -
branches/proxy/src/lib/network/monitor/network_stats_widget.cc
r9435 r9437 23 23 //#include "network_monitor.h" 24 24 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) 25 SHELL_COMMAND(gui, NetworkStatsWidget, gui); 26 27 28 HostWidget::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 38 void HostWidget::showing() 39 { 40 this->_name.show(); 41 this->_ip.show(); 42 } 43 44 void HostWidget::hiding() 45 { 46 this->_name.hide(); 47 this->_ip.hide(); 48 } 49 50 51 52 //======================================================// 53 54 55 ProxyWidget::ProxyWidget(const std::string& proxyName, const IP& ip) 56 : _proxyWidget(proxyName, ip) 57 { 58 this->_clientNameWidth = 100.0f; 59 this->pack(&_proxyWidget); 60 } 61 62 void 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 73 bool ProxyWidget::removeClient(const IP& ip) 74 { 75 std::vector<HostWidget*>::iterator rmIt; 76 for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt) 32 77 { 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 } 38 84 } 39 40 void HostWidget::showing() 85 return false; 86 } 87 88 bool ProxyWidget::removeClient(const std::string& name) 89 { 90 std::vector<HostWidget*>::iterator rmIt; 91 for(rmIt = this->_clients.begin(); rmIt != this->_clients.end(); ++rmIt) 41 92 { 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 } 44 99 } 45 46 void HostWidget::hiding() 100 return false; 101 102 } 103 104 bool 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) 47 108 { 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 } 50 115 } 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 120 void 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 127 void 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 134 void 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 145 void NetworkStatsWidget::gui() 146 { 147 printf("YEAH\n"); 148 } 149 150 151 /** 152 * @brief standard constructor 153 */ 154 NetworkStatsWidget::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 */ 181 NetworkStatsWidget::~NetworkStatsWidget () 182 {} 183 184 185 void NetworkStatsWidget::setMaximum(float max) 186 { 187 this->_bar.setMaximum(max); 188 } 189 190 void 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 202 void NetworkStatsWidget::resize() 203 { 204 GLGuiBox::resize(); 205 } 206 207 208 void NetworkStatsWidget::showing() 209 { 210 this->_valueText.show(); 211 this->_bar.show(); 212 } 213 214 void NetworkStatsWidget::hiding() 215 { 216 this->_valueText.hide(); 217 this->_bar.hide(); 218 } -
branches/proxy/src/lib/network/monitor/network_stats_widget.h
r9435 r9437 14 14 15 15 16 namespace OrxGui 16 17 class HostWidget : public OrxGui::GLGuiBox 17 18 { 19 public: 20 HostWidget(const std::string& name, const IP& ip); 21 ~HostWidget() {}; 18 22 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; }; 24 25 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); }; 27 27 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); }; 29 30 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(); 32 34 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 }; 42 40 43 41 44 class ProxyWidget : publicGLGuiBox45 46 47 42 class ProxyWidget : public OrxGui::GLGuiBox 43 { 44 public: 45 ProxyWidget(const std::string& proxyName, const IP& ip); 48 46 49 47 void addClient(const std::string& name, const IP& ip); 50 48 51 52 53 49 bool removeClient(const IP& ip); 50 bool removeClient(const std::string& name); 51 bool removeClient(const std::string& name, const IP& ip); 54 52 55 53 void setClientNameWidths(float width); 56 54 57 55 58 59 60 56 protected: 57 virtual void hiding(); 58 virtual void showing(); 61 59 62 60 63 64 61 private: 62 HostWidget _proxyWidget; 65 63 66 67 68 64 std::vector<HostWidget*> _clients; 65 float _clientNameWidth; 66 }; 69 67 70 68 71 69 72 70 73 74 class NetworkStatsWidget : publicGLGuiBox75 76 77 staticvoid gui();71 //! A class to display network Statistics. 72 class NetworkStatsWidget : public OrxGui::GLGuiBox 73 { 74 public: 75 void gui(); 78 76 79 80 81 77 public: 78 NetworkStatsWidget(); 79 virtual ~NetworkStatsWidget(); 82 80 83 84 85 81 void setUpstream(unsigned int upstream); 82 void setDownstream(unsigned int upstream); 83 void setIP(const IP& ip); 86 84 87 85 88 86 89 87 void addProxy(const std::string& name, const IP& proxy); 90 88 91 89 92 90 //void rebuildConnectedHosts(std::vector<hosts> hosts); 93 91 94 95 92 void setMaximum(float max); 93 void setValue(float value); 96 94 97 98 99 100 95 protected: 96 virtual void resize(); 97 virtual void showing(); 98 virtual void hiding(); 101 99 102 103 100 private: 101 HostWidget _thisHost; 104 102 105 GLGuiText_upstreamText;106 GLGuiText_downstreamText;103 OrxGui::GLGuiText _upstreamText; 104 OrxGui::GLGuiText _downstreamText; 107 105 108 106 std::vector<HostWidget*>_connectedProxies; 109 107 110 GLGuiText_serverIP;108 OrxGui::GLGuiText _serverIP; 111 109 112 110 113 GLGuiText_valueText;114 GLGuiBar_bar;115 116 } 111 OrxGui::GLGuiText _valueText; 112 OrxGui::GLGuiBar _bar; 113 }; 114 117 115 #endif /* _NETWORK_STATS_WIDGET_H */ -
branches/proxy/src/util/Makefile.am
r9406 r9437 26 26 animation/animation_player.cc \ 27 27 \ 28 track/pilot_node.cc \ 29 \ 30 network_stats_widget.cc 28 track/pilot_node.cc 31 29 32 30 # track/track_manager.cc \ … … 54 52 animation/t_animation.h \ 55 53 \ 56 track/pilot_node.h \ 57 \ 58 network_stats_widget.h 59 54 track/pilot_node.h 60 55 61 56 # track/track_manager.h \
Note: See TracChangeset
for help on using the changeset viewer.