mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-06 06:21:16 +08:00
--hardcopy now handles piped output
If we tell gnuplot to plot to a file whose name starts with '|', gnuplot writes to a a process, not to a file. This is now supported by feedgnuplot
This commit is contained in:
parent
669fb8dee6
commit
ffd19b9b87
@ -406,11 +406,15 @@ sub mainThread
|
|||||||
|
|
||||||
my $outputfile;
|
my $outputfile;
|
||||||
my $outputfileType;
|
my $outputfileType;
|
||||||
if( $options{hardcopy})
|
if( defined $options{hardcopy})
|
||||||
{
|
{
|
||||||
$outputfile = $options{hardcopy};
|
$outputfile = $options{hardcopy};
|
||||||
$outputfile =~ /\.(eps|ps|pdf|png|svg)$/i;
|
if( $outputfile =~ /^[^|] # starts with anything other than |
|
||||||
$outputfileType = $1 ? lc $1 : '';
|
.* # stuff in the middle
|
||||||
|
\.(eps|ps|pdf|png|svg)$/ix) # ends with a known extension
|
||||||
|
{
|
||||||
|
$outputfileType = lc $1;
|
||||||
|
}
|
||||||
|
|
||||||
my %terminalOpts =
|
my %terminalOpts =
|
||||||
( eps => 'postscript solid color enhanced eps',
|
( eps => 'postscript solid color enhanced eps',
|
||||||
@ -419,8 +423,12 @@ sub mainThread
|
|||||||
png => 'png size 1280,1024',
|
png => 'png size 1280,1024',
|
||||||
svg => 'svg');
|
svg => 'svg');
|
||||||
|
|
||||||
$options{terminal} ||= $terminalOpts{$outputfileType}
|
if( !defined $options{terminal} &&
|
||||||
if $terminalOpts{$outputfileType};
|
defined $outputfileType &&
|
||||||
|
$terminalOpts{$outputfileType} )
|
||||||
|
{
|
||||||
|
$options{terminal} = $terminalOpts{$outputfileType};
|
||||||
|
}
|
||||||
|
|
||||||
die "Asked to plot to file '$outputfile', but I don't know which terminal to use, and no --terminal given"
|
die "Asked to plot to file '$outputfile', but I don't know which terminal to use, and no --terminal given"
|
||||||
unless $options{terminal};
|
unless $options{terminal};
|
||||||
@ -658,13 +666,20 @@ sub mainThread
|
|||||||
# finished reading in all. Plot what we have
|
# finished reading in all. Plot what we have
|
||||||
plotStoredData();
|
plotStoredData();
|
||||||
|
|
||||||
if ( $options{hardcopy})
|
if ( defined $options{hardcopy})
|
||||||
{
|
{
|
||||||
print PIPE "set output\n";
|
print PIPE "set output\n";
|
||||||
# sleep until the plot file exists, and it is closed. Sometimes the output is
|
|
||||||
# still being written at this point
|
# sleep until the plot file exists, and it is closed. Sometimes the output
|
||||||
usleep(100_000) until -e $outputfile;
|
# is still being written at this point. If the output filename starts with
|
||||||
usleep(100_000) until(system("fuser -s \"$outputfile\""));
|
# '|', gnuplot pipes the output to that process, instead of writing to a
|
||||||
|
# file. In that case I don't make sure the file exists, since there IS not
|
||||||
|
# file
|
||||||
|
if( $options{hardcopy} !~ /^\|/ )
|
||||||
|
{
|
||||||
|
usleep(100_000) until -e $outputfile;
|
||||||
|
usleep(100_000) until(system("fuser -s \"$outputfile\""));
|
||||||
|
}
|
||||||
|
|
||||||
print "Wrote output to $outputfile\n";
|
print "Wrote output to $outputfile\n";
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user