Mercurial > hg > octave-nkf
changeset 20545:b439ccc9a162
doc: Improve building of images for the Manual.
Switch to using 'qt' as the default toolkit.
Stop producing onscreen flicker when building images.
Correctly build extended.pdf with new non-recursive build system.
* plot.txi: Change sample code for generation of image 15.7 to match the code
in plotimages.m
* geometryimages.m, sparseimages.m, interpimages.m, splineimages.m:
Call new function set_graphics_toolkit which makes sure there is at least
something available to do plotting with. Change hide_output() function
to call figure() directly with "visible", "off" properties passed to it
so there is never a moment when the figure is visible (stops flicker).
* plotimages.m: Change directory to working directory where documentation files
are kept before executing print with "-pdflatexstandalone". Call pdflatex
from within the working directory since that is what it expects. Clean up
after pdflatex by deleting auxiliary files. Capture status and output of
system command which invokes pdflatex so that it does not spew in to the
logs. Change text() command to use '\displaystyle' which looks nicer.
Add set_graphics_toolkit function and modify hide_output function as above.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 12 Jul 2015 15:00:26 -0700 |
parents | 07dd8e602f4e |
children | 55b10614f33d |
files | doc/interpreter/geometryimages.m doc/interpreter/interpimages.m doc/interpreter/plot.txi doc/interpreter/plotimages.m doc/interpreter/sparseimages.m doc/interpreter/splineimages.m |
diffstat | 6 files changed, 79 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/geometryimages.m +++ b/doc/interpreter/geometryimages.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. function geometryimages (d, nm, typ) - graphics_toolkit ("gnuplot"); + set_graphics_toolkit (); set_print_size (); hide_output (); outfile = fullfile (d, [nm "." typ]); @@ -135,6 +135,16 @@ endif endfunction +## This function no longer sets the graphics toolkit; That is now done +## automatically by C++ code which will ordinarily choose 'qt', but might +## choose gnuplot on older systems. Only a complete lack of plotting is a +## problem. +function set_graphics_toolkit () + if (isempty (available_graphics_toolkits ())) + error ("no graphics toolkit available for plotting"); + endif +endfunction + function set_print_size () image_size = [5.0, 3.5]; # in inches, 16:9 format border = 0; # For postscript use 50/72 @@ -144,12 +154,11 @@ set (0, "defaultfigurepaperposition", [border, border, image_size]); endfunction -## Use this function before plotting commands and after every call to -## print since print() resets output to stdout (unfortunately, gnpulot -## can't pop output as it can the terminal type). +## Use this function before plotting commands and after every call to print +## since print() resets output to stdout (unfortunately, gnuplot can't pop +## output as it can the terminal type). function hide_output () - hf = figure (1); - set (hf, "visible", "off"); + hf = figure (1, "visible", "off"); endfunction ## generate something for the texinfo @image command to process
--- a/doc/interpreter/interpimages.m +++ b/doc/interpreter/interpimages.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. function interpimages (d, nm, typ) - graphics_toolkit ("gnuplot"); + set_graphics_toolkit (); set_print_size (); hide_output (); outfile = fullfile (d, [nm "." typ]); @@ -78,6 +78,16 @@ hide_output (); endfunction +## This function no longer sets the graphics toolkit; That is now done +## automatically by C++ code which will ordinarily choose 'qt', but might +## choose gnuplot on older systems. Only a complete lack of plotting is a +## problem. +function set_graphics_toolkit () + if (isempty (available_graphics_toolkits ())) + error ("no graphics toolkit available for plotting"); + endif +endfunction + function set_print_size () image_size = [5.0, 3.5]; # in inches, 16:9 format border = 0; # For postscript use 50/72 @@ -87,12 +97,11 @@ set (0, "defaultfigurepaperposition", [border, border, image_size]); endfunction -## Use this function before plotting commands and after every call to -## print since print() resets output to stdout (unfortunately, gnpulot -## can't pop output as it can the terminal type). +## Use this function before plotting commands and after every call to print +## since print() resets output to stdout (unfortunately, gnuplot can't pop +## output as it can the terminal type). function hide_output () - hf = figure (1); - set (hf, "visible", "off"); + hf = figure (1, "visible", "off"); endfunction ## generate something for the texinfo @image command to process
--- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -960,7 +960,7 @@ hold on; plot (x, x, "r"); axis ([0, 3, 0, 1]); -text (0.65, 0.6175, ['$\leftarrow x = @{2/\sqrt@{\pi@}' ... +text (0.65, 0.6175, ['$\displaystyle\leftarrow x = @{2/\sqrt@{\pi@}' ... '@{\int_@{0@}^@{x@}@}e^@{-t^2@} dt@} = 0.6175$']); xlabel ("x"); ylabel ("erf (x)");
--- a/doc/interpreter/plotimages.m +++ b/doc/interpreter/plotimages.m @@ -90,21 +90,24 @@ hold on; plot (x, x, "r"); axis ([0, 3, 0, 1]); - if (strcmp (typ, "pdf")) - text (0.65, 0.6175, ['$\leftarrow x = {2/\sqrt{\pi}' ... - '{\int_{0}^{x}}e^{-t^2} dt} = 0.6175$']); - else - text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ... - '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']); - endif xlabel ("x"); ylabel ("erf (x)"); title ("erf (x) with text annotation"); if (strcmp (typ, "pdf")) - print (outfile, "-dpdflatexstandalone"); - system (["pdflatex " nm]); + text (0.65, 0.6175, ['$\displaystyle\leftarrow x = {2/\sqrt{\pi}' ... + '{\int_{0}^{x}}e^{-t^2} dt} = 0.6175$']); + ## Be very careful about modifying this. pdflatex expects to be in + ## the same directory as the file it is operating on. + cd (make_absolute_filename (d)); + print ([nm ".pdf"], "-dpdflatexstandalone"); + [status, output] = system (["pdflatex " nm]); + if (status) + error ("plotimages: Failed to run pdflatex on <extended.pdf>"); + endif delete ([nm ".aux"], [nm "-inc.pdf"], [nm ".log"], [nm ".tex"]); else + text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ... + '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']); print (outfile, d_typ); endif else @@ -113,17 +116,13 @@ hide_output (); endfunction -## Choose a toolkit with a preference for OpenGL renderers +## This function no longer sets the graphics toolkit; That is now done +## automatically by C++ code which will ordinarily choose 'qt', but might +## choose gnuplot on older systems. Only a complete lack of plotting is a +## problem. function set_graphics_toolkit () - avl_tk = available_graphics_toolkits (); - if (any (strcmp ("qt", avl_tk))) - graphics_toolkit ("qt"); - elseif (any (strcmp ("fltk", avl_tk))) - graphics_toolkit ("fltk"); - elseif (any (strcmp ("gnuplot", avl_tk))) - graphics_toolkit ("gnuplot"); - else - error ("no valid graphics toolkit found"); + if (isempty (available_graphics_toolkits ())) + error ("no graphics toolkit available for plotting"); endif endfunction
--- a/doc/interpreter/sparseimages.m +++ b/doc/interpreter/sparseimages.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. function sparseimages (d, nm, typ) - graphics_toolkit ("gnuplot"); + set_graphics_toolkit (); set_print_size (); if (strcmp (typ, "png")) set (0, "defaulttextfontname", "*"); @@ -280,6 +280,16 @@ endif endfunction +## This function no longer sets the graphics toolkit; That is now done +## automatically by C++ code which will ordinarily choose 'qt', but might +## choose gnuplot on older systems. Only a complete lack of plotting is a +## problem. +function set_graphics_toolkit () + if (isempty (available_graphics_toolkits ())) + error ("no graphics toolkit available for plotting"); + endif +endfunction + function set_print_size () image_size = [5.0, 3.5]; # in inches, 16:9 format border = 0; # For postscript use 50/72 @@ -289,11 +299,10 @@ set (0, "defaultfigurepaperposition", [border, border, image_size]); endfunction -## Use this function before plotting commands and after every call to -## print since print() resets output to stdout (unfortunately, gnpulot -## can't pop output as it can the terminal type). +## Use this function before plotting commands and after every call to print +## since print() resets output to stdout (unfortunately, gnuplot can't pop +## output as it can the terminal type). function hide_output () - hf = figure (1); - set (hf, "visible", "off"); + hf = figure (1, "visible", "off"); endfunction
--- a/doc/interpreter/splineimages.m +++ b/doc/interpreter/splineimages.m @@ -17,7 +17,7 @@ ## <http://www.gnu.org/licenses/>. function splineimages (d, nm, typ) - graphics_toolkit ("gnuplot"); + set_graphics_toolkit (); set_print_size (); hide_output (); outfile = fullfile (d, [nm "." typ]); @@ -159,6 +159,16 @@ hide_output (); endfunction +## This function no longer sets the graphics toolkit; That is now done +## automatically by C++ code which will ordinarily choose 'qt', but might +## choose gnuplot on older systems. Only a complete lack of plotting is a +## problem. +function set_graphics_toolkit () + if (isempty (available_graphics_toolkits ())) + error ("no graphics toolkit available for plotting"); + endif +endfunction + function set_print_size () image_size = [5.0, 3.5]; # in inches, 16:9 format border = 0; # For postscript use 50/72 @@ -168,12 +178,11 @@ set (0, "defaultfigurepaperposition", [border, border, image_size]); endfunction -## Use this function before plotting commands and after every call to -## print since print() resets output to stdout (unfortunately, gnpulot -## can't pop output as it can the terminal type). +## Use this function before plotting commands and after every call to print +## since print() resets output to stdout (unfortunately, gnuplot can't pop +## output as it can the terminal type). function hide_output () - hf = figure (1); - set (hf, "visible", "off"); + hf = figure (1, "visible", "off"); endfunction ## generate something for the texinfo @image command to process