annotate libinterp/dldfcn/__init_gnuplot__.cc @ 20267:a9574e3c6e9e

Deprecate Array::length() and Sparse::length() in favour of ::numel(). * liboctave/array/Array.h (Array::length): deprecate for ::numel. * liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel. * libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc, libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc, liboctave/array/Array-util.cc, liboctave/array/Array.cc, liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc, liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc, liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h, liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc, liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc, liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc, liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc, liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc, liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc, liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc, liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc, liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc, liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc, liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc, liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc, liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc, liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc, liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h, liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc, liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc, liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc, liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc, liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc, liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc, liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc, liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc, liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc, liboctave/util/glob-match.h, liboctave/util/kpse.cc, liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc, liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc, liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage of Array::length() and Sparse::length() with ::numel().
author Carnë Draug <carandraug@octave.org>
date Sat, 30 May 2015 03:14:07 +0100
parents 4197fc428c7d
children f90c8372b7ba
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
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19683
diff changeset
3 Copyright (C) 2007-2015 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"
19680
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"
19683
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
41 #include "oct-conf.h"
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
42 #include "oct-env.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "parse.h"
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
44 #include "utils.h"
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "variables.h"
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
47 // 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
48
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 static bool toolkit_loaded = false;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 class gnuplot_graphics_toolkit : public base_graphics_toolkit
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 public:
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 gnuplot_graphics_toolkit (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
55 : base_graphics_toolkit ("gnuplot") { }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 ~gnuplot_graphics_toolkit (void) { }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 bool is_valid (void) const { return true; }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 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
62 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
63 return go.isa ("figure");
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
64 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 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
67 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
68 if (go.isa ("figure"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
69 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 const figure::properties& props =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
71 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
72
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
73 send_quit (props.get___plot_stream__ ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
74 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
75 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 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
78 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 if (go.isa ("figure"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 graphics_object obj (go);
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
83 figure::properties& props =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
84 dynamic_cast<figure::properties&> (obj.get_properties ());
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
86 switch (id)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
87 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
88 case base_properties::ID_VISIBLE:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
89 if (! props.is_visible ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
90 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
91 send_quit (props.get___plot_stream__ ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
92 props.set___plot_stream__ (Matrix ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
93 props.set___enhanced__ (false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
94 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
95 break;
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 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 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
101 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
102 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
103 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
104 feval ("__gnuplot_drawnow__", args);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
105 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 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
108 const std::string& file, bool mono,
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 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
110 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
111 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
112 if (! debug_file.empty ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 args(4) = debug_file;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
114 args(3) = mono;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
115 args(2) = file;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
116 args(1) = term;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
117 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
118 feval ("__gnuplot_drawnow__", args);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
119 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 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
122 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
123 Matrix sz (1, 2, 0.0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
124 return sz;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
125 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 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
128 { return 72.0; }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 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
131 { return Matrix (1, 2, 0.0); }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 void close (void)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 if (toolkit_loaded)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 munlock ("__init_gnuplot__");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 gtk_manager::unload_toolkit ("gnuplot");
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 toolkit_loaded = false;
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
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 private:
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 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
148 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 if (! pstream.is_empty ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
150 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
151 octave_value_list args;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
152 Matrix fids = pstream.matrix_value ();
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
154 if (! error_state)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
155 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
156 Ffputs (ovl (fids(0), "\nquit;\n"));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
158 Ffflush (ovl (fids(0)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
159 Fpclose (ovl (fids(0)));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
161 if (fids.numel () > 1)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
162 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
163 Fpclose (ovl (fids(1)));
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
165 if (fids.numel () > 2)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
166 Fwaitpid (ovl (fids(2)));
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 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
170 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 };
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
173 static bool
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
174 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
175 {
19683
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
176 const std::string exeext = std::string (OCTAVE_CONF_EXEEXT);
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
177 const std::string path = octave_env::getenv ("PATH");
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
178
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
179 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
180 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
181
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
182 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
183 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
184
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
185 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
186
19683
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
187 if (! fs.exists () && ! exeext.empty ())
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
188 {
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
189 args[0] += exeext;
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
190
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
191 gnuplot_path = search_path_for_file (path, args);
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
192
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
193 fs = file_stat (gnuplot_path);
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
194 }
830c8457295a Check for gnuplot binary with executable file extension if needed
Mike Miller <mtmiller@ieee.org>
parents: 19680
diff changeset
195
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
196 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
197 }
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
198
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
199 // Initialize the gnuplot graphics toolkit.
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 DEFUN_DLD (__init_gnuplot__, , , "")
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 octave_value retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
205 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
206 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
207 else if (! toolkit_loaded)
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 mlock ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 graphics_toolkit tk (new gnuplot_graphics_toolkit ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212 gtk_manager::load_toolkit (tk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214 toolkit_loaded = true;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
218 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
220 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
221 "-*- texinfo -*-\n\
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
222 @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
223 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
224 @end deftypefn")
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
225 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
226 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
227
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
228 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
229
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
230 return retval;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
231 }
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
232