mirror of
https://github.com/dkogan/feedgnuplot.git
synced 2025-05-06 06:21:16 +08:00
reworked hardcopy output. No longer writing to a tmp file first
Ignore-this: 6bcb476652cd7d3f532fe5326ff18fca darcs-hash:20091220031411-0cb85-4749f31184e76afb16dc974a93d1214febbb9da3.gz
This commit is contained in:
parent
c92e011de0
commit
0d689edbf9
@ -184,7 +184,6 @@ sub mainThread {
|
||||
}
|
||||
autoflush PIPE 1;
|
||||
|
||||
my $temphardcopyfile;
|
||||
my $outputfile;
|
||||
my $outputfileType;
|
||||
if( defined $options{"hardcopy"})
|
||||
@ -193,21 +192,13 @@ sub mainThread {
|
||||
($outputfileType) = $outputfile =~ /\.(ps|pdf|png)$/;
|
||||
if(!$outputfileType) { die("Only .ps, .pdf and .png supported\n"); }
|
||||
|
||||
# write to a temporary file first
|
||||
$temphardcopyfile = $outputfile;
|
||||
$temphardcopyfile =~ s{/}{_}g;
|
||||
$temphardcopyfile = "/tmp/$temphardcopyfile";
|
||||
if ($outputfileType eq "png")
|
||||
{
|
||||
print PIPE "set terminal png\n";
|
||||
$temphardcopyfile .= '.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
print PIPE "set terminal postscript solid color landscape 10\n";
|
||||
$temphardcopyfile .= '.ps';
|
||||
}
|
||||
print PIPE "set output \"$temphardcopyfile\"\n";
|
||||
my %terminalOpts =
|
||||
( ps => 'postscript solid color landscape 10',
|
||||
pdf => 'pdfcairo solid color font ",10" size 11in,8.5in',
|
||||
png => 'png' );
|
||||
|
||||
print PIPE "set terminal $terminalOpts{$outputfileType}\n";
|
||||
print PIPE "set output \"$outputfile\"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -334,18 +325,9 @@ sub mainThread {
|
||||
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
|
||||
usleep(100_000) until -e $temphardcopyfile;
|
||||
usleep(100_000) until(system("fuser -s $temphardcopyfile"));
|
||||
usleep(100_000) until -e $outputfile;
|
||||
usleep(100_000) until(system("fuser -s $outputfile"));
|
||||
|
||||
print "Finished gnuplotting. Converting...\n";
|
||||
if($outputfileType eq "pdf")
|
||||
{
|
||||
system("ps2pdf $temphardcopyfile $outputfile");
|
||||
}
|
||||
else
|
||||
{
|
||||
system("mv $temphardcopyfile $outputfile");
|
||||
}
|
||||
print "Wrote output to $outputfile\n";
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user