annotate src/DLD-FUNCTIONS/gplot.l @ 5489:250917610b55

[project @ 2005-10-12 23:53:36 by jwe]
author jwe
date Wed, 12 Oct 2005 23:53:38 +0000
parents c49aec8a9080
children 4e8a9543e68c
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
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
29 #include <map>
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
30 #include <string>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
31 #include <fstream>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
32 #include <iostream>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
33
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
34 #ifdef HAVE_UNISTD_H
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
35 #ifdef HAVE_SYS_TYPES_H
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
36 #include <sys/types.h>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
37 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
38 #include <unistd.h>
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
39 #endif
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
40
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
41 #include "file-ops.h"
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
42 #include "oct-env.h"
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
43
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
44 #include "defun-dld.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
45 #include "file-io.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
46 #include "gripes.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
47 #include "load-save.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
48 #include "parse.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
49 #include "procstream.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
50 #include "sighandlers.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
51 #include "utils.h"
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
52 #include "variables.h"
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 enum _toktype
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
55 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
56 START_PAREN = 1,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
57 END_PAREN,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
58 START_BRACE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
59 END_BRACE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
60 START_BRACKET,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
61 END_BRACKET,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
62 COLON,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
63 SEMICOLON,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
64 COMMA,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
65 QUOTE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
66 IDENT,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
67 NUMBER,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
68 BINOP,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
69 UNOP,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
70 STRING,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
71 OTHER,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
72 TITLE,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
73 USING,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
74 WITH,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
75 AXES,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
76 CLEAR
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
77 };
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 typedef bool (*pred) (const int);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
80
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
81 class
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
82 gpt_parse_error
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
83 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
84 public:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
85 gpt_parse_error (void) : msg () { }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
86 gpt_parse_error (std::string errmsg) : msg (errmsg) { }
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 std::string msg;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
89 };
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 bool gpt_quote_is_transpose;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
92 static bool gpt_allow_plotkw;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
93 static int gpt_parens;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
94 static int gpt_brackets;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
95 static int gpt_braces;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
96
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
97 static bool can_be_plotkw (void);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
98
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
99 static int is_plot_keyword (const std::string& s);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
100
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
101 %}
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 D [0-9]
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
104 S [ \t]
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
105 IDENT ([_a-zA-Z@][_a-zA-Z0-9]*)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
106 EXPON ([DdEe][+-]?{D}+)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
107 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
108 NOT ((\~)|(\!))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
109 /* 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
110 BINOP (({NOT})|(\.?([\*/\\^+-]|\*\*)=?)|([<=~!>&|]=)|([=&|<>]{1,2})|(<<=)|(>>=)|(\.))
5106
0a048f33a545 [project @ 2005-01-12 01:33:28 by jwe]
jwe
parents: 5102
diff changeset
111 /* single quote (') transpose operator is handled separately. */
0a048f33a545 [project @ 2005-01-12 01:33:28 by jwe]
jwe
parents: 5102
diff changeset
112 UNOP ((\+\+)|(\-\-)|(\.'))
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
113
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
114 %%
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
115
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
116 "(" {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
117 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
118 gpt_parens++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
119 return START_PAREN;
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 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
124 gpt_parens--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
125 return END_PAREN;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
126 }
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
130 gpt_braces++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
131 return START_BRACE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
132 }
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 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
136 gpt_braces--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
137 return END_BRACE;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
138 }
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
142 gpt_brackets++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
143 return START_BRACKET;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
144 }
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 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
148 gpt_brackets--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
149 return END_BRACKET;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
150 }
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
154 return COLON;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
155 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
156
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
159 return SEMICOLON;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
160 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
161
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
164 return COMMA;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
165 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
166
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 if (gpt_quote_is_transpose)
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_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
171 return QUOTE;
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 else
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 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
176 gpt_allow_plotkw = true;
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
177 warning ("unknown token = \"%s\" in plot command", yytext);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
178 return OTHER;
5102
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 }
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 {IDENT} {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
183 int itok = 0;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
184 if (can_be_plotkw () && (itok = is_plot_keyword (yytext)))
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 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
187 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
188 return itok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
189 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
190 else if (std::string (yytext) == "function")
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
191 throw gpt_parse_error ("function keyword not allowed in plot commands");
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
192 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
193 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
194 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
195 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
196 return IDENT;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
197 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
198 }
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 {D}+/\.[\*/\\^'] | /* ' */
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
201 {NUMBER} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
202 gpt_quote_is_transpose = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
203 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
204 return NUMBER;
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
207 {BINOP} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
208 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
209 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
210 return BINOP;
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
213 {UNOP} {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
214 gpt_quote_is_transpose = false;
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 UNOP;
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 {S} { /* Ignore spaces and tabs outside of character strings. */ }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
220
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
221 . {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
222 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
223 gpt_allow_plotkw = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
224 warning ("unknown token = \"%s\" in plot command", yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
225 return OTHER;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
226 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
227
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
228 %%
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
229
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
230 // ------------------------------------------------------------
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
231 // Interface to external gnuplot process(es), including gnuplot
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
232 // command parser.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
233 // ------------------------------------------------------------
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
234
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
235 // 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
236 static std::string Vgnuplot_binary;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
237
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
238 // Append -title "Figure NN" to the gnuplot command?
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
239 static bool Vgnuplot_use_title_option;
5102
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 // Gnuplot command strings that we use.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
242 static std::string Vgnuplot_command_plot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
243 static std::string Vgnuplot_command_replot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
244 static std::string Vgnuplot_command_splot;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
245 static std::string Vgnuplot_command_using;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
246 static std::string Vgnuplot_command_with;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
247 static std::string Vgnuplot_command_axes;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
248 static std::string Vgnuplot_command_title;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
249 static std::string Vgnuplot_command_end;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
250
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
251 // If TRUE, a replot command is issued automatically each time a plot
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
252 // changes in some way.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
253 static bool Vautomatic_replot;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
254
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
255 // Check if the parser state is such that a plot keyword can occur.
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
256
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 5129
diff changeset
257 static bool
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
258 can_be_plotkw (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
259 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
260 return (gpt_allow_plotkw
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
261 && (gpt_braces == 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
262 && (gpt_brackets == 0)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
263 && (gpt_parens == 0));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
264 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
265
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
266 // Check to see if a character string matches any one of the plot
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
267 // option keywords. Don't match abbreviations for clear, since that's
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
268 // not a gnuplot keyword (users will probably only expect to be able
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
269 // to abbreviate actual gnuplot keywords).
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
270
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
271 static int
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
272 is_plot_keyword (const std::string& s)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
273 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
274 if (almost_match ("title", s, 1))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
275 return TITLE;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
276 else if (almost_match ("using", s, 1))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
277 return USING;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
278 else if (almost_match ("with", s, 1))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
279 return WITH;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
280 else if (almost_match ("axes", s, 2) || almost_match ("axis", s, 2))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
281 return AXES;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
282 else if ("clear" == s)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
283 return CLEAR;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
284 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
285 return 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
286 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
287
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
288 // This is used to handle single-quote delimited strings. Kludge alert.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
289
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
290 static int
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
291 handle_string (char delim)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
292 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
293 static char *buf = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
294
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
295 int c;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
296 bool escape_pending = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
297
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
298 std::string strbuf (1, static_cast<char> (delim));
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
299
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
300 while ((c = yyinput ()) != EOF)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
301 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
302 if (c == '\\')
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
303 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
304 if (escape_pending)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
305 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
306 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
307 escape_pending = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
308 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
309 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
310 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
311 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
312 escape_pending = true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
313 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
314 continue;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
315 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
316 else if (c == '\n')
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
317 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
318 error ("unterminated string constant");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
319 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
320 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
321 else if (c == delim)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
322 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
323 if (escape_pending)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
324 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
325 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
326 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
327 c = yyinput ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
328
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
329 if (c == delim)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
330 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
331 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
332 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
333 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
334 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
335 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
336 yyunput (c, yytext);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
337 strbuf += static_cast<char> (delim);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
338 delete [] buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
339 yytext = strsave (strbuf.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
340 return STRING;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
341 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
342 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
343 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
344 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
345 strbuf += static_cast<char> (c);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
346
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
347 escape_pending = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
348 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
349
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
350 throw gpt_parse_error ("unterminated string");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
351
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
352 return 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
353 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
354
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
355 // (Probably not necessesary, but current Matlab style plot functions
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
356 // break without this (they emit too short gnuplot commands))
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
357
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
358 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
359 plot_style_token (const std::string& s)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
360 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
361 std::string retval;
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 // XXX FIXME XXX -- specify minimum match length for these.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
364 static const char *plot_styles[] =
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 "boxes",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
367 "boxerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
368 "boxxyerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
369 "candlesticks",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
370 "dots",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
371 "errorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
372 "financebars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
373 "fsteps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
374 "histeps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
375 "impulses",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
376 "lines",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
377 "linespoints",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
378 "points",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
379 "steps",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
380 "vector",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
381 "xerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
382 "xyerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
383 "yerrorbars",
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
384 0,
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
385 };
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
386
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
387 const char * const *tmp = plot_styles;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
388 while (*tmp)
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 if (almost_match (*tmp, s.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 retval = *tmp;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
393 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
394 }
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 tmp++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
397 }
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 return retval;
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
402 // Some predicates on tokens
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
403
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
404 // Return true for ":".
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
405
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
406 static bool
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
407 colonp (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
408 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
409 return (tok == COLON);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
410 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
411
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
412 // Return TRUE for "]".
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
413
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
414 static bool
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
415 endbracketp (const int tok)
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 return (tok == END_BRACKET);
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
420 // Return TRUE for plot token, comma or end of input.
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
421
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
422 static bool
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
423 plottok_or_end_p (const int tok)
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 return (tok == TITLE
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
426 || tok == USING
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
427 || tok == WITH
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
428 || tok == AXES
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
429 || tok == CLEAR
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
430 || tok == COMMA
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
431 || tok == 0);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
432 }
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 // Equivalent to (colonp (tok) || plottok_or_end_p (tok)).
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
435
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
436 static bool
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
437 colon_plottok_or_end_p (const int tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
438 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
439 return (tok == COLON || plottok_or_end_p (tok));
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
440 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
441
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
442 // 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
443 // Return the last token in lasttok
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
444
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
445 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
446 read_until (pred test, int& lasttok) throw (gpt_parse_error)
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 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
449
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
450 // We have to maintain balanced delimiters per subexpression too.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
451 int brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
452 int parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
453 int braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
454 std::string s;
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 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
457
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
458 while (tok && ! (test (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
459 && brackets == 0
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
460 && parens == 0
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
461 && braces == 0))
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
462 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
463 switch (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
464 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
465 case START_BRACKET:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
466 brackets++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
467 break;
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 case END_BRACKET:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
470 brackets--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
471 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
472
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
473 case START_PAREN:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
474 parens++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
475 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
476
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
477 case END_PAREN:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
478 parens--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
479 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
480
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
481 case START_BRACE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
482 braces++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
483 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
484
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
485 case END_BRACE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
486 braces--;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
487 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
488
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
489 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
490 break;
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 s += std::string (yytext) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
494
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
495 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
496 }
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 // 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
499 // doesn't accept it.
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 if (! test (tok) && ! tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
502 throw gpt_parse_error ("unexpected end of input");
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 lasttok = tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
505
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
506 return s;
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
509 // Eval the two expressions giving limits of range and print it.
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
510
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
511 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
512 printrange (std::string starts, std::string ends)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
513 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
514 octave_value startv, endv;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
515 int status;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
516 std::string s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
517 OSSTREAM range_buf;
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 range_buf << "[";
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 (! starts.empty ())
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 startv = eval_string (starts, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
524 if (! startv.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
525 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
526 startv.print_raw (range_buf);
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
529 range_buf << ":";
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 if (! ends.empty ())
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 endv = eval_string (ends, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
534 if (! endv.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
535 throw gpt_parse_error ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
536 endv.print_raw (range_buf);
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
539 range_buf << "]";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
540 range_buf << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
541
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
542 s = OSSTREAM_STR (range_buf);
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 return s;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
545 }
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 // Handle plot parameters.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
548
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
549 // Parse, evaluate and print colon separated expressions in the using
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
550 // plot parameter. The use of trailing format string is not supported.
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
551
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
552 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
553 handle_using (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
554 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
555 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
556 std::string expr_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
557 std::string retstr = Vgnuplot_command_using + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
558 bool out = false;
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 octave_value tmp_data;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
561 int status;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
562 while (! out)
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 expr_str = read_until (colon_plottok_or_end_p, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
565
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
566 tmp_data = eval_string (expr_str, true, status);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
567 if (status != 0 || ! tmp_data.is_real_scalar ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
568 throw gpt_parse_error ();
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 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
571 tmp_data.print_raw (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
572 tmp_buf << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
573 retstr += OSSTREAM_STR (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
574
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
575 if (tok == COLON)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
576 retstr += ":";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
577 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
578 out = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
579 }
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 lasttok = tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
582
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
583 return retstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
584 }
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 // Presently just passes the linewidth, pointtype etc. tokens as they are.
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
587
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
588 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
589 handle_style (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
590 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
591 std::string retstr = Vgnuplot_command_with + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
592 std::string style;
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 lasttok = gptlex ();
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 if (lasttok != IDENT)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
597 throw gpt_parse_error ("expected plot style token");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
598
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
599 style = std::string (yytext);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
600 style = plot_style_token (style);
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 if (! style.empty ())
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
603 retstr += style;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
604 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
605 retstr += std::string (yytext);
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 // XXX FIXME XXX -- should evaluate the remaining tokens, but this
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
608 // needs changes in the parser.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
609 retstr += " " + read_until (plottok_or_end_p, lasttok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
610
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
611 return retstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
612 }
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 // Axes has only one qualifier keyword, which is not evaluated.
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
615
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
616 static std::string
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
617 handle_axes (int& lasttok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
618 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
619 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
620 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
621
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
622 static std::string
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
623 save_in_tmp_file (const octave_value& t, int ndim = 2, bool parametric = false)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
624 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
625 std::string name = file_ops::tempnam ("", "oct-");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
626
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
627 if (! name.empty ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
628 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
629 std::ofstream file (name.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
630
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
631 if (file)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
632 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
633 switch (ndim)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
634 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
635 case 2:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
636 save_ascii_data_for_plotting (file, t, name);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
637 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
638
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
639 case 3:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
640 save_three_d (file, t, parametric);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
641 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
642
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
643 default:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
644 gripe_2_or_3_dim_plot ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
645 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
646 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
647 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
648 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
649 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
650 error ("couldn't open temporary output file `%s'", name.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
651 name.resize (0);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
652 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
653 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
654
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
655 return name;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
656 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
657
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
658 static int
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
659 get_current_figure (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
660 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
661 int retval = 1;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
662
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
663 octave_value cf = get_global_value ("__current_figure__", true);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
664
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
665 if (cf.is_defined ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
666 retval = cf.int_value ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
667 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
668 set_global_value ("__current_figure__", retval);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
669
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
670 return retval;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
671 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
672
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
673 class
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
674 gnuplot
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
675 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
676 protected:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
677
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
678 gnuplot (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
679 : plot_line_count (0), parametric_plot (false),
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
680 use_title_option (Vgnuplot_use_title_option),
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
681 gnuplot_exe (Vgnuplot_binary),
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
682 gnuplot_terminal_type (), plot_stream ()
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
683 { }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
684
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
685 public:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
686
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
687 ~gnuplot (void) { }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
688
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
689 static bool have_instance (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
690
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
691 static bool ensure_instance (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
692
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
693 static bool ensure_plot_stream (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
694
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
695 static void open (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
696
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
697 static void close (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
698
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
699 static bool plot_stream_event_handler (pid_t pid, int status);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
700
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
701 static void init (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
702 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
703 if (ensure_instance ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
704 instance->do_init ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
705 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
706
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
707 static void send (const std::string& cmd)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
708 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
709 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
710 instance->do_send (cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
711 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
712
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
713 static void send_raw (const std::string& cmd)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
714 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
715 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
716 instance->do_send_raw (cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
717 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
718
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
719 static void clear (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
720 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
721 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
722 instance->do_clear ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
723 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
724
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
725 static void set (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
726 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
727 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
728 instance->do_set (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
729 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
730
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
731 static void show (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
732 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
733 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
734 instance->do_show (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
735 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
736
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
737 // XXX FIXME XXX -- should only remove tmp files associated with
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
738 // gnuplot?
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
739 static void cleanup_tmp_files (void) { ::cleanup_tmp_files (); }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
740
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
741 static void plot (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
742 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
743 if (ensure_plot_stream ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
744 instance->do_plot (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
745 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
746
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
747 private:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
748
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
749 static gnuplot *instance;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
750
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
751 static std::map<int, gnuplot *> instance_map;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
752
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
753 // The number of lines we've plotted so far.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
754 int plot_line_count;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
755
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
756 // Is this a parametric plot? Makes a difference for 3D plotting.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
757 bool parametric_plot;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
758
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
759 // Should we append '-title "TITLE"' to the gnuplot command?
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
760 bool use_title_option;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
761
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
762 // The executable program to run.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
763 std::string gnuplot_exe;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
764
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
765 // The gnuplot terminal type.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
766 std::string gnuplot_terminal_type;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
767
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
768 // Pipe to gnuplot.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
769 oprocstream *plot_stream;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
770
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
771 pid_t pid (void) const;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
772
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
773 static gnuplot *lookup_by_pid (pid_t pid);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
774
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
775 void do_open (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
776
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
777 void do_close (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
778
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
779 void delete_plot_stream (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
780
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
781 void reset_plot_stream (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
782
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
783 void do_send (const std::string& cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
784
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
785 void do_send_raw (const std::string& cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
786
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
787 void do_clear (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
788
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
789 void do_set (const string_vector& argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
790
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
791 void do_show (const string_vector& argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
792
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
793 void do_plot (const string_vector& argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
794
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
795 void do_init (void);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
796
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
797 std::string
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
798 makeplot (std::string caller, std::string args) throw (gpt_parse_error);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
799
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
800 std::string gnuplot::handle_title (int& lasttok);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
801 };
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
802
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
803 gnuplot *gnuplot::instance = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
804
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
805 std::map<int, gnuplot *> gnuplot::instance_map;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
806
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
807 bool
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
808 gnuplot::have_instance (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
809 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
810 int current_figure = get_current_figure ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
811
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
812 if (instance_map.find (current_figure) != instance_map.end ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
813 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
814 instance = instance_map[current_figure];
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
815 return true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
816 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
817 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
818 return false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
819 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
820
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
821 bool
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
822 gnuplot::ensure_instance (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
823 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
824 if (! have_instance ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
825 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
826 instance = new gnuplot ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
827
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
828 if (! instance)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
829 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
830 ::error ("unable to create gnuplot object!");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
831
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
832 return false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
833 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
834 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
835 instance_map[get_current_figure ()] = instance;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
836 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
837
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
838 return true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
839 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
840
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
841 bool
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
842 gnuplot::ensure_plot_stream (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
843 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
844 if (ensure_instance ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
845 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
846 instance->do_open ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
847
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
848 if (error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
849 return false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
850 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
851
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
852 return true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
853 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
854
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
855 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
856 gnuplot::close (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
857 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
858 if (have_instance ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
859 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
860 instance->do_close ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
861
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
862 instance_map.erase (get_current_figure ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
863 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
864 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
865
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
866 pid_t
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
867 gnuplot::pid (void) const
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
868 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
869 return plot_stream ? plot_stream->pid () : -1;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
870 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
871
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
872 gnuplot *
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
873 gnuplot::lookup_by_pid (pid_t pid)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
874 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
875 gnuplot *retval = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
876
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
877 for (std::map<int, gnuplot *>::const_iterator p = instance_map.begin ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
878 p != instance_map.end ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
879 p++)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
880 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
881 gnuplot *elt = p->second;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
882
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
883 if (elt && elt->pid () == pid)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
884 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
885 retval = elt;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
886 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
887 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
888 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
889
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
890 return retval;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
891 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
892
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
893 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
894 gnuplot::do_open (void)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
895 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
896 static bool initialized = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
897
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
898 if (plot_stream && ! *plot_stream)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
899 do_close ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
900
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
901 if (! plot_stream)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
902 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
903 initialized = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
904
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
905 plot_line_count = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
906
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
907 std::string cmd;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
908
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
909 if (gnuplot_exe.empty ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
910 cmd = "gnuplot";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
911 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
912 cmd = "\"" + gnuplot_exe + "\"";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
913
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
914 // XXX FIXME XXX -- I'm not sure this is the right thing to do,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
915 // but without it, C-c at the octave prompt will kill gnuplot...
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
916
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
917 #if defined (HAVE_POSIX_SIGNALS)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
918 sigset_t nset, oset;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
919 sigemptyset (&nset);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
920 sigaddset (&nset, SIGINT);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
921 sigprocmask (SIG_BLOCK, &nset, &oset);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
922 #else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
923 volatile octave_interrupt_handler old_interrupt_handler
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
924 = octave_ignore_interrupts ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
925 #endif
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
926
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
927 if (use_title_option)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
928 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
929 OSSTREAM buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
930
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
931 buf << cmd
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
932 << " -title \"Figure " << get_current_figure () << "\""
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
933 << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
934
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
935 cmd = OSSTREAM_STR (buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
936
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
937 OSSTREAM_FREEZE (buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
938 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
939
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
940 plot_stream = new oprocstream (cmd.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
941
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
942 if (plot_stream && *plot_stream)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
943 octave_child_list::insert (plot_stream->pid (),
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
944 plot_stream_event_handler);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
945 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
946 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
947 delete_plot_stream ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
948
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
949 error ("plot: unable to open pipe to `%s'", cmd.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
950 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
951
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
952 #if defined (HAVE_POSIX_SIGNALS)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
953 sigprocmask (SIG_SETMASK, &oset, 0);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
954 #else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
955 octave_set_interrupt_handler (old_interrupt_handler);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
956 #endif
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
957 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
958
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
959 if (! error_state && plot_stream && *plot_stream && ! initialized)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
960 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
961 initialized = true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
962
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
963 do_send_raw ("set style data lines\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
964
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
965 if (! gnuplot_terminal_type.empty ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
966 do_send_raw ("set term " + gnuplot_terminal_type
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
967 + Vgnuplot_command_end + "\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
968 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
969 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
970
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
971 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
972 gnuplot::delete_plot_stream (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
973 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
974 do_send_raw ("\nquit\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
975
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
976 delete plot_stream;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
977 plot_stream = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
978 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
979
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
980 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
981 gnuplot::reset_plot_stream (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
982 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
983 delete_plot_stream ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
984
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
985 plot_line_count = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
986 parametric_plot = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
987 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
988
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
989 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
990 gnuplot::do_close (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
991 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
992 if (plot_stream)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
993 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
994 octave_child_list::remove (plot_stream->pid ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
995
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
996 delete_plot_stream ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
997 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
998
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
999 plot_line_count = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1000 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1001
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1002 bool
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1003 gnuplot::plot_stream_event_handler (pid_t pid, int status)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1004 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1005 bool retval = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1006
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1007 if (pid > 0)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1008 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1009 if (WIFEXITED (status) || WIFSIGNALLED (status))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1010 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1011 gnuplot *plotter = gnuplot::lookup_by_pid (pid);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1012
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1013 // We should only print a warning or request removal of the
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1014 // process from the child list if the process died
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1015 // unexpectedly. If do_close is responsible for
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1016 // gnuplot's death, then plotter will be 0 here and we don't
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1017 // need to do anything.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1018
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1019 if (plotter)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1020 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1021 plotter->reset_plot_stream ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1022
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1023 warning ("connection to external plotter (pid = %d) lost --", pid);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1024 // Request removal of this PID from the list of child
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1025 // processes.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1026
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1027 retval = true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1028 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1029 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1030 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1031
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1032 return retval;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1033 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1034
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1035 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1036 gnuplot::do_send (const std::string& cmd)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1037 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1038 int replot_len = Vgnuplot_command_replot.length ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1039
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1040 bool is_replot = (Vgnuplot_command_replot == cmd.substr (0, replot_len));
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1041
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1042 if (! (plot_line_count == 0 && is_replot))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1043 do_send_raw (cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1044 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1045
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1046 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1047 gnuplot::do_send_raw (const std::string& cmd)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1048 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1049 if (plot_stream && *plot_stream)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1050 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1051 *plot_stream << cmd;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1052
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1053 plot_stream->flush ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1054 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1055 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1056
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1057 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1058 gnuplot::do_clear (void)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1059 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1060 do_send_raw ("clear\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1061
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1062 // XXX FIXME XXX -- instead of just clearing these things, it would
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1063 // be nice if we could reset things to a user-specified default
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1064 // state.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1065
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1066 do_send_raw ("set title\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1067 do_send_raw ("set xlabel\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1068 do_send_raw ("set ylabel\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1069 do_send_raw ("set nogrid\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1070 do_send_raw ("set nolabel\n");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1071
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1072 // This makes a simple `replot' not work after a `clearplot' command
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1073 // has been issued.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1074
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1075 plot_line_count = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1076 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1077
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1078 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1079 gnuplot::do_set (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1080 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1081 int argc = argv.length ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1082
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1083 OSSTREAM plot_buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1084
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1085 if (argc > 1)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1086 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1087 if (almost_match ("parametric", argv[1], 3))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1088 parametric_plot = true;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1089 else if (almost_match ("noparametric", argv[1], 5))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1090 parametric_plot = false;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1091 else if (almost_match ("term", argv[1], 1))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1092 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1093 gnuplot_terminal_type = "";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1094 OSSTREAM buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1095 int i;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1096 for (i = 2; i < argc-1; i++)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1097 buf << argv[i] << " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1098 if (i < argc)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1099 buf << argv[i];
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1100 buf << Vgnuplot_command_end << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1101 gnuplot_terminal_type = OSSTREAM_STR (buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1102 OSSTREAM_FREEZE (buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1103 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1104 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1105
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1106 int i;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1107 for (i = 0; i < argc-1; i++)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1108 plot_buf << argv[i] << " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1109
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1110 if (i < argc)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1111 plot_buf << argv[i];
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1112
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1113 plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1114
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1115 do_send_raw (OSSTREAM_STR (plot_buf));
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1116
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1117 OSSTREAM_FREEZE (plot_buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1118 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1119
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1120 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1121 gnuplot::do_show (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1122 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1123 int argc = argv.length ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1124
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1125 OSSTREAM plot_buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1126
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1127 int i;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1128 for (i = 0; i < argc-1; i++)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1129 plot_buf << argv[i] << " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1130 if (i < argc)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1131 plot_buf << argv[i];
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1132
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1133 plot_buf << Vgnuplot_command_end << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1134
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1135 do_send (OSSTREAM_STR (plot_buf));
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1136
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1137 OSSTREAM_FREEZE (plot_buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1138 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1139
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1140 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1141 gnuplot::do_plot (const string_vector& argv)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1142 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1143 std::string s;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1144
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1145 for (int i = 1; i < argv.length (); i++)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1146 s += argv[i] + " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1147
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1148 try
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1149 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1150 std::string cmd = makeplot (argv[0], s);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1151
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1152 do_send (cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1153 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1154 catch (gpt_parse_error& e)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1155 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1156 if (e.msg.empty ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1157 error ("could not parse plot command");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1158 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1159 error (e.msg.c_str ());
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1160 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1161 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1162
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1163 // Parse and evaluate parameter string and pass it to gnuplot pipe.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1164
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1165 std::string
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1166 gnuplot::makeplot (std::string caller, std::string args)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1167 throw (gpt_parse_error)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1168 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1169 std::string retval;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1170
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1171 YY_BUFFER_STATE bstate;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1172
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1173 bstate = yy_scan_string (args.c_str ());
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1174 yy_switch_to_buffer (bstate);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1175 std::string outstr;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1176 int ndim = 2;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1177
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1178 if (caller == "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1179 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1180 ndim = 1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1181 outstr += Vgnuplot_command_replot + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1182 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1183 else if (caller == "plot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1184 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1185 ndim = 2;
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
1186 plot_line_count = 0;
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
1187 outstr += Vgnuplot_command_plot + " ";
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1188 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1189 else if (caller == "splot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1190 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1191 ndim = 3;
5406
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
1192 plot_line_count = 0;
c49aec8a9080 [project @ 2005-07-08 15:25:43 by jwe]
jwe
parents: 5311
diff changeset
1193 outstr += Vgnuplot_command_splot + " ";
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1194 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1195 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1196 throw gpt_parse_error ("unknown plot command");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1197
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1198 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1199 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1200 gpt_parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1201 gpt_braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1202 gpt_brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1203
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1204 int tok;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1205 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1206 if (plottok_or_end_p (tok) && caller != "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1207 throw gpt_parse_error ("must have something to plot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1208
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1209 while (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1210 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1211 bool title_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1212 bool using_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1213 bool style_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1214 bool axes_set = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1215
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1216 if (tok == START_BRACKET)
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 if (caller == "replot")
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1219 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
1220
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1221 std::string xrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1222 std::string xrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1223 outstr += printrange (xrange_start_str, xrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1224 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1225 if (tok == START_BRACKET)
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 std::string yrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1228 std::string yrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1229 outstr += printrange (yrange_start_str, yrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1230 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1231 if (tok == START_BRACKET && caller == "gsplot")
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 std::string zrange_start_str = read_until (colonp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1234 std::string zrange_end_str = read_until (endbracketp, tok);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1235 outstr += printrange (zrange_start_str, zrange_end_str) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1236 tok = gptlex ();
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 }
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1241 if (plottok_or_end_p (tok))
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1242 return std::string ();
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1243 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1244 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1245 std::string file;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1246 plot_line_count++;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1247
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1248 std::string plot_expr_str;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1249 plot_expr_str += std::string (yytext) + " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1250 plot_expr_str += read_until (plottok_or_end_p, tok);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1251
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1252 int status = 0;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1253 octave_value tmp_data = eval_string (plot_expr_str,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1254 true, status);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1255
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1256 if (status != 0 || ! tmp_data.is_defined ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1257 throw gpt_parse_error ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1258
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1259 OSSTREAM tmp_buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1260 tmp_data.print_raw (tmp_buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1261 tmp_buf << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1262
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1263 if (tmp_data.is_string ())
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1264 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1265 file = file_ops::tilde_expand (tmp_data.string_value ());
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1266 // XXX FIXME XXX -- perhaps should check if the file exists?
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1267 outstr += file + " ";
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1268 }
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1269 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1270 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1271 switch (ndim)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1272 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1273 case 2:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1274 file = save_in_tmp_file (tmp_data, ndim);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1275 break;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1276
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1277 case 3:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1278 file = save_in_tmp_file (tmp_data, ndim,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1279 parametric_plot);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1280 break;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1281
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1282 default:
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1283 gripe_2_or_3_dim_plot ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1284 break;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1285 }
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1286
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1287 if (file.length () > 0)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1288 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1289 mark_for_deletion (file);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1290 outstr += "'" + file + "' ";
5152
b111ca4715c6 [project @ 2005-02-21 19:41:23 by jwe]
jwe
parents: 5142
diff changeset
1291 }
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1292 }
5102
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1295 std::string title_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1296 std::string using_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1297 std::string style_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1298 std::string axes_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1299
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1300 bool out = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1301 while (tok && ! out)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1302 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1303 switch (tok)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1304 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1305 case COMMA:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1306 out = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1307 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1308
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1309 case TITLE:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1310 if (! title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1311 title_str += handle_title (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1312 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1313 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
1314 title_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1315 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1316
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1317 case USING:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1318 if (! using_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1319 using_str += handle_using (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1320 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1321 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
1322 using_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1323 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1324
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1325 case WITH:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1326 if (! style_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1327 style_str += handle_style (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1328 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1329 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
1330 style_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1331 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1332
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1333 case AXES:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1334 if (! axes_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1335 axes_str += handle_axes (tok) + " ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1336 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1337 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
1338 axes_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1339 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1340
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1341 default:
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1342 tok = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1343 break;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1344 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1345 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1346
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1347 if (! title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1348 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1349 OSSTREAM tmp_buf;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1350 tmp_buf << Vgnuplot_command_title << " \"line "
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1351 << plot_line_count << "\" " << OSSTREAM_ENDS;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1352 title_str = OSSTREAM_STR (tmp_buf);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1353 title_set = true;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1354 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1355
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1356 // Plot parameters have to be output in this order.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1357 if (using_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1358 outstr += using_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1359
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1360 if (axes_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1361 outstr += axes_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1362
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1363 if (title_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1364 outstr += title_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1365
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1366 if (style_set)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1367 outstr += style_str;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1368
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1369 if (out)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1370 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1371 // Saw comma on while loop.
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1372 outstr += ", ";
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1373 gpt_quote_is_transpose = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1374 gpt_allow_plotkw = false;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1375 gpt_parens = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1376 gpt_braces = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1377 gpt_brackets = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1378 tok = gptlex ();
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1379 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1380 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1381
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1382 outstr += Vgnuplot_command_end;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1383
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1384 return outstr;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1385 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1386
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1387 // Title has one string expression which is evaluated and printed to the
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1388 // gnuplot command string.
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1389
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1390 std::string
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1391 gnuplot::handle_title (int& lasttok)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1392 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1393 int tok;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1394 std::string retstr = Vgnuplot_command_title + " ";
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1395 std::string title_expr_str;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1396
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1397 title_expr_str += read_until (plottok_or_end_p, tok);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1398
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1399 int status;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1400 octave_value tmp_data = eval_string (title_expr_str, true, status);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1401
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1402 if (status != 0 || ! tmp_data.is_defined ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1403 throw gpt_parse_error ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1404
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1405 OSSTREAM tmp_buf;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1406 if (tmp_data.is_string ())
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1407 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1408 tmp_buf << '"';
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1409 tmp_data.print_raw (tmp_buf);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1410 tmp_buf << '"' << OSSTREAM_ENDS;
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1411 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1412 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1413 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1414 warning ("line title must be a string");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1415 tmp_buf << '"' << "line " << plot_line_count << '"';
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1416 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1417
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1418 retstr += OSSTREAM_STR (tmp_buf);
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1419
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1420 lasttok = tok;
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1421
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1422 return retstr;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1423 }
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 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1426 automatic_replot (void)
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 Vautomatic_replot = check_preference ("automatic_replot");
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 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1431 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1432
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1433 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1434 set_string_var (std::string& var, const char *nm)
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 int retval = 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1437
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1438 std::string s = builtin_string_variable (nm);
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 if (s.empty ())
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 gripe_invalid_value_specified (nm);
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1443 retval = -1;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1444 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1445 else
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1446 var = s;
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 return retval;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1449 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1450
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1451 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1452 gnuplot_binary (void)
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 return set_string_var (Vgnuplot_binary, "gnuplot_binary");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1455 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1456
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1457 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1458 gnuplot_command_plot (void)
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 return set_string_var (Vgnuplot_command_plot, "gnuplot_command_plot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1461 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1462
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1463 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1464 gnuplot_command_replot (void)
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 return set_string_var (Vgnuplot_command_replot, "gnuplot_command_replot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1467 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1468
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1469 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1470 gnuplot_command_splot (void)
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 return set_string_var (Vgnuplot_command_splot, "gnuplot_command_splot");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1473 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1474
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1475 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1476 gnuplot_command_using (void)
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 return set_string_var (Vgnuplot_command_using, "gnuplot_command_using");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1479 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1480
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1481 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1482 gnuplot_command_with (void)
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 return set_string_var (Vgnuplot_command_with, "gnuplot_command_with");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1485 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1486
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1487 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1488 gnuplot_command_axes (void)
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 set_string_var (Vgnuplot_command_axes, "gnuplot_command_axes");
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
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1493 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1494 gnuplot_command_title (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1495 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1496 return set_string_var (Vgnuplot_command_title, "gnuplot_command_title");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1497 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1498
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1499 static int
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1500 gnuplot_command_end (void)
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1501 {
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1502 return set_string_var (Vgnuplot_command_end, "gnuplot_command_end");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1503 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1504
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1505 static int
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1506 gnuplot_use_title_option (void)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1507 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1508 Vgnuplot_use_title_option = check_preference ("gnuplot_use_title_option");
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1509
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1510 return 0;
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1511 }
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1512
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1513 void
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1514 gnuplot::do_init (void)
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1515 {
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1516 static bool gnuplot_initialized = false;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1517
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1518 if (gnuplot_initialized)
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1519 return;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1520
5215
32c569794216 [project @ 2005-03-16 18:54:42 by jwe]
jwe
parents: 5152
diff changeset
1521 gnuplot_initialized = true;
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1522
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1523 if (is_builtin_variable ("automatic_replot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1524 automatic_replot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1525 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1526 DEFVAR (automatic_replot, true, automatic_replot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1527 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1528 @defvr {Built-in Variable} automatic_replot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1529 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
1530 changes by setting the value of the builtin variable\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1531 @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
1532 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
1533 compatibility with Matlab.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1534 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1535
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1536 if (is_builtin_variable ("gnuplot_binary"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1537 gnuplot_binary ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1538 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1539 DEFVAR (gnuplot_binary, GNUPLOT_BINARY, gnuplot_binary,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1540 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1541 @defvr {Built-in Variable} gnuplot_binary\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1542 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
1543 is @code{\"gnuplot\"}. @xref{Installation}.\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1544 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1545
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1546 if (is_builtin_variable ("gnuplot_command_plot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1547 gnuplot_command_plot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1548 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1549 DEFVAR (gnuplot_command_plot, "pl", gnuplot_command_plot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1550 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1551 @defvr {Built-in Variable} gnuplot_command_plot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1552 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1553
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1554 if (is_builtin_variable ("gnuplot_command_replot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1555 gnuplot_command_replot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1556 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1557 DEFVAR (gnuplot_command_replot, "rep", gnuplot_command_replot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1558 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1559 @defvr {Built-in Variable} gnuplot_command_replot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1560 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1561
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1562 if (is_builtin_variable ("gnuplot_command_splot"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1563 gnuplot_command_splot ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1564 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1565 DEFVAR (gnuplot_command_splot, "sp", gnuplot_command_splot,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1566 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1567 @defvr {Built-in Variable} gnuplot_command_splot\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1568 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1569
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1570 if (is_builtin_variable ("gnuplot_command_using"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1571 gnuplot_command_using ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1572 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1573 DEFVAR (gnuplot_command_using, "u", gnuplot_command_using,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1574 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1575 @defvr {Built-in Variable} gnuplot_command_using\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1576 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1577
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1578 if (is_builtin_variable ("gnuplot_command_with"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1579 gnuplot_command_with ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1580 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1581 DEFVAR (gnuplot_command_with, "w", gnuplot_command_with,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1582 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1583 @defvr {Built-in Variable} gnuplot_command_with\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1584 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1585
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1586 if (is_builtin_variable ("gnuplot_command_axes"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1587 gnuplot_command_axes ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1588 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1589 DEFVAR (gnuplot_command_axes, "ax", gnuplot_command_axes,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1590 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1591 @defvr {Built-in Variable} gnuplot_command_axes\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1592 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1593
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1594 if (is_builtin_variable ("gnuplot_command_title"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1595 gnuplot_command_title ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1596 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1597 DEFVAR (gnuplot_command_title, "t", gnuplot_command_title,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1598 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1599 @defvr {Built-in Variable} gnuplot_command_title\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1600 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1601
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1602 if (is_builtin_variable ("gnuplot_command_end"))
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1603 gnuplot_command_end ();
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1604 else
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1605 DEFVAR (gnuplot_command_end, "\n", gnuplot_command_end,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1606 "-*- texinfo -*-\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1607 @defvr {Built-in Variable} gnuplot_command_end\n\
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1608 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1609
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1610 if (is_builtin_variable ("gnuplot_use_title_option"))
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1611 gnuplot_use_title_option ();
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1612 else
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1613 DEFVAR (gnuplot_use_title_option, octave_env::have_x11_display (),
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1614 gnuplot_use_title_option,
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1615 "-*- texinfo -*-\n\
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1616 @defvr {Built-in Variable} gnuplot_use_title_option\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1617 If nonzero, append @samp{-title \"Figure NN\"} to the gnuplot command.\n\
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1618 @end defvr");
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1619
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1620 }
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1621
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1622 // -----------------------
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1623 // User-callable functions
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1624 // -----------------------
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1625
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1626 DEFUN_DLD (__gnuplot_init__, , ,
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1627 "-*- texinfo -*-\n\
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1628 @deftypefn {Loadable Function} __gnuplot_init__ ()\n\
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1629 @end deftypefn")
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1630 {
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1631 gnuplot::init ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1632
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1633 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1634 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1635
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1636 DEFUN_DLD (clearplot, , ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1637 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1638 @deftypefn {Built-in Function} {} clearplot\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1639 @deftypefnx {Built-in Function} {} clg\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1640 Clear the plot window and any titles or axis labels. The name\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1641 @code{clg} is aliased to @code{clearplot} for compatibility with\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1642 @sc{Matlab}.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1643 @end deftypefn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1644 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1645 gnuplot::clear ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1646
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1647 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1648 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1649
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1650 DEFUN_DLD (closeplot, , ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1651 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1652 @deftypefn {Built-in Function} {} closeplot\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1653 Close stream to the @code{gnuplot} subprocess. If you are using X11,\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1654 this will close the plot window.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1655 @end deftypefn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1656 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1657 gnuplot::close ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1658
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1659 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1660 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1661
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1662 DEFUN_DLD (purge_tmp_files, , ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1663 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1664 @deftypefn {Built-in Function} {} purge_tmp_files\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1665 Delete the temporary files created by the plotting commands.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1666 \n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1667 Octave creates temporary data files for @code{gnuplot} and then sends\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1668 commands to @code{gnuplot} through a pipe. Octave will delete the\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1669 temporary files on exit, but if you are doing a lot of plotting you may\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1670 want to clean up in the middle of a session.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1671 \n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1672 A future version of Octave will eliminate the need to use temporary\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1673 files to hold the plot data.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1674 @end deftypefn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1675 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1676 gnuplot::cleanup_tmp_files ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1677
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1678 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1679 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1680
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1681 DEFUN_DLD (__gnuplot_raw__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1682 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1683 @deftypefn {Built-in Function} {} __gnuplot_raw__ (@var{string})\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1684 Send @var{string} directly to gnuplot subprocess.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1685 @end deftypefn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1686 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1687 if (args.length () == 1 && args(0).is_string ())
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1688 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1689 std::string cmd = args(0).string_value ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1690
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1691 gnuplot::send_raw (cmd);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1692 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1693 else
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1694 print_usage ("raw");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1695
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1696 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1697 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1698
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1699 DEFUN_DLD (__gnuplot_set__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1700 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1701 @deffn {Command} __gnuplot_set__ options\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1702 Set plotting options for gnuplot\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1703 @end deffn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1704 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1705 string_vector argv = args.make_argv ("set");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1706
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1707 if (! error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1708 gnuplot::set (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1709
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1710 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1711 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1712
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1713 DEFUN_DLD (__gnuplot_show__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1714 "-*- texinfo -*-\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1715 @deffn {Command} __gnuplot_show__ options\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1716 Show plotting options.\n\
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1717 @end deffn")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1718 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1719 string_vector argv = args.make_argv ("show");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1720
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1721 if (! error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1722 gnuplot::show (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1723
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1724 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1725 }
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1726
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1727 DEFUN_DLD (__gnuplot_plot__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1728 "Plot with gnuplot.\n")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1729 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1730 string_vector argv = args.make_argv ("plot");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1731
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1732 if (! error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1733 gnuplot::plot (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1734
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1735 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1736 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1737
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1738 DEFUN_DLD (__gnuplot_splot__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1739 "Plot with gnuplot.\n")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1740 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1741 string_vector argv = args.make_argv ("splot");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1742
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1743 if (! error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1744 gnuplot::plot (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1745
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1746 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1747 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1748
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1749 DEFUN_DLD (__gnuplot_replot__, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1750 "Plot with gnuplot.\n")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1751 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1752 string_vector argv = args.make_argv ("replot");
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1753
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1754 if (! error_state)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1755 gnuplot::plot (argv);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1756
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1757 return octave_value_list ();
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1758 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1759
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1760 // --------------------
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1761 // Deprecated functions
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1762 // --------------------
5311
46de0f964c1b [project @ 2005-04-27 21:05:43 by jwe]
jwe
parents: 5251
diff changeset
1763
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1764 #define WARN_DEPRECATED(FOLD, FNEW) \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1765 do \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1766 { \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1767 static bool warned = false; \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1768 if (! warned) \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1769 { \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1770 warned = true; \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1771 warning (#FOLD " is deprecated and will be removed from a future"); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1772 warning ("version of Octave."); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1773 warning ("You should use the higher-level plot functions"); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1774 warning ("(\"plot\", \"mesh\", \"semilogx\", etc.) instead"); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1775 warning ("of the low-level plotting commands."); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1776 warning ("If you absolutely must use this function, use the"); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1777 warning ("internal version " #FNEW " instead."); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1778 } \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1779 } \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1780 while (0)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1781
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1782 #define DEPRECATED_BODY(FOLD, FNEW) \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1783 WARN_DEPRECATED (FOLD, FNEW); \
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1784 return feval (#FNEW, args)
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1785
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1786 // We can't further simplify this by putting the DEFUN_DLD in a macro
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1787 // because then the mk-oct-links script will fail.
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1788
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1789 DEFUN_DLD (gplot, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1790 "")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1791 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1792 DEPRECATED_BODY (gplot, __gnuplot_plot__);
5102
b04b30d30c66 [project @ 2004-12-28 01:59:05 by jwe]
jwe
parents:
diff changeset
1793 }
5489
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1794
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1795 DEFUN_DLD (gsplot, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1796 "")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1797 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1798 DEPRECATED_BODY (gsplot, __gnuplot_splot__);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1799 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1800
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1801 DEFUN_DLD (graw, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1802 "")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1803 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1804 DEPRECATED_BODY (graw, __gnuplot_raw__);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1805 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1806
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1807 DEFUN_DLD (gset, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1808 "")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1809 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1810 DEPRECATED_BODY (gset, __gnuplot_set__);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1811 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1812
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1813 DEFUN_DLD (gshow, args, ,
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1814 "")
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1815 {
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1816 DEPRECATED_BODY (gshow, __gnuplot_show__);
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1817 }
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1818
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1819 /*
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1820 ;;; Local Variables: ***
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1821 ;;; mode: C++ ***
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1822 ;;; End: ***
250917610b55 [project @ 2005-10-12 23:53:36 by jwe]
jwe
parents: 5406
diff changeset
1823 */