bugGNU Octave - Bugs: bug #41216, epslatexstandalone not working for...

 
 

bug #41216: epslatexstandalone not working for fltk backend with 'visible' = 'off'

Submitted by:  Marco Caliari <caliari>
Submitted on:  Mon 13 Jan 2014 10:39:25 AM UTC  
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Duplicate Assigned to:  None
Originator Name:  caliari Open/Closed:  Closed
Release:  3.8.0 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Thu 27 Mar 2014 07:32:19 AM UTC, comment #13: 

Bug # 41957 may also be relevant

Michael Godfrey <godfrey>
Project Member
Thu 27 Mar 2014 06:49:42 AM UTC, comment #12: 

Closing this duplicate of bug #33180.

Mike Miller <mtmiller>
Project Administrator
Fri 17 Jan 2014 04:57:56 PM UTC, comment #11: 

I think you can get what you want by using a project-specific .octaverc file.  In the directory where you are doing your work, make a new file ".octaverc" and put whatever commands you want in it.  In this case, put the command

graphics_toolkit gnuplot

You can read about it in the documentation, but Octave runs the global .octaverc file, the personal .octaverc file (~/.octaverc), and then the project-specific .octaverc file so these local changes will override your more general settings.

The other solution is to make the figures visible before printing.

set (hfig, "visible", "on");
print
set (hfig, "visible", "off");

Rik <rik5>
Project Administrator
Fri 17 Jan 2014 08:03:42 AM UTC, comment #10: 

OK, thank you very much.
Then, suppose I have to run several instances of

octave -q file1.m
octave -q file2.m
...

inside a Makefile, I have to put a

graphics_toolkit gnuplot

on top of each file?.m, I don't see an option to directly start octave with gnuplot.

Marco

Marco Caliari <caliari>
Project Member
Thu 16 Jan 2014 04:44:20 PM UTC, comment #9: 

Good debugging.  Unfortunately you've traced it down to a known problem.  There is no off-screen printing for FLTK.  The figure window needs to be visible for gl2ps to function.  See bug #33180.  It also bites us when producing the documentation, which some people want to do on headless build machines, so we're forced into using gnuplot for the pictures in the manual.  It's very uncertain when this will get fixed.

Rik <rik5>
Project Administrator
Thu 16 Jan 2014 09:41:29 AM UTC, comment #8: 

Hi,

it seems now I have an example always failing, with or without sleep(1)

clear all
close all
system('rm -f test.tex') % ATTENTION: dangerous
f = figure;
set(f,'visible','off') % with this, always failure with FLTK
plot(1,1)
print('-depslatexstandalone','test.tex')

If I remove the line set(f,'visible','off'), then (today) it always works. With the line, it works with gnuplot.

Marco

Marco Caliari <caliari>
Project Member
Wed 15 Jan 2014 06:48:57 PM UTC, comment #7: 

The drawnow function is written in C++ and it uses the gl2ps library to take the plot (OpenGL) and convert it to Postscript.  It then seems to pass the resulting data on to whatever the pipeline command is via a call to system().

I would put a

keyboard;

statement just above the call to drawnow() in _fltk_print_.m.  That will drop you into the debugger and you can inspect the pipeline command to see if it looks appropriate.

I know one difference is that most output formats have a single gl2ps device and a single pipeline command.  The 'standalone' output formats, instead, run OpenGL two times and with possibly two different pipeline commands.

Rik <rik5>
Project Administrator
Wed 15 Jan 2014 08:08:18 AM UTC, comment #6: 

Hi Rik,

today it is always working, with or without the sleep(1) command.
Is there an easy way to know what the command

drawnow (gl2ps_device{n}, strcat ('|',pipeline{n}));

is really doing? Calling ghostscript, epstool, ...?

Thanks,

Marco

Marco Caliari <caliari>
Project Member
Tue 14 Jan 2014 07:04:08 PM UTC, comment #5: 

Well there is something interesting going on.  I ran

for i = 1:100
  plot (1,1)
  print('-depslatexstandalone','text.tex')
endfor

and it always passes.  Whatever it is doesn't seem to affect my machine.

What happens if you put the sleep(1) command just before line 651 of print.m so it reads

  sleep (1);
  fid = fopen (latexfile, "r");

Rik <rik5>
Project Administrator
Tue 14 Jan 2014 02:21:48 PM UTC, comment #4: 

sleep(1) does not solve the intermittent result. But, even without sleep(1), the following

rm -rf test.tex test-inc.eps && octave

plot(1,1),print('-depslatexstandalone','test.tex')

that is the two commands on the same line always works (well, 10 consecutive times, never happened before).

Marco

Marco Caliari <caliari>
Project Member
Tue 14 Jan 2014 01:19:56 PM UTC, comment #3: 

Take a look at the file private/__fltk_print__.m at the bottom near line 170.  There is the following:

for n = 1:numel (pipeline)
  if (opts.debug)
    fprintf ("fltk-pipeline: '%s'\n", pipeline{n});
  endif
  drawnow (gl2ps_device{n}, strcat ('|',pipeline{n}));
endfor

if (! isempty (strfind (opts.devopt, "standalone")))
  opts.latex_standalone (opts);
endif

The intermittent failure seems to point to a race condition.  The drawnow call actually uses gl2ps to create the output and then pipes it through a command that might include ghostscript or epstool.

To confirm that it is a race condition you might want to add a 'sleep (1)' call just before opts.latex_standalone (opts).  If that works repeatedly then we can sort out a better solution.

Rik <rik5>
Project Administrator
Tue 14 Jan 2014 07:59:38 AM UTC, comment #2: 

With the option -f, it sometimes works, in a quite random way.
Maybe it randomly works without that option, too.
When it does not work, it is because at l.651 of print.m the output file is supposed to exist. I cannot find where the output file is created before to be opened for reading.

Marco

Marco Caliari <caliari>
Project Member
Mon 13 Jan 2014 04:48:52 PM UTC, comment #1: 

Might be something odd with your setup as this works for me with 3.8.0.  I'm running Kubuntu12.04.

I ran

octave-3.8.0 -f
plot(1,1)
print('-depslatexstandalone','text.tex')

I used the '-f' switch to avoid loading any Octave configuration files that might be changing settings.

Rik <rik5>
Project Administrator
Mon 13 Jan 2014 10:39:25 AM UTC, original submission:  

Dear all,

the following

plot(1,1)
print('-depslatexstandalone','text.tex')

gives me

error: print.m: error opening file 'text.tex'
error: called from:
error:   /usr/local/share/octave/3.8.0/m/plot/util/print.m at line 663, column 5
error:   /usr/local/share/octave/3.8.0/m/plot/util/private/__fltk_print__.m at line 170, column 5
error:   /usr/local/share/octave/3.8.0/m/plot/util/print.m at line 422, column 14

while working with 3.6.2.

Cheers,

Marco

Marco Caliari <caliari>
Project Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by godfrey (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by caliari (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-03-27 mtmiller Open/ClosedOpen => Closed
    2014-01-16 rik5 Item GroupRegression => Incorrect Result
        Dependencies- => Depends on bugs #33180
    2014-01-16 rik5 StatusWorks For Me => Duplicate
        Summaryepslatexstandalone not working for fltk backend => epslatexstandalone not working for fltk backend with 'visible' = 'off'
    2014-01-13 rik5 StatusNone => Works For Me

    Back to the top


    Powered by Savane 3.5