Changeset 31


Ignore:
Timestamp:
Jan 12, 2006, 12:45:03 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Reimplemented the gnuplot pipe implementation.

Location:
trunk
Files:
2 added
4 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r26 r31  
    66Jari Häkkinen
    77Peter Johansson
    8 
    9 
    10 
    11 A major part of the Gnuplot interface was written by Rajarshi Guha
    12 (see README for details).
  • trunk/README

    r30 r31  
    33Acknowledgements
    44
    5 svnstat uses a C++ interface to Gnuplot written by Rajarshi Guha. The
    6 interface is integrated in the svnstat code with some modifications
    7 (see below). The original code used for svnstat can be found in
    8 directory ./gnuplot_i++.
     5svnstat uses a C++ interface to Gnuplot inspired by Rajarshi Guha.
    96
    107Rajarshi Guha's "A C++ Interface to Gnuplot" can be found through
     
    129interfaces in ANSI C" written by Nicolas Devillard. The C implemention
    1310is available through http://ndevilla.free.fr/ .
    14 
    15 Changes made to the C++ Gnuplot interface files (gnuplot_i.hpp and
    16 gnuplot_i.cc):
    17 
    18 i) Changed filename gnuplot_i.hpp to gnuplot_i.h, and consequently
    19    changed #include directive in gnuplot_i.cc.
    20 
    21 ii) Encapsulated the interface into namespace theplu::svnstat.
    22 
    23 iii) Added 'Id' tags in both files.
    24 
    25 iv) Changed the initial #ifndef/#define idiom to avoid potential
    26    clash with the original implementation.
    27 
    28 v) gnuplot_i.h: Removed the 'using namespace std;' statement, since we
    29    don't want to expose the std namespace to everyone using the
    30    Gnuplot interface. This triggered subsequent changes to code lines
    31    with string and vector<> usage.
    32 
    33 vi) Resolved signed/unsigned compiler warnings in gnuplot_i.cc on
    34    lines 235, 278, 418, and 482
    35 
    36 vii) gnuplot_i.cc: Changed order of code in Gnuplot destructor, now
    37    the pipe is closed first. I have not done a full scale
    38    investigation on why this is needed, but on MacOSX the files are
    39    removed before gnuplot plots data when the original code order is
    40    kept.
  • trunk/lib/Makefile.am

    r26 r31  
    44
    55noinst_LIBRARIES = libsvnstat.a
    6 libsvnstat_a_SOURCES = Directory.cc File.cc gnuplot_i.cc Node.cc Stats.cc
     6libsvnstat_a_SOURCES = \
     7  Directory.cc File.cc Gnuplot.cc Node.cc Stats.cc
  • trunk/test/gnuplot_pipe.cc

    r27 r31  
    11// $Id$
    22
    3 #include "gnuplot_i.h"
     3#include "Gnuplot.h"
    44
    5 #include <string>
    6 #include <iostream>
     5#include <vector>
    76
    87int main(const int argc,const char* argv[])
     
    1211  bool ok = true;
    1312
    14   // Jari speaks out: My first thought was to use one pipe to produce
    15   // all plots. The idea was to avoid creating pipes since these are
    16   // expensive. However, the Gnuplot class will run out of resources
    17   // when a lot of data is to be plotted using plot_x() and
    18   // plot_xy(). The current limit is 64 plots (plot_equation() and
    19   // plot_slope() does not add to this count). Well, if all this is
    20   // jibberish for you, never mind - we are going to write our own
    21   // Gnuplot pipe using Guha's implementation as inspiration.
    22 
    23   // Until the new implementation, use the last example below (look
    24   // for 'Peter, look here') as a template for now.
    25 
    26   Gnuplot gnuplot("steps");
    27   std::string command("set output 'test.png'\nset term png");
    28   gnuplot.cmd(command.c_str());
    29   gnuplot.plot_equation("sin(x)","sine of x");
    30 
    3113  std::vector<double> x,y;
    3214  for (int i=-10; i<=10; ++i) {
     
    3416    y.push_back(i*i);
    3517  }
    36   command=std::string("set output 'test2.png'");
    37   gnuplot.cmd(command.c_str());
    38   // Jari, the next line actually does a 'replot' if a 'plot' has
    39   // already been issued. See pngs for examples.
    40   gnuplot.plot_x(x,"x");  // Jari, shouldn't this be called plot_y?
    4118
    42   command=std::string("set output 'test3.png'");
    43   gnuplot.cmd(command.c_str());
    44   // Jari, the next line actually does a 'replot' if a 'plot' has
    45   // already been issued. See pngs for examples.
    46   gnuplot.plot_xy(x,y,"xy");
     19  svnstat::Gnuplot gnuplot1;
     20  gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'");
     21  gnuplot1.command("plot sin(x) title 'sine of x' with lines");
    4722
     23  svnstat::Gnuplot gnuplot2;
     24  gnuplot2.command("set output 'test2.png'; set term png");
     25  gnuplot2.plot_y(x);
    4826
    49   // Peter, look here.
    50   // Jari, Maybe we should stick to this type of stuff until the new
    51   // implementation.
    52   Gnuplot gnuplot1;
    53   gnuplot1.cmd("set output 'test4.png'\nset term png");
    54   gnuplot1.cmd("plot sin(x) title 'sine of x' with lines");
     27  svnstat::Gnuplot gnuplot3;
     28  gnuplot3.command("set output 'test3.png'; set term png");
     29  gnuplot3.linetitle("parabola");
     30  gnuplot3.plot_xy(x,y);
    5531
    56   Gnuplot gnuplot2;
    57   gnuplot2.cmd("set output 'test5.png'\nset term png");
    58   gnuplot2.plot_x(x,"x"); // Jari, shouldn't this be called plot_y?
    59 
    60   Gnuplot gnuplot3;
    61   gnuplot3.cmd("set output 'test6.png'\nset term png");
    62   gnuplot3.plot_xy(x,y,"xy");
     32  gnuplot3.command("set output 'test4.png'; set title 'composite'");
     33  gnuplot3.linestyle("linespoints");
     34  gnuplot3.linetitle("");
     35  gnuplot3.plot_y(x,true);
    6336
    6437  // Jari, if we want to avoid the above usage of plot_x and plot_xy,
     
    6740  // plot_x and plot_xy). Note, the below example compiles, but will
    6841  // fail at run time if 'filename.data' does not, miraculously, exist.
    69   Gnuplot gnuplot4;
    70   gnuplot4.cmd("set output 'test6.png'\nset term png");
    71   gnuplot4.cmd("plot 'filename.data' using 1:2 with linespoints");
     42  svnstat::Gnuplot gnuplot4;
     43  gnuplot4.command("set output 'test5.png'\nset term png");
     44  gnuplot4.command("plot 'filename.data' using 1:2 with linespoints");
    7245
    7346  return (ok ? 0 : -1);
Note: See TracChangeset for help on using the changeset viewer.