~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to plugins/octave/octave/plot/__plt2vm__.m

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
## Copyright (C) 1996, 1997 John W. Eaton
 
2
##
 
3
## This file is part of Octave.
 
4
##
 
5
## Octave is free software; you can redistribute it and/or modify it
 
6
## under the terms of the GNU General Public License as published by
 
7
## the Free Software Foundation; either version 2, or (at your option)
 
8
## any later version.
 
9
##
 
10
## Octave is distributed in the hope that it will be useful, but
 
11
## WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
## General Public License for more details.
 
14
##
 
15
## You should have received a copy of the GNU General Public License
 
16
## along with Octave; see the file COPYING.  If not, write to the Free
 
17
## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
18
## 02111-1307, USA.
 
19
 
 
20
## -*- texinfo -*-
 
21
## @deftypefn {Function File} {} __plt2vm__ (@var{x}, @var{y}, @var{fmt})
 
22
## @end deftypefn
 
23
 
 
24
## Author: jwe
 
25
 
 
26
## Modified Jan. 2003 -- Added TeXmacs interface support
 
27
## Author: Michael Graffam
 
28
 
 
29
function __plt2vm__ (x, y, fmt)
 
30
 
 
31
  if (nargin < 2 || nargin > 3)
 
32
    msg = sprintf ("__plt2vm__ (x, y)\n");
 
33
    msg = sprintf ("%s              __plt2vm__ (x, y, fmt)", msg);
 
34
    usage (msg);
 
35
  elseif (nargin == 2 || fmt == "")
 
36
    fmt = " ";  ## Yes, this is intentionally not an empty string!
 
37
  endif
 
38
 
 
39
  [x_nr, x_nc] = size (x);
 
40
  [y_nr, y_nc] = size (y);
 
41
 
 
42
  if (length(getenv("TEXMACS_PATH"))>0)
 
43
        gset output '/tmp/tmplot.eps';
 
44
  endif
 
45
 
 
46
  if (x_nr == 1)
 
47
    x = x';
 
48
    tmp = x_nr;
 
49
    x_nr = x_nc;
 
50
    x_nc = tmp;
 
51
  endif
 
52
 
 
53
  if (x_nr == y_nr)
 
54
    1;
 
55
  elseif (x_nr == y_nc)
 
56
    y = y';
 
57
    tmp = y_nr;
 
58
    y_nr = y_nc;
 
59
    y_nc = tmp;
 
60
  else
 
61
    error ("__plt2vm__: matrix dimensions must match");
 
62
  endif
 
63
 
 
64
  k = 1;
 
65
  fmt_nr = rows (fmt);
 
66
  if (y_nc > 0)
 
67
    tmp = [x, y];
 
68
    cmd = sprintf ("gplot tmp(:,%d:%d:%d) %s", 1, x_nc, x_nc+1,
 
69
                   deblank (fmt (k, :)));
 
70
    if (k < fmt_nr)
 
71
      k++;
 
72
    endif
 
73
    for i = 2:y_nc
 
74
      cmd = sprintf ("%s, tmp(:,%d:%d:%d) %s", cmd, 1, i, i+1,
 
75
                     deblank (fmt (k, :)));
 
76
      if (k < fmt_nr)
 
77
        k++;
 
78
      endif
 
79
    endfor
 
80
    eval (cmd);
 
81
          if (length(getenv("TEXMACS_PATH"))>0)
 
82
                 P=[2;112;115;58]; #P= "\002ps:"
 
83
                g=fopen("/tmp/tmplot.eps");
 
84
                while (g==-1)
 
85
                        sleep(1);
 
86
                        g=fopen("/tmp/tmplot.eps");
 
87
                endwhile
 
88
                while (!feof(g))
 
89
                        f=fread(g,2048);
 
90
                        if (length(f))
 
91
                                P=[P;f];
 
92
                        endif
 
93
                endwhile
 
94
                fclose(g);
 
95
                P=[P;5];
 
96
                disp(sprintf("%cverbatim:\n",2));
 
97
                disp(setstr(P'));
 
98
                system("rm /tmp/tmplot.eps");
 
99
        endif
 
100
 
 
101
  else
 
102
    error ("__plt2vm__: arguments must be a matrices");
 
103
  endif
 
104
 
 
105
endfunction