"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/netviz/packetfall.cpp" (19 Feb 2021, 1044 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "packetfall.cpp" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * packetfall.cpp: 
    3  * Show packets received vs port
    4  *
    5  * This source file is public domain, as it is not based on the original tcpflow.
    6  *
    7  * Author: Michael Shick <mike@shick.in>
    8  *
    9  */
   10 
   11 #include "config.h"
   12 
   13 #ifdef HAVE_LIBCAIRO
   14 #include "tcpflow.h"
   15 
   16 #include "packetfall.h"
   17 
   18 void packetfall::ingest_packet(const be13::packet_info &pi)
   19 {
   20 }
   21 
   22 void packetfall::render(cairo_t *cr, const plot_view::bounds_t &bounds)
   23 {
   24     cairo_set_source_rgb(cr, 0.67, 0.67, 0.67);
   25     cairo_rectangle(cr, bounds.x, bounds.y, bounds.width, bounds.height);
   26     cairo_fill(cr);
   27 
   28     double font_size = 16.0;
   29     std::string label = "pretty packetfall";
   30     cairo_text_extents_t extents;
   31 
   32     cairo_set_font_size(cr, font_size);
   33     cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
   34 
   35     cairo_text_extents(cr, label.c_str(), &extents);
   36 
   37     double text_x = bounds.x + (bounds.width - extents.width) / 2.0;
   38     double text_y = bounds.y + (bounds.height + extents.height) / 2.0;
   39 
   40     cairo_move_to(cr, text_x, text_y);
   41     cairo_show_text(cr, label.c_str());
   42 
   43 }
   44 #endif