Back to index

texmacs  1.0.7.15
__plt2vv__.m
Go to the documentation of this file.
00001 ## Copyright (C) 1996, 1997 John W. Eaton
00002 ##
00003 ## This file is part of Octave.
00004 ##
00005 ## Octave is free software; you can redistribute it and/or modify it
00006 ## under the terms of the GNU General Public License as published by
00007 ## the Free Software Foundation; either version 2, or (at your option)
00008 ## any later version.
00009 ##
00010 ## Octave is distributed in the hope that it will be useful, but
00011 ## WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 ## General Public License for more details.
00014 ##
00015 ## You should have received a copy of the GNU General Public License
00016 ## along with Octave; see the file COPYING.  If not, write to the Free
00017 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
00018 ## 02111-1307, USA.
00019 
00020 ## -*- texinfo -*-
00021 ## @deftypefn {Function File} {} __plt2vv__ (@var{x}, @var{y}, @var{fmt})
00022 ## @end deftypefn
00023 
00024 ## Author: jwe
00025 
00026 ## Modified Jan. 2003 -- Added TeXmacs interface support
00027 ## Author: Michael Graffam <mgraffam@mathlab.sunysb.edu>
00028 
00029 function __plt2vv__ (x, y, fmt)
00030 
00031   if (nargin < 2 || nargin > 3)
00032     msg = sprintf ("__plt2vv__ (x, y)\n");
00033     msg = sprintf ("%s              __plt2vv__ (x, y, fmt)", msg);
00034     usage (msg);
00035   elseif (nargin == 2)
00036     fmt = "";
00037   elseif (rows (fmt) > 1)
00038     fmt = fmt (1, :);
00039   endif
00040 
00041   if (length(getenv("TEXMACS_PATH"))>0)
00042        gset output '/tmp/tmplot.eps';
00043   endif
00044 
00045   [x_nr, x_nc] = size (x);
00046   [y_nr, y_nc] = size (y);
00047 
00048   if (x_nr == 1)
00049     x = x';
00050     tmp = x_nr;
00051     x_nr = x_nc;
00052     x_nc = tmp;
00053   endif
00054 
00055   if (y_nr == 1)
00056     y = y';
00057     tmp = y_nr;
00058     y_nr = y_nc;
00059     y_nc = tmp;
00060   endif
00061 
00062   if (x_nr != y_nr)
00063     error ("__plt2vv__: vector lengths must match");
00064   endif
00065 
00066   tmp = [x, y];
00067   cmd = sprintf ("gplot tmp %s", fmt);
00068   eval (cmd);
00069 
00070           if (length(getenv("TEXMACS_PATH"))>0)
00071                  P=[2;112;115;58]; #P= "\002ps:"
00072                 g=fopen("/tmp/tmplot.eps");
00073                 while (g==-1)
00074                         sleep(1);
00075                         g=fopen("/tmp/tmplot.eps");
00076                 endwhile
00077                 while (!feof(g))
00078                         f=fread(g,2048);
00079                         if (length(f))
00080                                 P=[P;f];
00081                         endif
00082                 endwhile
00083                 fclose(g);
00084                 P=[P;5];
00085                 disp(sprintf("%cverbatim:\n",2));
00086                 disp(setstr(P'));
00087                 system("rm /tmp/tmplot.eps");
00088         endif
00089 
00090 endfunction