bugGNU Octave - Bugs: bug #31967, Cannot print in eps form in fltk...

 
 

bug #31967: Cannot print in eps form in fltk printing

Submitter:  Tatsuro MATSUOKA <tmacchant>
Submitted:  Sat 25 Dec 2010 04:20:48 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  5 - Blocker
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  bpabbott
Originator Name:  Tatsuro MATSUOKA Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 18 Jan 2011 12:25:02 PM UTC, comment #29: 

I'm changing the status to fixed and closing this bug report.

Ben Abbott <bpabbott>
Group Member
Mon 17 Jan 2011 09:33:43 AM UTC, comment #28: 

Hello

I have checked out the development source which includes your changeset.  I have confirmed fltk+ eps printing works fine.

Thanks a lot!

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Sun 16 Jan 2011 11:36:17 PM UTC, comment #27: 

Hello Tatsuro,

Thanks for all the help and patience.  I've pushed this change

    http://hg.savannah.gnu.org/hgweb/octave/rev/84fa2ba414ee

I'll email the list and encourage other developers to test printing.

Regards,

Ben

Ben Abbott <bpabbott>
Group Member
Sun 16 Jan 2011 10:59:59 PM UTC, comment #26: 

Hello Ben

Fine!

octave:5> print -debug test1.eps
epstool command: 'C:\Programs\gs\gs8.70\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile="test1.eps" -'
fltk-pipeline: 'C:\Programs\gs\gs8.70\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile="test1.eps" -'

test1.eps was successfully created
For emf, I will report in the corresponding item

I really appreciate for your efforts.

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Sun 16 Jan 2011 07:55:59 PM UTC, comment #25: 

I've attached a sixth attempt.


