X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fport.cpp;h=678be06e991bdfb4dce3bbd31f88c36732795cbd;hb=e7ccd0d35487219da5d1e447e5fd435ad763ba4c;hp=1e4219da1025fbff77823a4aebd949178a851bce;hpb=9954e8cbf9bae21f5a727f9c92e9c33dc6d8eaf1;p=netvis.git diff --git a/source/port.cpp b/source/port.cpp index 1e4219d..678be06 100644 --- a/source/port.cpp +++ b/source/port.cpp @@ -37,7 +37,7 @@ Port::Port(NetVis &v, unsigned n): registered = !isdigit(name[0]); } else - name = Msp::lexical_cast(number); + name = Msp::lexical_cast(number); const map &ports = netvis.get_ports(); unsigned tries = 100; @@ -92,13 +92,38 @@ Port::Port(NetVis &v, unsigned n): bld.end(); } +void Port::set_name(const string &n) +{ + name = n; +} + +void Port::add_activity(unsigned bytes) +{ + activity.add_bytes(bytes); +} + +void Port::tick(const Time::TimeDelta &dt) +{ + activity.tick(dt); +} + void Port::render() const { - GL::PushMatrix push_; + GL::MatrixStack::Push push_(GL::MatrixStack::modelview()); mesh.draw(); - GL::translate(16, 1, 0); - GL::scale_uniform(10); - GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); - netvis.get_font().draw_string(name, imm); + { + GL::Immediate imm((GL::COLOR4_UBYTE, GL::VERTEX2)); + imm.begin(GL::QUADS); + imm.color(color.r, color.g, color.b, color.a); + unsigned x = static_cast(activity.get_average()/4096); + imm.vertex(14, 0); + imm.vertex(14+x, 0); + imm.vertex(14+x, 10); + imm.vertex(14, 10); + imm.end(); + } + GL::MatrixStack::modelview() *= GL::Matrix::translation(16, 1, 0); + GL::MatrixStack::modelview() *= GL::Matrix::scaling(10); + netvis.get_font().draw_string(name); GL::Texture::unbind(); }