From 7c8ec4597b8cf07c98bcc095d3f1c53f33d0595d Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de> Date: Fri, 16 Sep 2011 07:57:28 +0200 Subject: [PATCH] improve comments --- pub/src/dualplot.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pub/src/dualplot.cpp b/pub/src/dualplot.cpp index 7d074fd2..89f85f63 100644 --- a/pub/src/dualplot.cpp +++ b/pub/src/dualplot.cpp @@ -27,28 +27,31 @@ CPlot::CPlot( uint _iPlot, bool _logx, bool _logy ) : iPlot( _iPlot ), X( _logx ), Y( _logy ), maxpoints(20000), with_errors(true), equipoints(7), refine(true) { - // Start gnuplot. Use input redirection so that gnuplot receives - // commands from a gp_fifo which is created here. + // == Initialization for Gnuplot == + // Create a named pipe (FIFO) that will transmit our commands to Gnuplot. string fn_fifo = string("/tmp/gnuplot-") + getenv( "LOGNAME" ); - mystd::system( "rm -f "+fn_fifo ); if (mkfifo( fn_fifo.c_str(), 0666 )) throw "SYSTEM ERROR cannot make fifo " + fn_fifo + ": will not be able to print"; + // Start a Gnuplot that will read from our pipe. mystd::system( "gnuplot -title " + strg(iPlot) + " -noraise" + " < " + fn_fifo + " &" ); - // we use open instead of fopen or ofstream, - // because we need non-blocking mode. + // Open our pipe so that we can write commands to it + // (we use 'open' instead of 'fopen' or 'ofstream', + // because we need non-blocking mode). if ( ! ( gp_fifo = open( fn_fifo.c_str(), O_WRONLY ) ) ) throw "SYSTEM ERROR cannot open fifo " + fn_fifo + ": will not be able to print"; fcntl( gp_fifo, F_SETFL, O_NONBLOCK ); + // Now the initialization _within_ Gnuplot. gp_write( string("set terminal x11") ); + // == Initialization for PostScript == ps_fnum=0; } -- GitLab