(file #22422)

Ben Abbott <bpabbott>
Group Member
Sun 16 Jan 2011 07:38:24 PM UTC, comment #24: 

I appreciate your efforts.

This time

***********************************************
octave:6> print -debug test1.eps
epstool command: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile=' -'
fltk-pipeline: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile=' -'
***********************************************

The error "invalid handle (= -29.0571)" is disappeared.
 
"-sOutputFile" is -sOutputFile=' -' so that this gives an eps file named ' (a single quote)

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Sun 16 Jan 2011 04:49:27 PM UTC, comment #23: 

The 4th changeset missed checking if the handles were still valid before setting their properties. I also neglected to replace the single quotes with double quotes for the output file.

A 5th changeset is attached.

(file #22421)

Ben Abbott <bpabbott>
Group Member
Sun 16 Jan 2011 07:40:27 AM UTC, comment #22: 

Hello

Thank you for your efforts.

****************************************
octave:6> print -debug test1.eps
epstool command: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile=' -'
fltk-pipeline: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile=' -'
error: set: invalid handle (= -29.0571)
error: called from:
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\print.m at line 381, column 9
***************************

Windows command line seems accept double quote but not single quote for the path quoting.

Perhaps if -sOutputFile=' -' is -sOutputFile="test1.eps", things will go well.

Regards

Tatsuro


Tatsuro MATSUOKA <tmacchant>
Sat 15 Jan 2011 09:36:49 PM UTC, comment #21: 

I've isolated the handle error to the legend listeners, and supplied a simple fix.

I think I've fixed the problem with the single quotes as well.

I've attached a 4th version.

(file #22415)

Ben Abbott <bpabbott>
Group Member
Sat 15 Jan 2011 07:33:05 PM UTC, comment #20: 

Hello

The results are

octave:6> print -debug test1.eps
epstool command: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile='test1.eps' -'
fltk-pipeline: 'C:\Programs\gs\gs9.00\bin/gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile='test1.eps' -'
error: set: invalid handle (= -29.0571)
error: called from:
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\print.m at line 377, column 9

Tatsuro MATSUOKA <tmacchant>
Sat 15 Jan 2011 06:29:59 PM UTC, comment #19: 

I don't see how the single quotes are added to the filename. Do they show up in the ghostscript command or pipeline when the debug option is included?

print -debug test1.eps

Ben Abbott <bpabbott>
Group Member
Sat 15 Jan 2011 06:15:18 PM UTC, comment #18: 

octave:6> print test1.eps
error: set: invalid handle (= -29.0571)
error: called from:
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\print.m at line 377, column 9
octave:6> print test2.eps -tiff

Although errors appeared but the new changeset gives 'test1.eps' instead of test1.eps
.

I renamed 'test1.eps' to test.eps and I l can look fplot graph by gsview.

For print test2.eps -tiff seemed to hang.

Tatsuro MATSUOKA <tmacchant>
Sat 15 Jan 2011 05:38:13 PM UTC, comment #17: 

I forgot that _ghostscript_binary_ was a subfunction of _print_parse_opts_

Try the 3rd attempt instead.

(file #22414)

Ben Abbott <bpabbott>
Group Member
Sat 15 Jan 2011 05:32:08 PM UTC, comment #16: 

With (file #22413) , error message has been changed.

**********************************
octave:6> print test1.eps
error: `__ghostscript_binary__' undefined near line 517 column 42
error: evaluating argument list element number 2
error: called from:
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\print.m at line 517, column 13
error: evaluating argument list element number 1
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m at line 46, column 10
error: set: invalid handle (= -29.0571)
error: called from:
error:   C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\print.m at line 377, column 9

Tatsuro MATSUOKA <tmacchant>
Sat 15 Jan 2011 04:53:24 PM UTC, comment #15: 

From the tracker item below ...

https://savannah.gnu.org/bugs/?32134

We found that the gs binary was not being added to the command. I've produced another changeset which should fix that. It is attached.

(file #22413)

Ben Abbott <bpabbott>
Group Member
Sat 15 Jan 2011 02:58:34 PM UTC, comment #14: 

The pipeline should begin with "gs.exe" or "gswin32c.exe". I looks to me like (1) octave isn't finding ghostscript, or (2) the ghostscript command isn't being added to the pipeline. So instead of …


gswin32c.exe -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile='test1.eps' -


Only the ghostscript options are present.


 -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile='test1.eps' -


To see if Octave can find the ghostscript binary, please use _print_parse_opts_. Under mingw this function will look for both gs.exe and gswin32c.exe, and return the one it finds. For example, on MacOS X ...


opts = __print_parse_opts__
opts =

  scalar structure containing the fields:

    append_to_file = 0
    canvas_size =

       576   432

    debug = 0
    debug_file = octave-print-commands.log
    devopt = pswrite
    epstool_binary = /sw/bin/epstool
    figure = [](0x0)
    fig2dev_binary = /sw/bin/fig2dev
    fontsize =
    font =
    force_solid = 0
    formatted_for_printing =  1
    ghostscript =

      scalar structure containing the fields:

        binary = /sw/bin/gs
        debug = 0
        device = pswrite
        epscrop =  1
        level =  1
        output =
        papersize = letter
        pageoffset =

            18   180

        resolution = [](0x0)
        antialiasing =  1

    loose = 0
    lpr_binary = /usr/bin/lpr
    name =
    orientation = portrait
    pstoedit_binary = /sw/bin/pstoedit
    preview =
    printer =
    send_to_printer =  1
    special_flag = textnormal
    tight_flag = 0
    use_color =  1
    lpr_options = -l
    unlink = {}(0x0)


Currently, the function looks for "gswin32c.exe" (all lower case). Is this the correct name for ghostscript? Is it all lower case? Should the ".exe" be included?

Ben Abbott <bpabbott>
Group Member
Sat 15 Jan 2011 09:26:21 AM UTC, comment #13: 

I have attached a patch and carried out tests.

************************************
system('us')
backend('fltk')
fplot ("[cos(x), sin(x)]", [0, 2*pi]);
print test1.eps
print test2.eps -tiff
print test3.png
************************************
Results are
octave.exe:6> print test1.eps
'-dQUIET' is not recognized as an internal or external command,
operable program or batch file.
error: set: invalid handle (= -29.0571)
error: called from:
error:   c:\usr\Tatsu\mingwhome\octaves\OctBuild\octave-develop\..\..\hg\octave-work\scripts\plot\print.m at line 377, column 9
octave.exe:6> print test2.eps -tiff
'-dQUIET' is not recognized as an internal or external command,
operable program or batch file.
Failed to open "C:/DOCUME~1/Tatsu/LOCALS~1/Temp\oct-36.eps".
Run "epstool --help" for more details.
Could Not Find C:\DOCUME~1\Tatsu\LOCALS~1\Temp\oct-36.eps
error: set: invalid handle (= -29.8026)
error: called from:
error:   c:\usr\Tatsu\mingwhome\octaves\OctBuild\octave-develop\..\..\hg\octave-work\scripts\plot\print.m at line 377, column 9
octave.exe:6> print test3.png
***************************************
png printing works correct.


I have carried out trace using 'dbstop' and 'dbstep'
The problem occured in _fltk_print_.m
***************************************
152:     pid = popen (pipeline{n}, "w");
debug> dbstep
stopped in c:\usr\Tatsu\mingwhome\octaves\OctBuild\octave-develop\..\..\hg\octave-work\scripts\plot\__fltk_print__.m at line 153
153:     if (pid < 0)
debug> '-dQUIET' is not recognized as an internal or external command, operable program or batch file.

debug> pipeline{n}
ans =  -dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -sOutputFile='test1.eps' -
***********************************
pipeline{n} seems failed to have gswin32c


BTW, I found in the comment in the patch 'gs.exe' but it is worked on the Cygwin. For, native windows ghostscript it should be 'gswin32c'.

Tatsuro MATSUOKA <tmacchant>
Fri 14 Jan 2011 12:55:31 PM UTC, comment #12: 

I've changed this severity to "Blocker" so that we don't inadvertently release Octave without the ability to print under MingGW.


Ben Abbott <bpabbott>
Group Member
Thu 13 Jan 2011 11:38:15 PM UTC, comment #11: 

My mistake. I've attached the changeset.

The ChangeLog won't apply correctly, but the rest should be ok.

(file #22405)

Ben Abbott <bpabbott>
Group Member
Thu 13 Jan 2011 10:52:52 PM UTC, comment #10: 

Hello Ben

Sorry my late reply. I cannot find an attachment file.

Tatsuro MATSUOKA <tmacchant>
Sun 09 Jan 2011 09:23:34 PM UTC, comment #9: 

I've attached a changeset that uses ghostscript to connect via the pipe.

The changeset is untested, so it may introduce other problems.

Please try ...


plot (1:10)
print test1.eps
print test2.eps -tiff
print test3.png



Ben Abbott <bpabbott>
Group Member
Sun 09 Jan 2011 06:46:00 AM UTC, comment #8: 

Hello

>Does it matter if you use the DOS COMMAND shell or the MSYS shell?


Octave is native windows program so that DOS shell is executed by default.  Exception is 'pkg install' command. The Msys shell is executed to use unix like build system.  Therefore that the Msys shell can be used in principle.

However, solution without the Msys shell might be found.  I would like to see the code in more detail.

Tatsuro MATSUOKA <tmacchant>
Sun 09 Jan 2011 02:09:25 AM UTC, comment #7: 

Its not clear to me where the problem is. I'd expected "cat" to properly handle the pipe. Might the problem be with the shell?

Does it matter if you use the DOS COMMAND shell or the MSYS shell?


Ben Abbott <bpabbott>
Group Member
Sat 08 Jan 2011 07:00:22 PM UTC, comment #6: 

Hello Ben

Thank you for your suggestions.

Replacement of

waitpid (pid);  by fprintf (pid, "%s", char (26)); made nothing to be changed.

>For "print test.eps" to work, only line 510 needs to be changed.


This made a little change,

At the first post, the dbstep trace hangs at
153:     if (pid < 0)

but after change, hangs at
60:       pclose (pid);

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Wed 05 Jan 2011 11:09:25 PM UTC, comment #5: 

For unix systems, I used "cat >" as a simple approach to redirect stdin to a file.

I used an online DOS reference to find equivalents. Apparently my DOS solutions aren't working. However, I'm not sure if the problem is due to the missing ^Z, or due to how the copy command works.

What happens if the line below in _fltk_print_ ...


    waitpid (pid);


... is replaced by


    fprintf (pid, "%s", char (26));


I would have expected your idea to use 'cat' from CoreUtils for Windows to work. There are 3 instances where "copy con" need to be replaced by "cat >". They are on line 476, 504, and 510 of print.m. For "print test.eps" to work, only line 510 needs to be changed. Did you replace "copy con" on line 510?

Ben Abbott <bpabbott>
Group Member
Wed 05 Jan 2011 05:44:01 PM UTC, comment #4: 

Thank you for your comments.

>I'd expected "copy con test.eps" to be equivalent "cat > test.eps" (for linux).


Copy con requires ^Z to finish

*****************************
c:\>copy con test.txt
dfasfasd
fafasda
fsfas
^Z
        1 file(s) copied.
*****************************

I install 'cat' for windows (e.g CoreUtils for Windows - GnuWin32) and try

    if (dos_shell)
      pipeline = {sprintf("cat > %s.%s", name, suffix)};
      pipeline{2} = sprintf ("cat > %s.tex", name);
    else
      pipeline = {sprintf("cat > %s.%s", name, suffix)};
      pipeline{2} = sprintf ("cat > %s.tex", name);
    endif

but did not work.

I cannot understand meaning of 'cat > test.eps'

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Wed 05 Jan 2011 01:15:09 PM UTC, comment #3: 

The freeze occurs just after _fltk_print_ open a pipe to the "copy con 'test.eps'". The function that constructs this pipeliine is epstool(), which is a subfunction of print().

I'd expected "copy con test.eps" to be equivalent "cat > test.eps" (for linux).

Do you have a suggestion for how this should be done?


Ben Abbott <bpabbott>
Group Member
Wed 05 Jan 2011 02:55:03 AM UTC, comment #2: 

Hello

Thank you for your reply

plot (1:10)
print -depswrite test.eps

works fine but

plot (1:10)
print -tiff test.eps

freezes.

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>
Wed 05 Jan 2011 02:42:17 AM UTC, comment #1: 

I'm surprised by this problem. Both the ps and pdf output are produced from eps output.

Another way to produce eps output is to use the ghostscript eps device.


plot (1:10)
print -depswrite test.eps


If that works, does eps output work when a preview is requested ...


plot (1:10)
print -tiff test.eps



Ben Abbott <bpabbott>
Group Member
Sat 25 Dec 2010 04:20:48 AM UTC, original submission:  

Hello

I have been not able to print into eps files on fltk backend.
(Freezing during printing.)

Snapshot ID used for current test is


Thu Dec 23 15:57:40 2010 +0100
changeset 11409 dd539a976451
parent 11408 6154672afa9a

I have tried dbstep trace.

The epstool-3.08-win32 was used.

cd C:\usr\tatsu\test\testOctave\fltk_print_test
dbstop _fltk_print_
backend('fltk')
fplot('cos', [0 2*pi])
print('cos.eps','-deps')
********************************

octave:4> print('cos.eps','-deps')
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 26
26:   dos_shell = (ispc () && ! isunix ());
debug>
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 28
28:   figure (opts.figure)
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 29
29:   drawnow ("expose")
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 30
30:   _fltk_redraw_ ();
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 32
32:   if (! isempty (opts.fig2dev_binary))
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 32
32:   if (! isempty (opts.fig2dev_binary))
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 34
34:     fig2dev_devices = {"pstex", "mf", "emf"};
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 39
39:   gl2ps_device = {};
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 40
40:   pipeline = {};
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 41
41:   switch (lower (opts.devopt))
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 41
41:   switch (lower (opts.devopt))
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 44
44:     gl2ps_device = {"eps"};
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 46
46:     pipeline = {opts.epstool_cmd(opts, "-", opts.name)};
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 146
146:   opts.pipeline = pipeline;
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 148
148:   for n = 1:numel(pipeline)
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 149
149:     if (opts.debug)
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 149
149:     if (opts.debug)
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 152
152:     pid = popen (pipeline{n}, "w");
debug> dbstep
stopped in C:\Programs\OctaveBuild\share\octave\3.3.54+\m\plot\__fltk_print__.m
at line 153
153:     if (pid < 0)
debug>(freeze here)

For ps and pdf, printing worked fine.

I have met different kind of trouble with fltk printing in emf form.  I will post it as another issue.

Any suggestions ?

Regards

Tatsuro

Tatsuro MATSUOKA <tmacchant>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #22422:  changeset.patch added by bpabbott (6KiB - sixth version)
file #22415:  changeset.patch added by bpabbott (5KiB - fourth version)
file #22414:  changeset.patch added by bpabbott (3KiB - third attempt)
file #22413:  changeset.patch added by bpabbott (3KiB - second changeset)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by tmacchant (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-18 bpabbott StatusNone Fixed
        Open/ClosedOpen Closed
    2011-01-16 bpabbott Attached File- Added changeset.patch, #22422
    2011-01-16 bpabbott Attached File- Added changeset.patch, #22421
    2011-01-15 bpabbott Attached File- Added changeset.patch, #22415
    2011-01-15 bpabbott Attached File- Added changeset.patch, #22414
    2011-01-15 bpabbott Attached File- Added changeset.patch, #22413
    2011-01-14 bpabbott Severity3 - Normal 5 - Blocker
    2011-01-13 bpabbott Attached File- Added changeset.patch, #22405
    2011-01-05 bpabbott Assigned toNone bpabbott

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code