annotate src/DLD-FUNCTIONS/gplot.l @ 5440:b73d469ef0c9

[project @ 2005-09-04 12:31:45 by dbateman] ChangeLog
author dbateman
date Sun, 04 Sep 2005 12:31:45 +0000
parents c49aec8a9080
children 250917610b55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1 %option prefix="gpt"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
2 %option noyywrap
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
3
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
4 %{
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
5 // PKG_ADD: mark_as_rawcommand ("__gnuplot_plot__");
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
6 // PKG_ADD: mark_as_rawcommand ("__gnuplot_set__");
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
7 // PKG_ADD: mark_as_rawcommand ("__gnuplot_splot__");
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
8 // PKG_ADD: mark_as_rawcommand ("__gnuplot_replot__");
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
9
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
10 // PKG_ADD: mark_as_rawcommand ("gplot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
11 // PKG_ADD: mark_as_rawcommand ("gset");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
12 // PKG_ADD: mark_as_rawcommand ("gsplot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
13
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
14 // PKG_ADD: mark_as_command ("__gnuplot_show__");
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
15
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
16 // PKG_ADD: mark_as_command ("gshow");
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
17
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
18 // PKG_ADD: mark_as_command ("set");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
19 // PKG_ADD: mark_as_command ("show");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
20
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
21 // PKG_ADD: __gnuplot_init__ ();
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
22
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
23 // PKG_ADD: atexit ("closeplot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
24
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
27 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
28
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
29 #include <string>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
30 #include <fstream>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
31 #include <iostream>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
32
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
33 #ifdef HAVE_UNISTD_H
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
34 #ifdef HAVE_SYS_TYPES_H
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
35 #include <sys/types.h>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
36 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
37 #include <unistd.h>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
38 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
39
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
40 #include "file-ops.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
41
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
42 #include "defun-dld.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
43 #include "file-io.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
44 #include "gripes.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
45 #include "load-save.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
46 #include "parse.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
47 #include "procstream.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
48 #include "sighandlers.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
49 #include "utils.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
50 #include "variables.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
51
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
52 enum _toktype
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
53 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
54 START_PAREN = 1,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
55 END_PAREN,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
56 START_BRACE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
57 END_BRACE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
58 START_BRACKET,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
59 END_BRACKET,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
60 COLON,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
61 SEMICOLON,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
62 COMMA,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
63 QUOTE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
64 IDENT,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
65 NUMBER,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
66 BINOP,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
67 UNOP,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
68 STRING,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
69 OTHER,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
70 TITLE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
71 USING,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
72 WITH,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
73 AXES,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
74 CLEAR
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
75 };
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
76
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
77 typedef bool (*pred) (const int);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
78
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
79 class
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
80 gpt_parse_error
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
81 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
82 public:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
83 gpt_parse_error (void) : msg () { }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
84 gpt_parse_error (std::string errmsg) : msg (errmsg) { }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
85
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
86 std::string msg;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
87 };
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
88
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
89 static int is_plot_keyword (const std::string& s);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
90
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
91 static int handle_string (char delim);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
92
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
93 static inline bool can_be_plotkw (void);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
94
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
95 static void gnuplot_init (void);
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
96
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
97 static bool gpt_quote_is_transpose;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
98 static bool gpt_allow_plotkw;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
99 static int gpt_parens;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
100 static int gpt_brackets;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
101 static int gpt_braces;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
103 static int send_to_plot_stream (const std::string& cmd);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
104
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
105 // needed by handle_string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
106 static char string_buf[256];
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
107
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
108 %}
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
109
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
110 D [0-9]
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
111 S [ \t]
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
112 IDENT ([_a-zA-Z@][_a-zA-Z0-9]*)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
113 EXPON ([DdEe][+-]?{D}+)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
114 NUMBER (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
115 NOT ((\~)|(\!))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
116 /* NOT is not strictly a binary operator, but is close enough for us. */
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
117 BINOP (({NOT})|(\.?([\*/\\^+-]|\*\*)=?)|([<=~!>&|]=)|([=&|<>]{1,2})|(<<=)|(>>=)|(\.))
5106
0a048f33a545 [project @ 2005-01-12 01:33:28 by jwe]
jwe
parents: 5102
diff changeset
118 /* single quote (') transpose operator is handled separately. */
0a048f33a545 [project @ 2005-01-12 01:33:28 by jwe]
jwe
parents: 5102
diff changeset
119 UNOP ((\+\+)|(\-\-)|(\.'))
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
120
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
121 %%
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
122
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
123 "(" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
124 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
125 gpt_parens++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
126 return START_PAREN;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
127 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
128
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
129 ")" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
130 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
131 gpt_parens--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
132 return END_PAREN;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
133 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
134
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
135 "{" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
136 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
137 gpt_braces++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
138 return START_BRACE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
139 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
140
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
141 "}" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
142 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
143 gpt_braces--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
144 return END_BRACE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
145 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
146
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
147 "[" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
148 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
149 gpt_brackets++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
150 return START_BRACKET;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
151 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
152
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
153 "]" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
154 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
155 gpt_brackets--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
156 return END_BRACKET;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
157 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
158
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
159 ":" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
160 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
161 return COLON;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
162 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
163
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
164 ";" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
165 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
166 return SEMICOLON;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
167 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
168
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
169 "," {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
170 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
171 return COMMA;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
172 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
173
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
174 "'" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
175 if (gpt_quote_is_transpose)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
176 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
177 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
178 return QUOTE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
179 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
180 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
181 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
182 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
183 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
184 return handle_string ('\'');
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
185 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
186 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
187
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
188 "\"" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
189 return handle_string ('"');
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
190 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
191
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
192 {IDENT} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
193 int itok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
194 if (can_be_plotkw () && (itok = is_plot_keyword (yytext)))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
195 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
196 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
197 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
198 return itok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
199 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
200 else if (std::string (yytext) == "function")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
201 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
202 throw gpt_parse_error ("The 'function' keyword is not allowed in plot commands.");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
203 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
204 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
205 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
206 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
207 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
208 return IDENT;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
209 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
210 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
211
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
212 {D}+/\.[\*/\\^'] | /* ' */
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
213 {NUMBER} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
214 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
215 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
216 return NUMBER;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
217 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
218
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
219 {BINOP} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
220 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
221 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
222 return BINOP;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
223 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
224
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
225 {UNOP} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
226 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
227 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
228 return UNOP;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
229 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
230
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
231 {S} { /* Ignore spaces and tabs outside of character strings. */ }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
232
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
233 . {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
234 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
235 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
236 warning ("unknown token = \"%s\" in plot command", yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
237 return OTHER;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
238 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
239
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
240 %%
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
241
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
242 // If TRUE, a replot command is issued automatically each time a plot
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
243 // changes in some way.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
244 static bool Vautomatic_replot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
245
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
246 // The name of the shell command to execute to start gnuplot.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
247 static std::string Vgnuplot_binary;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
248
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
249 // TRUE if gnuplot appears to support multiple plot windows with X11.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
250 static bool Vgnuplot_has_frames;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
251
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
252 // The number of lines we've plotted so far.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
253 static int plot_line_count = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
254
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
255 // Is this a parametric plot? Makes a difference for 3D plotting.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
256 static bool parametric_plot = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
257
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
258 // The gnuplot terminal type.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
259 static std::string gnuplot_terminal_type;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
260
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
261 // Pipe to gnuplot.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
262 static oprocstream *plot_stream = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
263
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
264 // Gnuplot command strings that we use.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
265 static std::string Vgnuplot_command_plot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
266 static std::string Vgnuplot_command_replot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
267 static std::string Vgnuplot_command_splot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
268 static std::string Vgnuplot_command_using;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
269 static std::string Vgnuplot_command_with;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
270 static std::string Vgnuplot_command_axes;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
271 static std::string Vgnuplot_command_title;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
272 static std::string Vgnuplot_command_end;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
273
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
274 // (almost) copy-paste code from pt-plot.cc
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
275
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
276 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
277 save_in_tmp_file (const octave_value& t, int ndim = 2, bool parametric = false)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
278 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
279 std::string name = file_ops::tempnam ("", "oct-");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
280
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
281 if (! name.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
282 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
283 std::ofstream file (name.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
284
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
285 if (file)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
286 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
287 switch (ndim)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
288 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
289 case 2:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
290 save_ascii_data_for_plotting (file, t, name);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
291 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
292
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
293 case 3:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
294 save_three_d (file, t, parametric);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
295 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
296
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
297 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
298 gripe_2_or_3_dim_plot ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
299 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
300 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
301 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
302 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
303 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
304 error ("couldn't open temporary output file `%s'", name.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
305 name.resize (0);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
306 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
307 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
308
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
309 return name;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
310 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
311
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
312 static void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
313 close_plot_stream (bool remove_from_child_list = true)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
314 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
315 if (plot_stream)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
316 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
317 if (remove_from_child_list)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
318 octave_child_list::remove (plot_stream->pid ());
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
319
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
320 send_to_plot_stream ("\nquit\n");
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
321
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
322 delete plot_stream;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
323 plot_stream = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
324 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
325
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
326 plot_line_count = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
327 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
328
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
329 static bool
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
330 plot_stream_event_handler (pid_t pid, int status)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
331 {
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
332 bool retval = false;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
333
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
334 if (pid > 0)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
335 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
336 if (WIFEXITED (status) || WIFSIGNALLED (status))
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
337 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
338 close_plot_stream (false);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
339
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
340 warning ("connection to external plotter (pid = %d) lost --", pid);
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
341 warning ("please try your plot command(s) again");
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
342
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
343 // Request removal of this PID from the list of child
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
344 // processes.
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
345
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
346 retval = true;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
347 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
348 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
349
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
350 return retval;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
351 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
352
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
353 static void
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
354 open_plot_stream (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
355 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
356 static bool initialized = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
357
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
358 if (plot_stream && ! *plot_stream)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
359 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
360 delete plot_stream;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
361 plot_stream = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
362 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
363
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
364 if (! plot_stream)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
365 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
366 initialized = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
367
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
368 plot_line_count = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
369
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
370 std::string plot_prog;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
371
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
372 if (Vgnuplot_binary.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
373 plot_prog = "gnuplot";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
374 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
375 plot_prog = "\"" + Vgnuplot_binary + "\"";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
376
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
377 // XXX FIXME XXX -- I'm not sure this is the right thing to do,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
378 // but without it, C-c at the octave prompt will kill gnuplot...
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
379
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
380 #if defined (HAVE_POSIX_SIGNALS)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
381 sigset_t set, oset;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
382 sigemptyset (&set);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
383 sigaddset (&set, SIGINT);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
384 sigprocmask (SIG_BLOCK, &set, &oset);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
385 #else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
386 volatile octave_interrupt_handler old_interrupt_handler
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
387 = octave_ignore_interrupts ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
388 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
389
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
390 plot_stream = new oprocstream (plot_prog.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
391
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
392 if (plot_stream)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
393 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
394 if (! *plot_stream)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
395 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
396 delete plot_stream;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
397 plot_stream = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
398
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
399 error ("plot: unable to open pipe to `%s'", plot_prog.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
400 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
401 else
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
402 octave_child_list::insert (plot_stream->pid (),
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
403 plot_stream_event_handler);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
404 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
405 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
406 error ("plot: unable to open pipe to `%s'", plot_prog.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
407
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
408 #if defined (HAVE_POSIX_SIGNALS)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
409 sigprocmask (SIG_SETMASK, &oset, 0);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
410 #else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
411 octave_set_interrupt_handler (old_interrupt_handler);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
412 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
413 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
414
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
415 if (! error_state && plot_stream && *plot_stream && ! initialized)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
416 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
417 initialized = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
418
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
419 *plot_stream << "set style data lines\n";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
420
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
421 if (! gnuplot_terminal_type.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
422 *plot_stream << "set term " << gnuplot_terminal_type
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
423 << Vgnuplot_command_end << "\n";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
424 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
425 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
426
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
427 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
428 send_to_plot_stream (const std::string& cmd)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
429 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
430 if (! (plot_stream && *plot_stream))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
431 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
432 open_plot_stream ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
433
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
434 if (error_state)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
435 return -1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
436 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
437
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
438 int replot_len = Vgnuplot_command_replot.length ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
439
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
440 bool is_replot = (Vgnuplot_command_replot == cmd.substr (0, replot_len));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
441
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
442 if (! (plot_line_count == 0 && is_replot))
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
443 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
444 *plot_stream << cmd;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
445
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
446 plot_stream->flush ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
447 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
448
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
449 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
450 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
451
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
452 // Check if the parser state is such that a plot keyword can occur.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
453 static inline bool
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
454 can_be_plotkw (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
455 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
456 return (gpt_allow_plotkw
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
457 && (gpt_braces == 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
458 && (gpt_brackets == 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
459 && (gpt_parens == 0));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
460 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
461
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
462 // (Probably not necessesary, but current Matlab style plot functions
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
463 // break without this (they emit too short gnuplot commands))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
464 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
465 plot_style_token (const std::string& s)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
466 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
467 std::string retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
468
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
469 // XXX FIXME XXX -- specify minimum match length for these.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
470 static const char *plot_styles[] =
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
471 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
472 "boxes",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
473 "boxerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
474 "boxxyerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
475 "candlesticks",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
476 "dots",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
477 "errorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
478 "financebars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
479 "fsteps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
480 "histeps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
481 "impulses",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
482 "lines",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
483 "linespoints",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
484 "points",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
485 "steps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
486 "vector",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
487 "xerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
488 "xyerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
489 "yerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
490 0,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
491 };
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
492
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
493 const char * const *tmp = plot_styles;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
494 while (*tmp)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
495 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
496 if (almost_match (*tmp, s.c_str ()))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
497 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
498 retval = *tmp;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
499 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
500 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
501
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
502 tmp++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
503 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
504
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
505 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
506 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
507
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
508 // This is used to handle single-quote delimited strings. Kludge alert.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
509 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
510 handle_string (char delim)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
511 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
512 int c;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
513 char *pos = string_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
514 int escape_pending = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
515
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
516 *pos++ = static_cast<char> (delim);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
517 while ((c = yyinput ()) != EOF)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
518 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
519 if (c == '\\')
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
520 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
521 if (escape_pending)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
522 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
523 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
524 escape_pending = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
525 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
526 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
527 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
528 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
529 escape_pending = 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
530 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
531 continue;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
532 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
533 else if (c == '\n')
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
534 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
535 error ("unterminated string constant");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
536 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
537 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
538 else if (c == delim)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
539 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
540 if (escape_pending)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
541 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
542 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
543 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
544 c = yyinput ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
545 if (c == delim)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
546 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
547 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
548 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
549 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
550 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
551 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
552 yyunput (c, yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
553 *pos++ = static_cast<char> (delim);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
554 *pos++ = '\0';
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
555 yytext = string_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
556 return STRING;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
557 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
558 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
559 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
560 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
561 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
562 *pos++ = static_cast<char> (c);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
563 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
564
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
565 escape_pending = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
566 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
567
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
568 throw gpt_parse_error ("Unterminated string?");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
569
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
570 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
571 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
572
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
573 // Check to see if a character string matches any one of the plot
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
574 // option keywords. Don't match abbreviations for clear, since that's
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
575 // not a gnuplot keyword (users will probably only expect to be able
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
576 // to abbreviate actual gnuplot keywords).
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
577
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
578 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
579 is_plot_keyword (const std::string& s)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
580 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
581 const char *t = s.c_str ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
582 if (almost_match ("title", t, 1))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
583 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
584 return TITLE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
585 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
586 else if (almost_match ("using", t, 1))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
587 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
588 return USING;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
589 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
590 else if (almost_match ("with", t, 1))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
591 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
592 return WITH;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
593 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
594 else if (almost_match ("axes", t, 2) || almost_match ("axis", t, 2))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
595 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
596 return AXES;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
597 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
598 else if (strcmp ("clear", t) == 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
599 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
600 return CLEAR;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
601 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
602 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
603 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
604 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
605 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
606 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
607
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
608 // Some predicates on tokens
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
609
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
610 // Return true for ":".
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
611 static inline bool
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
612 colonp (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
613 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
614 return (tok == COLON);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
615 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
616
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
617 // Return TRUE for "]".
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
618 static inline bool
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
619 endbracketp (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
620 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
621 return (tok == END_BRACKET);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
622 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
623
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
624 // Return TRUE for plot token, comma or end of input.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
625 static inline bool
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
626 plottok_or_end_p (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
627 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
628 return (tok == TITLE
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
629 || tok == USING
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
630 || tok == WITH
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
631 || tok == AXES
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
632 || tok == CLEAR
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
633 || tok == COMMA
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
634 || tok == 0);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
635 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
636
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
637 // Equivalent to (colonp (tok) || plottok_or_end_p (tok)).
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
638 static inline bool
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
639 colon_plottok_or_end_p (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
640 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
641 return (tok == COLON || plottok_or_end_p (tok));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
642 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
643
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
644 // read until test is true and delimiters are balanced, or end of input.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
645 // Return the last token in lasttok
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
646 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
647 read_until (pred test, int& lasttok) throw (gpt_parse_error)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
648 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
649 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
650
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
651 // We have to maintain balanced delimiters per subexpression too.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
652 int brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
653 int parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
654 int braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
655 std::string s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
656
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
657 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
658
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
659 while (tok && ! (test (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
660 && brackets == 0
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
661 && parens == 0
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
662 && braces == 0))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
663 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
664 switch (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
665 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
666 case START_BRACKET:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
667 brackets++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
668 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
669
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
670 case END_BRACKET:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
671 brackets--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
672 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
673
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
674 case START_PAREN:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
675 parens++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
676 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
677
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
678 case END_PAREN:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
679 parens--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
680 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
681
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
682 case START_BRACE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
683 braces++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
684 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
685
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
686 case END_BRACE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
687 braces--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
688 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
689
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
690 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
691 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
692 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
693
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
694 s += std::string (yytext) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
695
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
696 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
697 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
698
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
699 // Throw error only if we've reached the end token and the test
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
700 // doesn't accept it.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
701
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
702 if (! test (tok) && ! tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
703 throw gpt_parse_error ("unexpected end of input");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
704
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
705 lasttok = tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
706
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
707 return s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
708 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
709
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
710 // Eval the two expressions giving limits of range and print it.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
711 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
712 printrange (std::string starts, std::string ends)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
713 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
714 octave_value startv, endv;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
715 int status;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
716 std::string s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
717 OSSTREAM range_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
718
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
719 range_buf << "[";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
720
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
721 if (! starts.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
722 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
723 startv = eval_string (starts, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
724 if (! startv.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
725 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
726 startv.print_raw (range_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
727 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
728
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
729 range_buf << ":";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
730
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
731 if (! ends.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
732 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
733 endv = eval_string (ends, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
734 if (! endv.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
735 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
736 endv.print_raw (range_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
737 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
738
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
739 range_buf << "]";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
740 range_buf << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
741
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
742 s = OSSTREAM_STR (range_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
743
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
744 return s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
745 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
746
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
747 // Handle plot parameters.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
748
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
749 // Title has one string expression which is evaluated and printed to the
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
750 // gnuplot command string.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
751 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
752 handle_title (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
753 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
754 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
755 std::string retstr = Vgnuplot_command_title + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
756 std::string title_expr_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
757
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
758 title_expr_str += read_until (plottok_or_end_p, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
759
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
760 int status;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
761 octave_value tmp_data = eval_string (title_expr_str, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
762
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
763 if (status != 0 || ! tmp_data.is_defined ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
764 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
765
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
766 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
767 if (tmp_data.is_string ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
768 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
769 tmp_buf << '"';
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
770 tmp_data.print_raw (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
771 tmp_buf << '"' << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
772 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
773 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
774 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
775 warning ("line title must be a string");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
776 tmp_buf << '"' << "line " << plot_line_count << '"';
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
777 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
778
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
779 retstr += OSSTREAM_STR (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
780
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
781 lasttok = tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
782
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
783 return retstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
784 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
785
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
786 // Parse, evaluate and print colon separated expressions in the using
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
787 // plot parameter. The use of trailing format string is not supported.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
788 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
789 handle_using (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
790 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
791 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
792 std::string expr_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
793 std::string retstr = Vgnuplot_command_using + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
794 bool out = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
795
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
796 octave_value tmp_data;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
797 int status;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
798 while (! out)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
799 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
800 expr_str = read_until (colon_plottok_or_end_p, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
801
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
802 tmp_data = eval_string (expr_str, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
803 if (status != 0 || ! tmp_data.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
804 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
805
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
806 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
807 tmp_data.print_raw (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
808 tmp_buf << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
809 retstr += OSSTREAM_STR (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
810
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
811 if (tok == COLON)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
812 retstr += ":";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
813 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
814 out = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
815 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
816
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
817 lasttok = tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
818
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
819 return retstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
820 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
821
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
822 // Presently just passes the linewidth, pointtype etc. tokens as they are.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
823 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
824 handle_style (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
825 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
826 std::string retstr = Vgnuplot_command_with + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
827 std::string style;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
828
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
829 lasttok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
830
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
831 if (lasttok != IDENT)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
832 throw gpt_parse_error ("expected plot style token");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
833
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
834 style = std::string (yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
835 style = plot_style_token (style);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
836
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
837 if (! style.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
838 retstr += style;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
839 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
840 retstr += std::string (yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
841
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
842 // XXX FIXME XXX -- should evaluate the remaining tokens, but this
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
843 // needs changes in the parser.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
844 retstr += " " + read_until (plottok_or_end_p, lasttok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
845
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
846 return retstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
847 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
848
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
849 // Axes has only one qualifier keyword, which is not evaluated.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
850 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
851 handle_axes (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
852 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
853 return Vgnuplot_command_axes + " " + read_until (plottok_or_end_p, lasttok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
854 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
855
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
856 // Parse and evaluate parameter string and pass it to gnuplot pipe.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
857 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
858 makeplot (std::string caller, std::string args) throw (gpt_parse_error)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
859 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
860 YY_BUFFER_STATE bstate;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
861
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
862 bstate = yy_scan_string (args.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
863 yy_switch_to_buffer (bstate);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
864 std::string outstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
865 int ndim = 2;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
866
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
867 if (caller == "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
868 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
869 ndim = 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
870 outstr += Vgnuplot_command_replot + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
871 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
872 else if (caller == "plot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
873 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
874 ndim = 2;
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
875 plot_line_count = 0;
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
876 outstr += Vgnuplot_command_plot + " ";
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
877 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
878 else if (caller == "splot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
879 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
880 ndim = 3;
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
881 plot_line_count = 0;
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
882 outstr += Vgnuplot_command_splot + " ";
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
883 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
884 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
885 throw gpt_parse_error ("unknown plot command");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
886
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
887 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
888 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
889 gpt_parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
890 gpt_braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
891 gpt_brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
892
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
893 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
894 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
895 if (plottok_or_end_p (tok) && caller != "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
896 throw gpt_parse_error ("must have something to plot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
897
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
898 while (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
899 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
900 bool title_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
901 bool using_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
902 bool style_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
903 bool axes_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
904
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
905 if (tok == START_BRACKET)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
906 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
907 if (caller == "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
908 throw gpt_parse_error ("can't specify new plot ranges with `replot' or while hold is on");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
909
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
910 std::string xrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
911 std::string xrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
912 outstr += printrange (xrange_start_str, xrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
913 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
914 if (tok == START_BRACKET)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
915 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
916 std::string yrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
917 std::string yrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
918 outstr += printrange (yrange_start_str, yrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
919 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
920 if (tok == START_BRACKET && caller == "gsplot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
921 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
922 std::string zrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
923 std::string zrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
924 outstr += printrange (zrange_start_str, zrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
925 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
926 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
927 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
928 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
929
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
930 if (plottok_or_end_p (tok))
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
931 return 1;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
932 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
933 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
934 std::string file;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
935 plot_line_count++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
936
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
937 if (tok == STRING)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
938 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
939 file = file_ops::tilde_expand (std::string (yytext));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
940 // XXX FIXME XXX -- perhaps should check if the file exists?
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
941 outstr += file + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
942 // Discard junk after the string.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
943 read_until (plottok_or_end_p, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
944 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
945 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
946 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
947 std::string plot_expr_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
948 plot_expr_str += std::string (yytext) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
949 plot_expr_str += read_until (plottok_or_end_p, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
950
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
951 int status = 0;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
952 octave_value tmp_data = eval_string (plot_expr_str,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
953 true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
954
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
955 if (status != 0 || ! tmp_data.is_defined ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
956 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
957
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
958 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
959 tmp_data.print_raw (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
960 tmp_buf << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
961
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
962 if (tmp_data.is_string ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
963 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
964 file = file_ops::tilde_expand (tmp_data.string_value ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
965 // XXX FIXME XXX -- perhaps should check if the file exists?
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
966 outstr += file + " ";
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
967 }
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
968 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
969 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
970 switch (ndim)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
971 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
972 case 2:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
973 file = save_in_tmp_file (tmp_data, ndim);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
974 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
975
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
976 case 3:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
977 file = save_in_tmp_file (tmp_data, ndim,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
978 parametric_plot);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
979 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
980
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
981 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
982 gripe_2_or_3_dim_plot ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
983 break;
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
984 }
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
985
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
986 if (file.length () > 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
987 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
988 mark_for_deletion (file);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
989 outstr += "'" + file + "' ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
990 }
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
991 }
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
992 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
993 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
994
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
995 std::string title_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
996 std::string using_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
997 std::string style_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
998 std::string axes_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
999
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1000 bool out = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1001 while (tok && ! out)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1002 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1003 switch (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1004 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1005 case COMMA:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1006 out = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1007 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1008
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1009 case TITLE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1010 if (! title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1011 title_str += handle_title (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1012 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1013 throw gpt_parse_error ("only one title option may be specified");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1014 title_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1015 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1016
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1017 case USING:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1018 if (! using_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1019 using_str += handle_using (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1020 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1021 throw gpt_parse_error ("only one using option may be specified");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1022 using_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1023 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1024
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1025 case WITH:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1026 if (! style_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1027 style_str += handle_style (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1028 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1029 throw gpt_parse_error ("only one style option may be specified");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1030 style_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1031 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1032
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1033 case AXES:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1034 if (! axes_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1035 axes_str += handle_axes (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1036 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1037 throw gpt_parse_error ("only one axes option may be specified");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1038 axes_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1039 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1040
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1041 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1042 tok = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1043 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1044 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1045 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1046
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1047 if (! title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1048 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1049 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1050 tmp_buf << Vgnuplot_command_title << " \"line "
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1051 << plot_line_count << "\" " << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1052 title_str = OSSTREAM_STR (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1053 title_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1054 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1055
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1056 // Plot parameters have to be output in this order.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1057 if (using_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1058 outstr += using_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1059
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1060 if (axes_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1061 outstr += axes_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1062
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1063 if (title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1064 outstr += title_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1065
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1066 if (style_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1067 outstr += style_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1068
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1069 if (out)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1070 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1071 // Saw comma on while loop.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1072 outstr += ", ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1073 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1074 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1075 gpt_parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1076 gpt_braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1077 gpt_brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1078 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1079 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1080 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1081
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1082 outstr += Vgnuplot_command_end;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1083
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1084 // Terrible kludge, but line count is destroyed when plot stream
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1085 // is opened for the first time.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1086 int linesave = plot_line_count;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1087 send_to_plot_stream (outstr);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1088 plot_line_count = linesave;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1089
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1090 return 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1091 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1092
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1093 static void
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1094 doplot (std::string caller, octave_value_list args)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1095 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1096 std::string s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1097 int i = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1098
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1099 while (i < args.length ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1100 s += args (i++).string_value () + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1101
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1102 try
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1103 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1104 makeplot (caller, s);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1105 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1106 catch (gpt_parse_error e)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1107 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1108 if (e.msg.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1109 error ("could not parse plot command");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1110 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1111 error (e.msg.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1112 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1113 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1114
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1115 DEFUN_DLD (clearplot, , ,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1116 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1117 @deftypefn {Built-in Function} {} clearplot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1118 @deftypefnx {Built-in Function} {} clg\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1119 Clear the plot window and any titles or axis labels. The name\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1120 @code{clg} is aliased to @code{clearplot} for compatibility with\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1121 @sc{Matlab}.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1122 @end deftypefn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1123 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1124 octave_value_list retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1125
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1126 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1127
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1128 send_to_plot_stream ("clear\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1129
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1130 // XXX FIXME XXX -- instead of just clearing these things, it would
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1131 // be nice if we could reset things to a user-specified default
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1132 // state.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1133
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1134 send_to_plot_stream ("set title\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1135 send_to_plot_stream ("set xlabel\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1136 send_to_plot_stream ("set ylabel\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1137 send_to_plot_stream ("set nogrid\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1138 send_to_plot_stream ("set nolabel\n");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1139
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1140 // This makes a simple `replot' not work after a `clearplot' command
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1141 // has been issued.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1142
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1143 plot_line_count = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1144
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1145 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1146 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1147
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1148 DEFUN_DLD (closeplot, , ,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1149 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1150 @deftypefn {Built-in Function} {} closeplot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1151 Close stream to the @code{gnuplot} subprocess. If you are using X11,\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1152 this will close the plot window.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1153 @end deftypefn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1154 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1155 octave_value_list retval;
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1156
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1157 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1158
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1159 parametric_plot = false;
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1160
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1161 set_global_value ("__multiplot_mode__", 0.0);
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1162
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1163 close_plot_stream ();
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1164
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1165 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1166 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1167
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1168 DEFUN_DLD (purge_tmp_files, , ,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1169 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1170 @deftypefn {Built-in Function} {} purge_tmp_files\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1171 Delete the temporary files created by the plotting commands.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1172 \n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1173 Octave creates temporary data files for @code{gnuplot} and then sends\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1174 commands to @code{gnuplot} through a pipe. Octave will delete the\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1175 temporary files on exit, but if you are doing a lot of plotting you may\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1176 want to clean up in the middle of a session.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1177 \n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1178 A future version of Octave will eliminate the need to use temporary\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1179 files to hold the plot data.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1180 @end deftypefn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1181 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1182 octave_value_list retval;
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1183
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1184 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1185
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1186 cleanup_tmp_files ();
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1187
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1188 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1189 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1190
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1191 DEFUN_DLD (__gnuplot_raw__, args, ,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1192 "-*- texinfo -*-\n\
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1193 @deftypefn {Built-in Function} {} __gnuplot_raw__ (@var{string})\n\
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1194 Send @var{string} directly to gnuplot subprocess.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1195 @end deftypefn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1196 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1197 octave_value_list retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1198
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1199 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1200
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1201 if (args.length () == 1 && args(0).is_string ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1202 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1203 std::string cmd = args(0).string_value ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1204
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1205 if (! (plot_stream && *plot_stream))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1206 open_plot_stream ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1207
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1208 if (! error_state)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1209 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1210 *plot_stream << cmd;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1211
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1212 plot_stream->flush ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1213 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1214 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1215 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1216 print_usage ("raw");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1217
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1218 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1219 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1220
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1221 DEFUN_DLD (__gnuplot_set__, args, ,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1222 "-*- texinfo -*-\n\
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1223 @deffn {Command} __gnuplot_set__ options\n\
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1224 Set plotting options for gnuplot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1225 @end deffn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1226 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1227 octave_value_list retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1228
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1229 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1230
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1231 int argc = args.length () + 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1232
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1233 string_vector argv = args.make_argv ("set");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1234
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1235 if (error_state)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1236 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1237
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1238 OSSTREAM plot_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1239
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1240 if (argc > 1)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1241 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1242 if (almost_match ("parametric", argv[1], 3))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1243 parametric_plot = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1244 else if (almost_match ("noparametric", argv[1], 5))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1245 parametric_plot = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1246 else if (almost_match ("term", argv[1], 1))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1247 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1248 gnuplot_terminal_type = "";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1249 OSSTREAM buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1250 int i;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1251 for (i = 2; i < argc-1; i++)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1252 buf << argv[i] << " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1253 if (i < argc)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1254 buf << argv[i];
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1255 buf << Vgnuplot_command_end << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1256 gnuplot_terminal_type = OSSTREAM_STR (buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1257 OSSTREAM_FREEZE (buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1258 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1259 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1260
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1261 int i;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1262 for (i = 0; i < argc-1; i++)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1263 plot_buf << argv[i] << " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1264
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1265 if (i < argc)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1266 plot_buf << argv[i];
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1267
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1268 plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1269
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1270 send_to_plot_stream (OSSTREAM_STR (plot_buf));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1271
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1272 OSSTREAM_FREEZE (plot_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1273
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1274 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1275 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1276
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1277 DEFUN_DLD (__gnuplot_show__, args, ,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1278 "-*- texinfo -*-\n\
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1279 @deffn {Command} __gnuplot_show__ options\n\
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1280 Show plotting options.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1281 @end deffn")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1282 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1283 octave_value_list retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1284
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1285 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1286
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1287 int argc = args.length () + 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1288
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1289 string_vector argv = args.make_argv ("show");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1290
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1291 if (error_state)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1292 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1293
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1294 OSSTREAM plot_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1295
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1296 int i;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1297 for (i = 0; i < argc-1; i++)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1298 plot_buf << argv[i] << " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1299 if (i < argc)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1300 plot_buf << argv[i];
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1301
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1302 plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1303
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1304 send_to_plot_stream (OSSTREAM_STR (plot_buf));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1305
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1306 OSSTREAM_FREEZE (plot_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1307
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1308 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1309 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1310
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1311 DEFUN_DLD (__gnuplot_plot__, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1312 "Plot with gnuplot.\n")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1313 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1314 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1315
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1316 doplot ("plot", args);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1317 return octave_value_list ();
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1318 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1319
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1320 DEFUN_DLD (__gnuplot_splot__, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1321 "Plot with gnuplot.\n")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1322 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1323 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1324
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1325 doplot ("splot", args);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1326 return octave_value_list ();
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1327 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1328
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1329 DEFUN_DLD (__gnuplot_replot__, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1330 "Plot with gnuplot.\n")
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1331 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1332 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1333
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1334 doplot ("replot", args);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1335 return octave_value_list ();
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1336 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1337
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1338 // Deprecated functions.
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1339
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1340 #define WARN_DEPRECATED(FOLD, FNEW) \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1341 do \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1342 { \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1343 static bool warned = false; \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1344 if (! warned) \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1345 { \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1346 warned = true; \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1347 warning (#FOLD " is deprecated and will be removed from a future"); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1348 warning ("version of Octave."); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1349 warning ("You should use the higher-level plot functions"); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1350 warning ("(\"plot\", \"mesh\", \"semilogx\", etc.) instead"); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1351 warning ("of the low-level plotting commands."); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1352 warning ("If you absolutely must use this function, use the"); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1353 warning ("internal version " #FNEW " instead."); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1354 } \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1355 } \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1356 while (0)
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1357
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1358 #define DEPRECATED_BODY(FOLD, FNEW) \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1359 WARN_DEPRECATED (FOLD, FNEW); \
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1360 return feval (#FNEW, args)
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1361
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1362 // We can't further simplify this by putting the DEFUN_DLD in a macro
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1363 // because then the mk-oct-links script will fail.
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1364
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1365 DEFUN_DLD (gplot, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1366 "")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1367 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1368 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1369
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1370 DEPRECATED_BODY (gplot, __gnuplot_plot__);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1371 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1372
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1373 DEFUN_DLD (gsplot, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1374 "")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1375 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1376 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1377
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1378 DEPRECATED_BODY (gsplot, __gnuplot_splot__);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1379 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1380
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1381 DEFUN_DLD (graw, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1382 "")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1383 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1384 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1385
5251
454e3c98300d [project @ 2005-03-28 16:05:51 by jwe]
jwe
parents: 5215
diff changeset
1386 DEPRECATED_BODY (graw, __gnuplot_raw__);
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1387 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1388
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1389 DEFUN_DLD (gset, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1390 "")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1391 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1392 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1393
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1394 DEPRECATED_BODY (gset, __gnuplot_set__);
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1395 }
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1396
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1397 DEFUN_DLD (gshow, args, ,
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1398 "")
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1399 {
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1400 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1401
5251
454e3c98300d [project @ 2005-03-28 16:05:51 by jwe]
jwe
parents: 5215
diff changeset
1402 DEPRECATED_BODY (gshow, __gnuplot_show__);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1403 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1404
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1405 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1406 automatic_replot (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1407 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1408 Vautomatic_replot = check_preference ("automatic_replot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1409
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1410 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1411 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1412
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1413 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1414 set_string_var (std::string& var, const char *nm)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1415 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1416 int retval = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1417
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1418 std::string s = builtin_string_variable (nm);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1419
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1420 if (s.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1421 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1422 gripe_invalid_value_specified (nm);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1423 retval = -1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1424 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1425 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1426 var = s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1427
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1428 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1429 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1430
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1431 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1432 gnuplot_binary (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1433 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1434 return set_string_var (Vgnuplot_binary, "gnuplot_binary");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1435 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1436
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1437 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1438 gnuplot_command_plot (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1439 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1440 return set_string_var (Vgnuplot_command_plot, "gnuplot_command_plot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1441 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1442
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1443 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1444 gnuplot_command_replot (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1445 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1446 return set_string_var (Vgnuplot_command_replot, "gnuplot_command_replot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1447 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1448
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1449 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1450 gnuplot_command_splot (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1451 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1452 return set_string_var (Vgnuplot_command_splot, "gnuplot_command_splot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1453 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1454
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1455 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1456 gnuplot_command_using (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1457 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1458 return set_string_var (Vgnuplot_command_using, "gnuplot_command_using");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1459 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1460
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1461 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1462 gnuplot_command_with (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1463 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1464 return set_string_var (Vgnuplot_command_with, "gnuplot_command_with");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1465 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1466
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1467 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1468 gnuplot_command_axes (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1469 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1470 return set_string_var (Vgnuplot_command_axes, "gnuplot_command_axes");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1471 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1472
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1473 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1474 gnuplot_command_title (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1475 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1476 return set_string_var (Vgnuplot_command_title, "gnuplot_command_title");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1477 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1478
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1479 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1480 gnuplot_command_end (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1481 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1482 return set_string_var (Vgnuplot_command_end, "gnuplot_command_end");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1483 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1484
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1485 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1486 gnuplot_has_frames (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1487 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1488 Vgnuplot_has_frames = check_preference ("gnuplot_has_frames");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1489
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1490 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1491 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1492
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1493 static void
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1494 gnuplot_init (void)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1495 {
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1496 static bool gnuplot_initialized = false;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1497
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1498 if (gnuplot_initialized)
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1499 return;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1500
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1501 gnuplot_initialized = true;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1502
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1503 if (is_builtin_variable ("automatic_replot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1504 automatic_replot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1505 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1506 DEFVAR (automatic_replot, true, automatic_replot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1507 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1508 @defvr {Built-in Variable} automatic_replot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1509 You can tell Octave to redisplay the plot each time anything about it\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1510 changes by setting the value of the builtin variable\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1511 @code{automatic_replot} to a nonzero value. Although it is fairly\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1512 inefficient, especially for large plots, the default value is 1 for\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1513 compatibility with Matlab.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1514 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1515
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1516 if (is_builtin_variable ("gnuplot_binary"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1517 gnuplot_binary ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1518 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1519 DEFVAR (gnuplot_binary, GNUPLOT_BINARY, gnuplot_binary,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1520 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1521 @defvr {Built-in Variable} gnuplot_binary\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1522 The name of the program invoked by the plot command. The default value\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1523 is @code{\"gnuplot\"}. @xref{Installation}.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1524 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1525
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1526 if (is_builtin_variable ("gnuplot_command_plot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1527 gnuplot_command_plot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1528 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1529 DEFVAR (gnuplot_command_plot, "pl", gnuplot_command_plot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1530 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1531 @defvr {Built-in Variable} gnuplot_command_plot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1532 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1533
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1534 if (is_builtin_variable ("gnuplot_command_replot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1535 gnuplot_command_replot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1536 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1537 DEFVAR (gnuplot_command_replot, "rep", gnuplot_command_replot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1538 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1539 @defvr {Built-in Variable} gnuplot_command_replot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1540 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1541
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1542 if (is_builtin_variable ("gnuplot_command_splot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1543 gnuplot_command_splot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1544 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1545 DEFVAR (gnuplot_command_splot, "sp", gnuplot_command_splot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1546 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1547 @defvr {Built-in Variable} gnuplot_command_splot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1548 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1549
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1550 if (is_builtin_variable ("gnuplot_command_using"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1551 gnuplot_command_using ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1552 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1553 DEFVAR (gnuplot_command_using, "u", gnuplot_command_using,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1554 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1555 @defvr {Built-in Variable} gnuplot_command_using\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1556 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1557
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1558 if (is_builtin_variable ("gnuplot_command_with"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1559 gnuplot_command_with ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1560 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1561 DEFVAR (gnuplot_command_with, "w", gnuplot_command_with,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1562 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1563 @defvr {Built-in Variable} gnuplot_command_with\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1564 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1565
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1566 if (is_builtin_variable ("gnuplot_command_axes"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1567 gnuplot_command_axes ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1568 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1569 DEFVAR (gnuplot_command_axes, "ax", gnuplot_command_axes,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1570 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1571 @defvr {Built-in Variable} gnuplot_command_axes\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1572 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1573
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1574 if (is_builtin_variable ("gnuplot_command_title"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1575 gnuplot_command_title ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1576 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1577 DEFVAR (gnuplot_command_title, "t", gnuplot_command_title,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1578 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1579 @defvr {Built-in Variable} gnuplot_command_title\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1580 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1581
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1582 if (is_builtin_variable ("gnuplot_command_end"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1583 gnuplot_command_end ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1584 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1585 DEFVAR (gnuplot_command_end, "\n", gnuplot_command_end,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1586 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1587 @defvr {Built-in Variable} gnuplot_command_end\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1588 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1589
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1590 #if defined (GNUPLOT_HAS_FRAMES)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1591 bool with_frames = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1592 #else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1593 bool with_frames = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1594 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1595
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1596 if (is_builtin_variable ("gnuplot_has_frames"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1597 gnuplot_has_frames ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1598 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1599 DEFVAR (gnuplot_has_frames, with_frames, gnuplot_has_frames,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1600 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1601 @defvr {Built-in Variable} gnuplot_has_frames\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1602 If the value of this variable is nonzero, Octave assumes that your copy\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1603 of gnuplot has support for multiple frames that is included in recent\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1604 3.6beta releases. Its initial value is determined by configure, but it\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1605 can be changed in your startup script or at the command line in case\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1606 configure got it wrong, or if you upgrade your gnuplot installation.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1607 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1608
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1609 }
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1610
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1611 DEFUN_DLD (__gnuplot_init__, , ,
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1612 "-*- texinfo -*-\n\
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1613 @deftypefn {Loadable Function} __gnuplot_init__ ()\n\
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1614 @end deftypefn")
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1615 {
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1616 octave_value_list retval;
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1617
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1618 gnuplot_init ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1619
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1620 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1621 }