annotate libinterp/dldfcn/__init_gnuplot__.cc @ 19646:408361a8c72f

Don't register gnuplot toolkit if gnuplot is not available (bug #35391) * __init_gnuplot__.cc (F__have_gnuplot__, have_gnuplot_binary): New functions to test for existence of gnuplot external program. (PKG_ADD): Don't register gnuplot toolkit unless gnuplot binary is available. (F__init_gnuplot): Error if gnuplot binary is not available. * graphics.cc (gtk_manager::do_get_toolkit): Provide better error message if no graphics toolkits are available.
author Mike Miller <mtmiller@ieee.org>
date Sat, 31 Jan 2015 02:42:15 -0500
parents 175b392e91fe
children 830c8457295a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 15423
diff changeset
3 Copyright (C) 2007-2013 John W. Eaton
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 /*
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 To initialize:
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 graphics_toolkit ("gnuplot");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 plot (randn (1e3, 1));
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 */
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #ifdef HAVE_CONFIG_H
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <config.h>
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #endif
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
36 #include "builtins.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "defun-dld.h"
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "error.h"
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
39 #include "file-stat.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "graphics.h"
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
41 #include "oct-env.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "parse.h"
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
43 #include "utils.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "variables.h"
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
46 // PKG_ADD: if (__have_gnuplot__ ()) register_graphics_toolkit ("gnuplot"); endif
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 static bool toolkit_loaded = false;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 class gnuplot_graphics_toolkit : public base_graphics_toolkit
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 public:
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 gnuplot_graphics_toolkit (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
54 : base_graphics_toolkit ("gnuplot") { }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 ~gnuplot_graphics_toolkit (void) { }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 bool is_valid (void) const { return true; }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 bool initialize (const graphics_object& go)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
61 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
62 return go.isa ("figure");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
63 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 void finalize (const graphics_object& go)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
66 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
67 if (go.isa ("figure"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
68 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
69 const figure::properties& props =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 dynamic_cast<const figure::properties&> (go.get_properties ());
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
72 send_quit (props.get___plot_stream__ ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
73 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
74 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 void update (const graphics_object& go, int id)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
77 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 if (go.isa ("figure"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 graphics_object obj (go);
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
82 figure::properties& props =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
83 dynamic_cast<figure::properties&> (obj.get_properties ());
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
85 switch (id)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
86 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
87 case base_properties::ID_VISIBLE:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
88 if (! props.is_visible ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
89 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
90 send_quit (props.get___plot_stream__ ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
91 props.set___plot_stream__ (Matrix ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
92 props.set___enhanced__ (false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
93 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
94 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
95 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
96 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
97 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 void redraw_figure (const graphics_object& go) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
100 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
101 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
102 args(0) = go.get_handle ().as_octave_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
103 feval ("__gnuplot_drawnow__", args);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
104 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 void print_figure (const graphics_object& go, const std::string& term,
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 const std::string& file, bool mono,
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 const std::string& debug_file) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
109 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
110 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
111 if (! debug_file.empty ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
112 args(4) = debug_file;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 args(3) = mono;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
114 args(2) = file;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
115 args(1) = term;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
116 args(0) = go.get_handle ().as_octave_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
117 feval ("__gnuplot_drawnow__", args);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
118 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 Matrix get_canvas_size (const graphics_handle&) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
121 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
122 Matrix sz (1, 2, 0.0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
123 return sz;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
124 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 double get_screen_resolution (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
127 { return 72.0; }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 Matrix get_screen_size (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
130 { return Matrix (1, 2, 0.0); }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 void close (void)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 if (toolkit_loaded)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 munlock ("__init_gnuplot__");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 gtk_manager::unload_toolkit ("gnuplot");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 toolkit_loaded = false;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144 private:
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 void send_quit (const octave_value& pstream) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
147 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
148 if (! pstream.is_empty ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
150 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
151 Matrix fids = pstream.matrix_value ();
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
153 if (! error_state)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
154 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
155 Ffputs (ovl (fids(0), "\nquit;\n"));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
157 Ffflush (ovl (fids(0)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
158 Fpclose (ovl (fids(0)));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
160 if (fids.numel () > 1)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
161 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
162 Fpclose (ovl (fids(1)));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
164 if (fids.numel () > 2)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
165 Fwaitpid (ovl (fids(2)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
166 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
167 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
168 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
169 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 };
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
172 static bool
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
173 have_gnuplot_binary (void)
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
174 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
175 octave_value_list tmp = feval ("gnuplot_binary", octave_value_list ());
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
176 std::string gnuplot_binary = tmp(0).string_value ();
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
177
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
178 std::string path = octave_env::getenv ("PATH");
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
179
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
180 string_vector args (gnuplot_binary);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
181 std::string gnuplot_path = search_path_for_file (path, args);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
182
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
183 file_stat fs (gnuplot_path);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
184
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
185 return fs.exists ();
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
186 }
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
187
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
188 // Initialize the gnuplot graphics toolkit.
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 DEFUN_DLD (__init_gnuplot__, , , "")
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 octave_value retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
194 if (! have_gnuplot_binary ())
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
195 error ("__init_gnuplot__: the gnuplot program is not available, see 'gnuplot_binary'");
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
196 else if (! toolkit_loaded)
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198 mlock ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 graphics_toolkit tk (new gnuplot_graphics_toolkit ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 gtk_manager::load_toolkit (tk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203 toolkit_loaded = true;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208
19646
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
209 DEFUN_DLD (__have_gnuplot__, , ,
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
210 "-*- texinfo -*-\n\
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
211 @deftypefn {Loadable Function} {@var{gnuplot_available} =} __have_gnuplot__ ()\n\
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
212 Undocumented internal function.\n\
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
213 @end deftypefn")
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
214 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
215 octave_value retval;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
216
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
217 retval = have_gnuplot_binary ();
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
218
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
219 return retval;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
220 }
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
221