annotate libinterp/corefcn/graphics.cc @ 20617:ba2b07c13913

use new string_value method to handle value extraction errors * __dispatch__.cc, balance.cc, colloc.cc, conv2.cc, data.cc, debug.cc, graphics.cc, input.cc, matrix_type.cc, oct-hist.cc, schur.cc, spparms.cc, symtab.cc, sysdep.cc, toplev.cc, utils.cc: Use new string_value method.
author John W. Eaton <jwe@octave.org>
date Fri, 09 Oct 2015 10:06:39 -0400
parents bc6daa38ff50
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1 /*
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19700
diff changeset
3 Copyright (C) 2007-2015 John W. Eaton
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
6
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
10 option) any later version.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
11
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
15 for more details.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
16
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6962
diff changeset
19 <http://www.gnu.org/licenses/>.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
20
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
21 */
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
22
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
25 #endif
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
26
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
27 #include <cctype>
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
28 #include <cfloat>
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
29 #include <cstdlib>
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
30 #include <ctime>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
31
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
32 #include <algorithm>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
33 #include <list>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
34 #include <map>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
35 #include <set>
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
36 #include <string>
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
37 #include <sstream>
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
38
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
39 #include "cmd-edit.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
40 #include "file-ops.h"
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
41 #include "file-stat.h"
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
42 #include "oct-locbuf.h"
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
43 #include "singleton-cleanup.h"
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
44
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
45 #include "builtins.h"
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
46 #include "cutils.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
47 #include "defun.h"
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
48 #include "display.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
49 #include "error.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
50 #include "graphics.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
51 #include "input.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
52 #include "ov.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
53 #include "oct-obj.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
54 #include "oct-map.h"
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
55 #include "ov-fcn-handle.h"
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
56 #include "pager.h"
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
57 #include "parse.h"
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
58 #include "toplev.h"
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
59 #include "txt-eng-ft.h"
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
60 #include "unwind-prot.h"
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
61 #include "octave-default-image.h"
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
62
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
63 // forward declarations
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
64 static octave_value xget (const graphics_handle& h, const caseless_str& name);
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
65
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
66 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
67 gripe_set_invalid (const std::string& pname)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
68 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
69 error ("set: invalid value for %s property", pname.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
70 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
71
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
72 // Check to see that PNAME matches just one of PNAMES uniquely.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
73 // Return the full name of the match, or an empty caseless_str object
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
74 // if there is no match, or the match is ambiguous.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
75
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
76 static caseless_str
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
77 validate_property_name (const std::string& who, const std::string& what,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
78 const std::set<std::string>& pnames,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
79 const caseless_str& pname)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
80 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
81 size_t len = pname.length ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
82 std::set<std::string> matches;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
83
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
84 for (std::set<std::string>::const_iterator p = pnames.begin ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
85 p != pnames.end (); p++)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
86 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
87 if (pname.compare (*p, len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
88 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
89 if (len == p->length ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
90 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
91 // Exact match.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
92 return pname;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
93 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
94
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
95 matches.insert (*p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
96 }
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
97 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
98
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
99 size_t num_matches = matches.size ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
100
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
101 if (num_matches == 0)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
102 {
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
103 error ("%s: unknown %s property %s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
104 who.c_str (), what.c_str (), pname.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
105 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
106 else if (num_matches > 1)
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
107 {
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
108 string_vector sv (matches);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
109
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
110 std::ostringstream os;
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
111
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
112 sv.list_in_columns (os);
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
113
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
114 std::string match_list = os.str ();
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
115
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
116 error ("%s: ambiguous %s property name %s; possible matches:\n\n%s",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
117 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ());
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
118 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
119 else if (num_matches == 1)
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
120 {
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
121 // Exact match was handled above.
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
122
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
123 std::string possible_match = *(matches.begin ());
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
124
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
125 warning_with_id ("Octave:abbreviated-property-match",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
126 "%s: allowing %s to match %s property %s",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
127 who.c_str (), pname.c_str (), what.c_str (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
128 possible_match.c_str ());
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
129
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
130 return possible_match;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
131 }
9584
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
132
0fcbfddaa87f allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents: 9582
diff changeset
133 return caseless_str ();
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
134 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
135
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
136 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
137 jet_colormap (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
138 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
139 Matrix cmap (64, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
140
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
141 // Produce X in the same manner as linspace so that
15707
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
142 // jet_colormap and jet.m produce *exactly* the same result.
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
143 double delta = 1.0 / 63.0;
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
144
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
145 for (octave_idx_type i = 0; i < 64; i++)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
146 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
147 // This is the jet colormap. It would be nice to be able to feval the
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
148 // jet function but since there is a static property object that includes
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
149 // a colormap_property object, we need to initialize this before main is
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
150 // even called, so calling an interpreted function is not possible.
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
151
15707
d803cd07f31a Tweak C++ implementation of jet colormap to produce exactly the same result as jet.m
Rik <rik@octave.org>
parents: 15467
diff changeset
152 double x = i*delta;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
153
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
154 if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
155 cmap(i,0) = 4.0 * x - 3.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
156 else if (x >= 5.0/8.0 && x < 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
157 cmap(i,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
158 else if (x >= 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
159 cmap(i,0) = -4.0 * x + 9.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
160
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
161 if (x >= 1.0/8.0 && x < 3.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
162 cmap(i,1) = 4.0 * x - 1.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
163 else if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
164 cmap(i,1) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
165 else if (x >= 5.0/8.0 && x < 7.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
166 cmap(i,1) = -4.0 * x + 7.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
167
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
168 if (x < 1.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
169 cmap(i,2) = 4.0 * x + 1.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
170 else if (x >= 1.0/8.0 && x < 3.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
171 cmap(i,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
172 else if (x >= 3.0/8.0 && x < 5.0/8.0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
173 cmap(i,2) = -4.0 * x + 5.0/2.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
174 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
175
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
176 return cmap;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
177 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
178
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
179 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
180 default_screendepth (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
181 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
182 return display_info::depth ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
183 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
184
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
185 static Matrix
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
186 default_screensize (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
187 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
188 Matrix retval (1, 4);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
189
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
190 retval(0) = 1.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
191 retval(1) = 1.0;
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
192 retval(2) = display_info::width ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
193 retval(3) = display_info::height ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
194
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
195 return retval;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
196 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
197
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
198 static double
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
199 default_screenpixelsperinch (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
200 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
201 return (display_info::x_dpi () + display_info::y_dpi ()) / 2;
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
202 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
203
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
204 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
205 default_colororder (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
206 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
207 Matrix retval (7, 3, 0.0);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
208
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
209 retval(0,2) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
210
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
211 retval(1,1) = 0.5;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
212
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
213 retval(2,0) = 1.0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
214
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
215 retval(3,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
216 retval(3,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
217
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
218 retval(4,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
219 retval(4,2) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
220
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
221 retval(5,0) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
222 retval(5,1) = 0.75;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
223
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
224 retval(6,0) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
225 retval(6,1) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
226 retval(6,2) = 0.25;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
227
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
228 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
229 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
230
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
231 static Matrix
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
232 default_lim (bool logscale = false)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
233 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
234 Matrix m (1, 2);
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
235
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
236 if (logscale)
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
237 {
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
238 m(0) = 0.1;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
239 m(1) = 1.0;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
240 }
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
241 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
242 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
243 m(0) = 0.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
244 m(1) = 1.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
245 }
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
246
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
247 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
248 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
249
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
250 static Matrix
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
251 default_data (void)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
252 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
253 Matrix retval (1, 2);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
254
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
255 retval(0) = 0;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
256 retval(1) = 1;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
257
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
258 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
259 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
260
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
261 static Matrix
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
262 default_image_cdata (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
263 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
264 Matrix m (64, 64);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
265
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
266 int i = 0;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
267 for (int col = 0; col < 64; col++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
268 for (int row = 0; row < 64; row++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
269 {
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
270 m(col,row) = static_cast<double> (default_im_data[i]);
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
271 i++;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
272 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
273
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
274 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
275 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
276
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
277 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
278 default_surface_xdata (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
279 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
280 Matrix m (3, 3);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
281
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
282 for (int col = 0; col < 3; col++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
283 for (int row = 0; row < 3; row++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
284 m(row,col) = col+1;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
285
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
286 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
287 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
288
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
289 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
290 default_surface_ydata (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
291 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
292 Matrix m (3, 3);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
293
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
294 for (int row = 0; row < 3; row++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
295 for (int col = 0; col < 3; col++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
296 m(row,col) = row+1;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
297
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
298 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
299 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
300
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
301 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
302 default_surface_zdata (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
303 {
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
304 Matrix m (3, 3, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
305
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
306 for (int row = 0; row < 3; row++)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
307 m(row,row) = 1.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
308
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
309 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
310 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
311
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
312 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
313 default_surface_cdata (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
314 {
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
315 return default_surface_zdata ();
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
316 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
317
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
318 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
319 default_patch_faces (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
320 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
321 Matrix m (1, 3);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
322
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
323 m(0) = 1.0;
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
324 m(1) = 2.0;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
325 m(2) = 3.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
326
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
327 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
328 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
329
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
330 static Matrix
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
331 default_patch_vertices (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
332 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
333 Matrix m (3, 2, 0.0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
334
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
335 m(1) = 1.0;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
336 m(3) = 1.0;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
337 m(4) = 1.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
338
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
339 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
340 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
341
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
342 static Matrix
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
343 default_patch_xdata (void)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
344 {
18939
82773ee8119a Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18935
diff changeset
345 Matrix m (3, 1, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
346
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
347 m(1) = 1.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
348
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
349 return m;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
350 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
351
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
352 static Matrix
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
353 default_patch_ydata (void)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
354 {
18939
82773ee8119a Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18935
diff changeset
355 Matrix m (3, 1, 1.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
356
18939
82773ee8119a Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18935
diff changeset
357 m(2) = 0.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
358
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
359 return m;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
360 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
361
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
362 static Matrix
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
363 default_axes_position (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
364 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
365 Matrix m (1, 4);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
366
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
367 m(0) = 0.13;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
368 m(1) = 0.11;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
369 m(2) = 0.775;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
370 m(3) = 0.815;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
371
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
372 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
373 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
374
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
375 static Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
376 default_axes_outerposition (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
377 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
378 Matrix m (1, 4);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
379
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
380 m(0) = 0.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
381 m(1) = 0.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
382 m(2) = 1.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
383 m(3) = 1.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
384
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
385 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
386 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
387
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
388 static Matrix
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
389 default_axes_view (void)
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
390 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
391 Matrix m (1, 2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
392
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
393 m(0) = 0.0;
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
394 m(1) = 90.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
395
18680
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
396 return m;
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
397 }
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
398
2deed6538c72 Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents: 18610
diff changeset
399 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
400 default_axes_tick (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
401 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
402 Matrix m (1, 6);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
403
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
404 m(0) = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
405 m(1) = 0.2;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
406 m(2) = 0.4;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
407 m(3) = 0.6;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
408 m(4) = 0.8;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
409 m(5) = 1.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
410
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
411 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
412 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
413
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
414 static Matrix
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
415 default_axes_ticklength (void)
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
416 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
417 Matrix m (1, 2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
418
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
419 m(0) = 0.01;
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
420 m(1) = 0.025;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
421
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
422 return m;
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
423 }
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
424
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
425 static Matrix
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
426 default_figure_position (void)
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
427 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
428 Matrix m (1, 4);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
429
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
430 m(0) = 300;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
431 m(1) = 200;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
432 m(2) = 560;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
433 m(3) = 420;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
434
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
435 return m;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
436 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
437
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
438 static Matrix
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
439 default_figure_papersize (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
440 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
441 Matrix m (1, 2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
442
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
443 m(0) = 8.5;
8961
6b87f2f34fdd graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents: 8944
diff changeset
444 m(1) = 11.0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
445
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
446 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
447 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
448
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
449 static Matrix
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
450 default_figure_paperposition (void)
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
451 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
452 Matrix m (1, 4);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
453
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
454 m(0) = 0.25;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
455 m(1) = 2.50;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
456 m(2) = 8.00;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
457 m(3) = 6.00;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
458
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
459 return m;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
460 }
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
461
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
462 static Matrix
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
463 default_control_position (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
464 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
465 Matrix retval (1, 4);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
466
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
467 retval(0) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
468 retval(1) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
469 retval(2) = 80;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
470 retval(3) = 30;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
471
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
472 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
473 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
474
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
475 static Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
476 default_control_sliderstep (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
477 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
478 Matrix retval (1, 2);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
479
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
480 retval(0) = 0.01;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
481 retval(1) = 0.1;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
482
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
483 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
484 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
485
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
486 static Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
487 default_panel_position (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
488 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
489 Matrix retval (1, 4);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
490
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
491 retval(0) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
492 retval(1) = 0;
19930
90299974feda Change default uipanel "position" for compatibility with Matlab (bug #44411)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19927
diff changeset
493 retval(2) = 1;
90299974feda Change default uipanel "position" for compatibility with Matlab (bug #44411)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19927
diff changeset
494 retval(3) = 1;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
495
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
496 return retval;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
497 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
498
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
499 static double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
500 convert_font_size (double font_size, const caseless_str& from_units,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
501 const caseless_str& to_units, double parent_height = 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
502 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
503 // Simple case where from_units == to_units
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
504
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
505 if (from_units.compare (to_units))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
506 return font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
507
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
508 // Converts the given fontsize using the following transformation:
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
509 // <old_font_size> => points => <new_font_size>
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
510
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
511 double points_size = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
512 double res = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
513
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
514 if (from_units.compare ("points"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
515 points_size = font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
516 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
517 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
518 res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
519
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
520 if (from_units.compare ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
521 points_size = font_size * 72.0 / res;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
522 else if (from_units.compare ("inches"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
523 points_size = font_size * 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
524 else if (from_units.compare ("centimeters"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
525 points_size = font_size * 72.0 / 2.54;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
526 else if (from_units.compare ("normalized"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
527 points_size = font_size * parent_height * 72.0 / res;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
528 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
529
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
530 double new_font_size = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
531
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
532 if (to_units.compare ("points"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
533 new_font_size = points_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
534 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
535 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
536 if (res <= 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
537 res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
538
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
539 if (to_units.compare ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
540 new_font_size = points_size * res / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
541 else if (to_units.compare ("inches"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
542 new_font_size = points_size / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
543 else if (to_units.compare ("centimeters"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
544 new_font_size = points_size * 2.54 / 72.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
545 else if (to_units.compare ("normalized"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
546 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
547 // Avoid setting font size to (0/0) = NaN
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
548
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
549 if (parent_height > 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
550 new_font_size = points_size * res / (parent_height * 72.0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
551 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
552 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
553
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
554 return new_font_size;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
555 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
556
13804
4f112bebd474 use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents: 13801
diff changeset
557 static Matrix
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
558 convert_position (const Matrix& pos, const caseless_str& from_units,
13799
760e4e88dba3 convert units for figure positions
John W. Eaton <jwe@octave.org>
parents: 13757
diff changeset
559 const caseless_str& to_units, const Matrix& parent_dim)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
560 {
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
561 Matrix retval (1, pos.numel ());
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
562 double res = 0;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
563 bool is_rectangle = (pos.numel () == 4);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
564 bool is_2d = (pos.numel () == 2);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
565
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
566 if (from_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
567 retval = pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
568 else if (from_units.compare ("normalized"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
569 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
570 retval(0) = pos(0) * parent_dim(0) + 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
571 retval(1) = pos(1) * parent_dim(1) + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
572 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
573 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
574 retval(2) = pos(2) * parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
575 retval(3) = pos(3) * parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
576 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
577 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
578 retval(2) = 0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
579 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
580 else if (from_units.compare ("characters"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
581 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
582 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
583 res = xget (0, "screenpixelsperinch").double_value ();
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
584
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
585 double f = 0.0;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
586
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
587 // FIXME: this assumes the system font is Helvetica 10pt
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
588 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
8599
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
589 f = 12.0 * res / 74.951;
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
590
b4fb0a52b15e Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents: 8560
diff changeset
591 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
592 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
593 retval(0) = 0.5 * pos(0) * f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
594 retval(1) = pos(1) * f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
595 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
596 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
597 retval(2) = 0.5 * pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
598 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
599 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
600 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
601 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
602 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
603 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
604 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
605 {
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
606 if (res <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
607 res = xget (0, "screenpixelsperinch").double_value ();
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
608
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
609 double f = 0.0;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
610
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
611 if (from_units.compare ("points"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
612 f = res / 72.0;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
613 else if (from_units.compare ("inches"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
614 f = res;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
615 else if (from_units.compare ("centimeters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
616 f = res / 2.54;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
617
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
618 if (f > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
619 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
620 retval(0) = pos(0) * f + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
621 retval(1) = pos(1) * f + 1;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
622 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
623 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
624 retval(2) = pos(2) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
625 retval(3) = pos(3) * f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
626 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
627 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
628 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
629 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
630 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
631
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
632 if (! to_units.compare ("pixels"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
633 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
634 if (to_units.compare ("normalized"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
635 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
636 retval(0) = (retval(0) - 1) / parent_dim(0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
637 retval(1) = (retval(1) - 1) / parent_dim(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
638 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
639 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
640 retval(2) /= parent_dim(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
641 retval(3) /= parent_dim(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
642 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
643 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
644 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
645 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
646 else if (to_units.compare ("characters"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
647 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
648 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
649 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
650
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
651 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
652
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
653 f = 12.0 * res / 74.951;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
654
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
655 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
656 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
657 retval(0) = 2 * retval(0) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
658 retval(1) = retval(1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
659 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
660 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
661 retval(2) = 2 * retval(2) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
662 retval(3) = retval(3) / f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
663 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
664 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
665 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
666 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
667 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
668 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
669 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
670 if (res <= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
671 res = xget (0, "screenpixelsperinch").double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
672
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
673 double f = 0.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
674
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
675 if (to_units.compare ("points"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
676 f = res / 72.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
677 else if (to_units.compare ("inches"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
678 f = res;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
679 else if (to_units.compare ("centimeters"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
680 f = res / 2.54;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
681
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
682 if (f > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
683 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
684 retval(0) = (retval(0) - 1) / f;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
685 retval(1) = (retval(1) - 1) / f;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
686 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
687 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
688 retval(2) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
689 retval(3) /= f;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
690 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
691 else if (! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
692 retval(2) = 0;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
693 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
694 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
695 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
696 else if (! is_rectangle && ! is_2d)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
697 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
698
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
699 return retval;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
700 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
701
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
702 static Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
703 convert_text_position (const Matrix& pos, const text::properties& props,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
704 const caseless_str& from_units,
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
705 const caseless_str& to_units)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
706 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
707 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
708 graphics_object ax = go.get_ancestor ("axes");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
709
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
710 Matrix retval;
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
711
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
712 if (ax.valid_object ())
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
713 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
714 const axes::properties& ax_props =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
715 dynamic_cast<const axes::properties&> (ax.get_properties ());
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
716 graphics_xform ax_xform = ax_props.get_transform ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
717 bool is_rectangle = (pos.numel () == 4);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
718 Matrix ax_bbox = ax_props.get_boundingbox (true),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
719 ax_size = ax_bbox.extract_n (0, 2, 1, 2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
720
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
721 if (from_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
722 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
723 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
724 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
725 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
726 v2 = ax_xform.transform (pos(0) + pos(2),
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
727 pos(1) + pos(3), 0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
728
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
729 retval.resize (1, 4);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
730
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
731 retval(0) = v1(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
732 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
733 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
734 retval(3) = v1(1) - v2(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
735 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
736 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
737 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
738 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2));
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
739
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
740 retval.resize (1, 3);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
741
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
742 retval(0) = v(0) - ax_bbox(0) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
743 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
744 retval(2) = 0;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
745 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
746 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
747 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
748 retval = convert_position (pos, from_units, "pixels", ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
749
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
750 if (! to_units.compare ("pixels"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
751 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
752 if (to_units.compare ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
753 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
754 if (is_rectangle)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
755 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
756 ColumnVector v1, v2;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
757 v1 = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
758 retval(0) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
759 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
760 v2 = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
761 retval(0) + retval(2) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
762 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
763
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
764 retval.resize (1, 4);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
765
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
766 retval(0) = v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
767 retval(1) = v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
768 retval(2) = v2(0) - v1(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
769 retval(3) = v2(1) - v1(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
770 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
771 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
772 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
773 ColumnVector v;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
774 v = ax_xform.untransform (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
775 retval(0) + ax_bbox(0) - 1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
776 ax_bbox(1) + ax_bbox(3) - retval(1) + 1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
777
13876
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
778 retval.resize (1, 3);
c1b072ef1fc7 avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents: 13849
diff changeset
779
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
780 retval(0) = v(0);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
781 retval(1) = v(1);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
782 retval(2) = v(2);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
783 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
784 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
785 else
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
786 retval = convert_position (retval, "pixels", to_units, ax_size);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
787 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
788 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
789
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
790 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
791 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
792
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
793 // This function always returns the screensize in pixels
13804
4f112bebd474 use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents: 13801
diff changeset
794 static Matrix
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
795 screen_size_pixels (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
796 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
797 graphics_object obj = gh_manager::get_object (0);
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
798 Matrix sz = obj.get ("screensize").matrix_value ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
799 return convert_position (sz, obj.get ("units").string_value (), "pixels",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
800 sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
801 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
802
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
803 static void
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
804 convert_cdata_2 (bool is_scaled, bool is_real, double clim_0, double clim_1,
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
805 const double *cmapv, double x, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
806 octave_idx_type nc, octave_idx_type i, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
807 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
808 if (is_scaled)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
809 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0));
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
810 else if (is_real)
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
811 x = xround (x - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
812
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
813 if (xisnan (x))
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
814 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
815 av[i] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
816 av[i+lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
817 av[i+2*lda] = x;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
818 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
819 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
820 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
821 if (x < 0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
822 x = 0;
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
823 else if (x >= nc)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
824 x = (nc - 1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
825
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
826 octave_idx_type idx = static_cast<octave_idx_type> (x);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
827
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
828 av[i] = cmapv[idx];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
829 av[i+lda] = cmapv[idx+nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
830 av[i+2*lda] = cmapv[idx+2*nc];
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
831 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
832 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
833
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
834 template <class T>
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
835 void
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
836 convert_cdata_1 (bool is_scaled, bool is_real, double clim_0, double clim_1,
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
837 const double *cmapv, const T *cv, octave_idx_type lda,
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
838 octave_idx_type nc, double *av)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
839 {
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
840 for (octave_idx_type i = 0; i < lda; i++)
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
841 convert_cdata_2 (is_scaled, is_real,
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
842 clim_0, clim_1, cmapv, cv[i], lda, nc, i, av);
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
843 }
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
844
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
845 static octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
846 convert_cdata (const base_properties& props, const octave_value& cdata,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
847 bool is_scaled, int cdim)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
848 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
849 dim_vector dv (cdata.dims ());
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
850
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
851 // TrueColor data doesn't require conversion
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
852 if (dv.length () == cdim && dv(cdim-1) == 3)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
853 return cdata;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
854
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
855 Matrix cmap (1, 3, 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
856 Matrix clim (1, 2, 0.0);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
857
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
858 graphics_object go = gh_manager::get_object (props.get___myhandle__ ());
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
859 graphics_object fig = go.get_ancestor ("figure");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
860
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
861 if (fig.valid_object ())
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
862 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
863 Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
864
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
865 cmap = _cmap;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
866 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
867
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
868 if (is_scaled)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
869 {
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
870 graphics_object ax = go.get_ancestor ("axes");
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
871
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
872 if (ax.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
873 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
874 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
875
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
876 clim = _clim;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
877 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
878 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
879
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
880 dv.resize (cdim);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
881 dv(cdim-1) = 3;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
882
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
883 NDArray a (dv);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
884
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
885 octave_idx_type lda = a.numel () / static_cast<octave_idx_type> (3);
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
886 octave_idx_type nc = cmap.rows ();
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
887
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
888 double *av = a.fortran_vec ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
889 const double *cmapv = cmap.data ();
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
890
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
891 double clim_0 = clim(0);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
892 double clim_1 = clim(1);
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
893
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
894 // FIXME: There is a lot of processing time spent just on data conversion
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
895 // both here in graphics.cc and again in gl-render.cc. There must
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
896 // be room for improvement! Here a macro expands to a templated
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
897 // function which in turn calls another function (covert_cdata_2).
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
898 // And in gl-render.cc (opengl_renderer::draw_image), only GLfloat
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
899 // is supported anyways so there is another double for loop across
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
900 // height and width to convert all of the input data to GLfloat.
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
901
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
902 #define CONVERT_CDATA_1(ARRAY_T, VAL_FN, IS_REAL) \
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
903 do \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
904 { \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
905 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
906 \
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
907 convert_cdata_1 (is_scaled, IS_REAL, clim_0, clim_1, cmapv, \
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
908 tmp.data (), lda, nc, av); \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
909 } \
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
910 while (0)
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
911
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
912 if (cdata.is_uint8_type ())
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
913 CONVERT_CDATA_1 (uint8NDArray, uint8_, false);
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
914 else if (cdata.is_uint16_type ())
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
915 CONVERT_CDATA_1 (uint16NDArray, uint16_, false);
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
916 else if (cdata.is_double_type ())
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
917 CONVERT_CDATA_1 (NDArray, , true);
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
918 else if (cdata.is_single_type ())
18717
44f0d1a53ead Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents: 18714
diff changeset
919 CONVERT_CDATA_1 (FloatNDArray, float_, true);
18746
d57a83f2d73e Preserve image class in cdata (bug #41240).
Rik <rik@octave.org>
parents: 18736
diff changeset
920 else if (cdata.is_bool_type ())
d57a83f2d73e Preserve image class in cdata (bug #41240).
Rik <rik@octave.org>
parents: 18736
diff changeset
921 CONVERT_CDATA_1 (boolNDArray, bool_, false);
10923
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
922 else
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
923 error ("unsupported type for cdata (= %s)", cdata.type_name ().c_str ());
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
924
4c1ffaed8caa graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents: 10922
diff changeset
925 #undef CONVERT_CDATA_1
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
926
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
927 return octave_value (a);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
928 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
929
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
930 template<class T>
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
931 static void
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
932 get_array_limits (const Array<T>& m, double& emin, double& emax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
933 double& eminp, double& emaxp)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
934 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
935 const T *data = m.data ();
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
936 octave_idx_type n = m.numel ();
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
937
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
938 for (octave_idx_type i = 0; i < n; i++)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
939 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
940 double e = double (data[i]);
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
941
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
942 // Don't need to test for NaN here as NaN>x and NaN<x is always false
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
943 if (! xisinf (e))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
944 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
945 if (e < emin)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
946 emin = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
947
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
948 if (e > emax)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
949 emax = e;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
950
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
951 if (e > 0 && e < eminp)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
952 eminp = e;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
953
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
954 if (e < 0 && e > emaxp)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
955 emaxp = e;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
956 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
957 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
958 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
959
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
960 static bool
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
961 lookup_object_name (const caseless_str& name, caseless_str& go_name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
962 caseless_str& rest)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
963 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
964 int len = name.length ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
965 int offset = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
966 bool result = false;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
967
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
968 if (len >= 4)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
969 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
970 caseless_str pfx = name.substr (0, 4);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
971
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
972 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
973 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
974 offset = 4;
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
975 else if (len >= 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
976 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
977 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
978
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
979 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
980 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
981 else if (len >= 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
982 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
983 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
984
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
985 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
986 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
987 else if (len >= 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
988 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
989 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
990
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
991 if (pfx.compare ("surface") || pfx.compare ("hggroup")
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
992 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
993 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
994 else if (len >= 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
995 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
996 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
997
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
998 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
999 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1000 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1001 else if (len >= 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1002 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1003 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1004
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1005 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1006 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1007 else if (len >= 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1008 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1009 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1010
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1011 if (pfx.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1012 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1013 else if (len >= 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1014 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1015 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1016
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1017 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1018 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1019 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1020 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1021 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1022 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1023 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1024 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1025 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1026
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1027 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1028 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1029 go_name = pfx;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1030 rest = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1031 result = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1032 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1033 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1034
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1035 return result;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1036 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1037
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1038 static base_graphics_object*
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1039 make_graphics_object_from_type (const caseless_str& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1040 const graphics_handle& h = graphics_handle (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1041 const graphics_handle& p = graphics_handle ())
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1042 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1043 base_graphics_object *go = 0;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1044
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1045 if (type.compare ("figure"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1046 go = new figure (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1047 else if (type.compare ("axes"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1048 go = new axes (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1049 else if (type.compare ("line"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1050 go = new line (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1051 else if (type.compare ("text"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1052 go = new text (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1053 else if (type.compare ("image"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1054 go = new image (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1055 else if (type.compare ("patch"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1056 go = new patch (h, p);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1057 else if (type.compare ("surface"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1058 go = new surface (h, p);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
1059 else if (type.compare ("hggroup"))
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
1060 go = new hggroup (h, p);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1061 else if (type.compare ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1062 go = new uimenu (h, p);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1063 else if (type.compare ("uicontrol"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1064 go = new uicontrol (h, p);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1065 else if (type.compare ("uipanel"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1066 go = new uipanel (h, p);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1067 else if (type.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1068 go = new uicontextmenu (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1069 else if (type.compare ("uitoolbar"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1070 go = new uitoolbar (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1071 else if (type.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1072 go = new uipushtool (h, p);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1073 else if (type.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1074 go = new uitoggletool (h, p);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1075 return go;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1076 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1077
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1078 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1079
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1080 bool
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1081 base_property::set (const octave_value& v, bool do_run, bool do_notify_toolkit)
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1082 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1083 if (do_set (v))
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1084 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1085 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1086 if (id >= 0 && do_notify_toolkit)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1087 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1088 graphics_object go = gh_manager::get_object (parent);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1089 if (go)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1090 go.update (id);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1091 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1092
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1093 // run listeners
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1094 if (do_run)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1095 run_listeners (POSTSET);
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1096
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1097 return true;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1098 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1099
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1100 return false;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1101 }
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1102
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1103
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
1104 void
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1105 base_property::run_listeners (listener_mode mode)
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1106 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1107 const octave_value_list& l = listeners[mode];
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1108
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1109 for (int i = 0; i < l.length (); i++)
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1110 gh_manager::execute_listener (parent, l(i));
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1111 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1112
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1113 radio_values::radio_values (const std::string& opt_string)
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
1114 : default_val (), possible_vals ()
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1115 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1116 size_t beg = 0;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1117 size_t len = opt_string.length ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1118 bool done = len == 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1119
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1120 while (! done)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1121 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1122 size_t end = opt_string.find ('|', beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1123
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1124 if (end == std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1125 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1126 end = len;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1127 done = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1128 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1129
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1130 std::string t = opt_string.substr (beg, end-beg);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1131
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1132 // Might want more error checking here...
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1133 if (t[0] == '{')
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1134 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1135 t = t.substr (1, t.length () - 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1136 default_val = t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1137 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1138 else if (beg == 0) // ensure default value
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1139 default_val = t;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1140
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1141 possible_vals.insert (t);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1142
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1143 beg = end + 1;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1144 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1145 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1146
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1147 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1148 radio_values::values_as_string (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1149 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1150 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1151 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1152 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1153 {
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1154 if (retval.empty ())
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1155 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1156 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1157 retval = "{" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1158 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1159 retval = *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1160 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1161 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1162 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1163 if (*it == default_value ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1164 retval += " | {" + *it + "}";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1165 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1166 retval += " | " + *it;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1167 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1168 }
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1169
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1170 if (! retval.empty ())
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1171 retval = "[ " + retval + " ]";
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1172
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1173 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1174 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1175
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1176 Cell
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1177 radio_values::values_as_cell (void) const
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1178 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1179 octave_idx_type i = 0;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1180 Cell retval (nelem (), 1);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1181 for (std::set<caseless_str>::const_iterator it = possible_vals.begin ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1182 it != possible_vals.end (); it++)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1183 retval(i++) = std::string (*it);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1184 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1185 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
1186
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1187 bool
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1188 color_values::str2rgb (const std::string& str_arg)
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1189 {
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1190 bool retval = true;
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1191
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1192 double tmp_rgb[3] = {0, 0, 0};
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1193
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
1194 std::string str = str_arg;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
1195 unsigned int len = str.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1196
6925
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
1197 std::transform (str.begin (), str.end (), str.begin (), tolower);
1401a79af68c [project @ 2007-09-26 18:58:52 by dbateman]
dbateman
parents: 6898
diff changeset
1198
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1199 if (str.compare (0, len, "blue", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1200 tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1201 else if (str.compare (0, len, "black", 0, len) == 0
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1202 || str.compare (0, len, "k", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1203 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1204 else if (str.compare (0, len, "red", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1205 tmp_rgb[0] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1206 else if (str.compare (0, len, "green", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1207 tmp_rgb[1] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1208 else if (str.compare (0, len, "yellow", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1209 tmp_rgb[0] = tmp_rgb[1] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1210 else if (str.compare (0, len, "magenta", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1211 tmp_rgb[0] = tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1212 else if (str.compare (0, len, "cyan", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1213 tmp_rgb[1] = tmp_rgb[2] = 1;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1214 else if (str.compare (0, len, "white", 0, len) == 0
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1215 || str.compare (0, len, "w", 0, len) == 0)
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1216 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1217 else
6761
813172f035de [project @ 2007-06-27 15:08:05 by jwe]
jwe
parents: 6733
diff changeset
1218 retval = false;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
1219
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1220 if (retval)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1221 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1222 for (int i = 0; i < 3; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1223 xrgb(i) = tmp_rgb[i];
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1224 }
6563
7a65c1a09ec3 [project @ 2007-04-23 19:26:17 by jwe]
jwe
parents: 6509
diff changeset
1225
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1226 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1227 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1228
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1229 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1230 color_property::do_set (const octave_value& val)
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1231 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1232 if (val.is_string ())
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1233 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1234 std::string s = val.string_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1235
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1236 if (! s.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1237 {
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1238 std::string match;
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1239
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1240 if (radio_val.contains (s, match))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1241 {
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1242 if (current_type != radio_t || match != current_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1243 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1244 if (s.length () != match.length ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1245 warning_with_id ("Octave:abbreviated-property-match",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1246 "%s: allowing %s to match %s value %s",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1247 "set", s.c_str (), get_name ().c_str (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1248 match.c_str ());
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1249 current_val = match;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1250 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1251 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1252 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1253 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1254 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1255 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1256 color_values col (s);
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1257
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1258 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1259 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1260 if (current_type != color_t || col != color_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1261 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1262 color_val = col;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1263 current_type = color_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1264 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1265 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1266 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1267 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1268 error ("invalid value for color property \"%s\" (value = %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1269 get_name ().c_str (), s.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1270 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1271 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1272 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1273 error ("invalid value for color property \"%s\"",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1274 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1275 }
9311
868fbeb2e365 allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents: 9238
diff changeset
1276 else if (val.is_numeric_type ())
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1277 {
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1278 Matrix m = val.matrix_value ();
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1279
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1280 if (m.numel () == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1281 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1282 color_values col (m(0), m(1), m(2));
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1283
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1284 if (current_type != color_t || col != color_val)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1285 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1286 color_val = col;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1287 current_type = color_t;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1288 return true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1289 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1290 }
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1291 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1292 error ("invalid value for color property \"%s\"",
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1293 get_name ().c_str ());
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1294 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1295 else
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1296 error ("invalid value for color property \"%s\"",
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1297 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1298
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1299 return false;
6790
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1300 }
f1157da78825 [project @ 2007-07-24 19:02:27 by jwe]
jwe
parents: 6765
diff changeset
1301
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1302 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1303 double_radio_property::do_set (const octave_value& val)
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1304 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1305 if (val.is_string ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1306 {
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1307 std::string s = val.string_value ();
13236
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1308 std::string match;
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1309
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1310 if (! s.empty () && radio_val.contains (s, match))
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1311 {
8bb526fb3349 allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents: 13211
diff changeset
1312 if (current_type != radio_t || match != current_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1313 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1314 if (s.length () != match.length ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1315 warning_with_id ("Octave:abbreviated-property-match",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1316 "%s: allowing %s to match %s value %s",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1317 "set", s.c_str (), get_name ().c_str (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1318 match.c_str ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1319 current_val = match;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1320 current_type = radio_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1321 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1322 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1323 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1324 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1325 error ("invalid value for double_radio property \"%s\"",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1326 get_name ().c_str ());
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1327 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1328 else if (val.is_scalar_type () && val.is_real_type ())
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1329 {
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1330 double new_dval = val.double_value ();
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1331
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1332 if (current_type != double_t || new_dval != dval)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1333 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1334 dval = new_dval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1335 current_type = double_t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1336 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1337 }
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1338 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1339 else
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1340 error ("invalid value for double_radio property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1341 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1342
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1343 return false;
7844
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1344 }
3d60445d3638 Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7843
diff changeset
1345
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1346 bool
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1347 array_property::validate (const octave_value& v)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1348 {
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1349 bool xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1350
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1351 // check value type
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1352 if (type_constraints.size () > 0)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1353 {
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1354 if (type_constraints.find (v.class_name ()) != type_constraints.end ())
15069
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1355 xok = true;
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1356
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1357 // check if complex is allowed (it's also of class "double", so
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1358 // checking that alone is not enough to ensure real type)
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1359 if (type_constraints.find ("real") != type_constraints.end ()
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1360 && v.is_complex_type ())
7a3957ca99c3 Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15017
diff changeset
1361 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1362 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1363 else
20066
c66909c234e6 Allow bool_scalar types for graphics array properties (Bug #44699)
John Donoghue
parents: 19969
diff changeset
1364 xok = v.is_numeric_type () || v.is_bool_scalar ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1365
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1366 if (xok)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1367 {
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1368 if (size_constraints.size () == 0)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1369 return true;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1370
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1371 dim_vector vdims = v.dims ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1372 int vlen = vdims.length ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1373
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1374 xok = false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1375
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1376 // check dimensional size constraints until a match is found
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1377 for (std::list<dim_vector>::const_iterator it = size_constraints.begin ();
19895
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
1378 ! xok && it != size_constraints.end (); ++it)
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1379 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1380 dim_vector itdims = (*it);
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1381
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1382 if (itdims.length () == vlen)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1383 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1384 xok = true;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1385
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1386 for (int i = 0; xok && i < vlen; i++)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1387 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1388 if (itdims(i) > 0)
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1389 {
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1390 if (itdims(i) != vdims(i))
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1391 xok = false;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1392 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1393 else if (v.is_empty ())
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1394 break;
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1395 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1396 }
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
1397 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1398 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1399
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
1400 return xok;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1401 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1402
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1403 bool
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1404 array_property::is_equal (const octave_value& v) const
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1405 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1406 if (data.type_name () == v.type_name ())
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1407 {
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1408 if (data.dims () == v.dims ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1409 {
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1410
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1411 #define CHECK_ARRAY_EQUAL(T,F,A) \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1412 { \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1413 if (data.numel () == 1) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1414 return data.F ## scalar_value () == \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1415 v.F ## scalar_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1416 else \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1417 { \
8075
a028a5960e18 Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents: 8063
diff changeset
1418 /* Keep copy of array_value to allow sparse/bool arrays */ \
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1419 /* that are converted, to not be deallocated early */ \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1420 const A m1 = data.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1421 const T* d1 = m1.data (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1422 const A m2 = v.F ## array_value (); \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1423 const T* d2 = m2.data ();\
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1424 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1425 bool flag = true; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1426 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1427 for (int i = 0; flag && i < data.numel (); i++) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1428 if (d1[i] != d2[i]) \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1429 flag = false; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1430 \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1431 return flag; \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1432 } \
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1433 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1434
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
1435 if (data.is_double_type () || data.is_bool_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1436 CHECK_ARRAY_EQUAL (double, , NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1437 else if (data.is_single_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1438 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1439 else if (data.is_int8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1440 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1441 else if (data.is_int16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1442 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1443 else if (data.is_int32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1444 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1445 else if (data.is_int64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1446 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1447 else if (data.is_uint8_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1448 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1449 else if (data.is_uint16_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1450 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1451 else if (data.is_uint32_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1452 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1453 else if (data.is_uint64_type ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1454 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1455 }
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1456 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1457
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1458 return false;
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1459 }
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1460
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1461 void
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1462 array_property::get_data_limits (void)
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1463 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1464 xmin = xminp = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1465 xmax = xmaxp = -octave_Inf;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1466
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1467 if (! data.is_empty ())
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1468 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1469 if (data.is_integer_type ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1470 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1471 if (data.is_int8_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1472 get_array_limits (data.int8_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1473 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1474 else if (data.is_uint8_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1475 get_array_limits (data.uint8_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1476 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1477 else if (data.is_int16_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1478 get_array_limits (data.int16_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1479 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1480 else if (data.is_uint16_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1481 get_array_limits (data.uint16_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1482 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1483 else if (data.is_int32_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1484 get_array_limits (data.int32_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1485 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1486 else if (data.is_uint32_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1487 get_array_limits (data.uint32_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1488 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1489 else if (data.is_int64_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1490 get_array_limits (data.int64_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1491 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1492 else if (data.is_uint64_type ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1493 get_array_limits (data.uint64_array_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1494 xmin, xmax, xminp, xmaxp);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1495 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1496 else
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
1497 get_array_limits (data.array_value (), xmin, xmax, xminp, xmaxp);
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1498 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1499 }
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
1500
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1501 bool
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
1502 handle_property::do_set (const octave_value& v)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1503 {
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1504 // Users may want to use empty matrix to reset a handle property
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1505 if (v.is_empty ())
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1506 {
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1507 if (! get ().is_empty ())
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1508 {
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1509 current_val = graphics_handle ();
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1510 return true;
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1511 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1512 else
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1513 return false;
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1514 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
1515
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1516 double dv = v.double_value ();
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1517
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1518 if (! error_state)
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1519 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1520 graphics_handle gh = gh_manager::lookup (dv);
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1521
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1522 if (xisnan (gh.value ()) || gh.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1523 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1524 if (current_val != gh)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1525 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1526 current_val = gh;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1527 return true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1528 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1529 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1530 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1531 error ("set: invalid graphics handle (= %g) for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1532 dv, get_name ().c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1533 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1534 else
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1535 error ("set: invalid graphics handle for property \"%s\"",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1536 get_name ().c_str ());
8063
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1537
41bc700ff642 Trigger actions/listeners only for actual property change
Michael Goffioul
parents: 8062
diff changeset
1538 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1539 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1540
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1541 Matrix
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1542 children_property::do_get_children (bool return_hidden) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1543 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1544 Matrix retval (children_list.size (), 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1545 octave_idx_type k = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1546
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1547 graphics_object go = gh_manager::get_object (0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1548
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1549 root_figure::properties& props =
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1550 dynamic_cast<root_figure::properties&> (go.get_properties ());
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1551
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1552 if (! props.is_showhiddenhandles ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1553 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1554 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1555 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1556 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1557 graphics_handle kid = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1558
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1559 if (gh_manager::is_handle_visible (kid))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1560 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1561 if (! return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1562 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1563 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1564 else if (return_hidden)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1565 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1566 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1567
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1568 retval.resize (k, 1);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1569 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1570 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1571 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1572 for (const_children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1573 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1574 retval(k++) = *p;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1575 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1576
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1577 return retval;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1578 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1579
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1580 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1581 children_property::do_delete_children (bool clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1582 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1583 for (children_list_iterator p = children_list.begin ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1584 p != children_list.end (); p++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1585 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1586 graphics_object go = gh_manager::get_object (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1587
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1588 if (go.valid_object ())
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1589 gh_manager::free (*p);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1590 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1591
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1592 if (clear)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1593 children_list.clear ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1594 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
1595
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1596 bool
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1597 callback_property::validate (const octave_value& v) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1598 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1599 // case 1: empty matrix
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1600 // case 2: function handle
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1601 // case 3: string corresponding to known function name
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1602 // case 4: string that can be eval()'ed
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1603 // case 5: cell array with first element being a function handle
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1604
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1605 if (v.is_empty ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1606 return true;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1607 else if (v.is_function_handle ())
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1608 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1609 else if (v.is_string ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1610 // complete validation will be done at execution-time
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1611 return true;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1612 else if (v.is_cell () && (v.rows () == 1 || v.columns () == 1)
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1613 && v.cell_value ()(0).is_function_handle ())
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1614 return true;
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1615
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1616 return false;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1617 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1618
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1619 // If TRUE, we are executing any callback function, or the functions it calls.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1620 // Used to determine handle visibility inside callback functions.
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1621 static bool executing_callback = false;
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1622
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1623 void
7367
600808df131c [project @ 2008-01-14 08:58:02 by jwe]
jwe
parents: 7366
diff changeset
1624 callback_property::execute (const octave_value& data) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1625 {
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1626 unwind_protect frame;
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1627
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1628 // We are executing the callback function associated with this
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1629 // callback property. When set to true, we avoid recursive calls to
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1630 // callback routines.
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1631 frame.protect_var (executing);
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1632
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1633 // We are executing a callback function, so allow handles that have
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1634 // their handlevisibility property set to "callback" to be visible.
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1635 frame.protect_var (executing_callback);
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1636
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1637 if (! executing)
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1638 {
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1639 executing = true;
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
1640 executing_callback = true;
13323
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1641
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1642 if (callback.is_defined () && ! callback.is_empty ())
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1643 gh_manager::execute_callback (get_parent (), callback, data);
de081abd32c6 don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents: 13281
diff changeset
1644 }
7824
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1645 }
adb520646d7e Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7822
diff changeset
1646
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1647 // Used to cache dummy graphics objects from which dynamic properties can be
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1648 // cloned.
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1649 static std::map<caseless_str, graphics_object> dprop_obj_map;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1650
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1651 property
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1652 property::create (const std::string& name, const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1653 const caseless_str& type, const octave_value_list& args)
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1654 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1655 property retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1656
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1657 if (type.compare ("string"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1658 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1659 std::string sv = (args.length () > 0 ? args(0).string_value () : "");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1660
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1661 retval = property (new string_property (name, h, sv));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1662 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1663 else if (type.compare ("any"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1664 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1665 octave_value ov = args.length () > 0 ? args(0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1666 : octave_value (Matrix ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1667
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1668 retval = property (new any_property (name, h, ov));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1669 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1670 else if (type.compare ("radio"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1671 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1672 if (args.length () < 1)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1673 error ("addproperty: missing possible values for radio property");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1674 else
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1675 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1676 std::string sv = args(0).string_value ("addproperty: invalid argument for radio property, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1677
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1678 retval = property (new radio_property (name, h, sv));
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1679
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1680 if (args.length () > 1)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
1681 retval.set (args(1));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1682 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1683 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1684 else if (type.compare ("double"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1685 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1686 double dv = (args.length () > 0 ? args(0).double_value () : 0.0);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1687
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1688 retval = property (new double_property (name, h, dv));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1689 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1690 else if (type.compare ("handle"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1691 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1692 double hv = (args.length () > 0 ? args(0).double_value () : octave_NaN);
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1693
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1694 graphics_handle gh (hv);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1695
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1696 retval = property (new handle_property (name, h, gh));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1697 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1698 else if (type.compare ("boolean"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1699 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1700 retval = property (new bool_property (name, h, false));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1701
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1702 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1703 retval.set (args(0));
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1704 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1705 else if (type.compare ("data"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1706 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1707 retval = property (new array_property (name, h, Matrix ()));
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1708
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1709 if (args.length () > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1710 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1711 retval.set (args(0));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1712 // FIXME: additional argument could define constraints,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1713 // but is this really useful?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1714 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1715 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1716 else if (type.compare ("color"))
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1717 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1718 color_values cv (0, 0, 0);
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1719 radio_values rv;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1720
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1721 if (args.length () > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1722 rv = radio_values (args(1).string_value ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1723
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1724 retval = property (new color_property (name, h, cv, rv));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1725
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1726 if (args.length () > 0 && ! args(0).is_empty ())
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1727 retval.set (args(0));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1728 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1729 retval.set (rv.default_value ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1730 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1731 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1732 {
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1733 caseless_str go_name, go_rest;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1734
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1735 if (lookup_object_name (type, go_name, go_rest))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1736 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1737 graphics_object go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1738
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1739 std::map<caseless_str, graphics_object>::const_iterator it =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1740 dprop_obj_map.find (go_name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1741
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1742 if (it == dprop_obj_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1743 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1744 base_graphics_object *bgo =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1745 make_graphics_object_from_type (go_name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1746
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1747 if (bgo)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1748 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1749 go = graphics_object (bgo);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1750
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1751 dprop_obj_map[go_name] = go;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1752 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1753 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1754 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1755 go = it->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1756
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1757 if (go.valid_object ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1758 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1759 property prop = go.get_properties ().get_property (go_rest);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1760
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1761 retval = prop.clone ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1762
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1763 retval.set_parent (h);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1764 retval.set_name (name);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1765
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1766 if (args.length () > 0)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1767 retval.set (args(0));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1768 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1769 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1770 error ("addproperty: invalid object type (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1771 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1772 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1773 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1774 error ("addproperty: unsupported type for dynamic property (= %s)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1775 type.c_str ());
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1776 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
1777
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1778 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1779 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
1780
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1781 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1782 finalize_r (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1783 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1784 graphics_object go = gh_manager::get_object (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1785
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1786 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1787 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1788 Matrix children = go.get_properties ().get_all_children ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1789
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1790 for (int k = 0; k < children.numel (); k++)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1791 finalize_r (children(k));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1792
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1793 go.finalize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1794 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1795 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1796
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1797 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1798 initialize_r (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1799 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1800 graphics_object go = gh_manager::get_object (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1801
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1802 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1803 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1804 Matrix children = go.get_properties ().get_all_children ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1805
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1806 go.initialize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1807
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1808 for (int k = 0; k < children.numel (); k++)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1809 initialize_r (children(k));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1810 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1811 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1812
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1813 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1814 figure::properties::set_toolkit (const graphics_toolkit& b)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1815 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1816 if (toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1817 finalize_r (get___myhandle__ ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1818
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1819 toolkit = b;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1820 __graphics_toolkit__ = b.get_name ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1821 __plot_stream__ = Matrix ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1822
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1823 if (toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1824 initialize_r (get___myhandle__ ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1825
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1826 mark_modified ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1827 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1828
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1829 void
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1830 figure::properties::set___mouse_mode__ (const octave_value& val_arg)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1831 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1832 std::string direction = "in";
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1833
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1834 octave_value val = val_arg;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1835
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1836 if (val.is_string ())
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1837 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1838 std::string modestr = val.string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1839
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1840 if (modestr == "zoom in")
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1841 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1842 val = modestr = "zoom";
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1843 direction = "in";
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1844 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1845 else if (modestr == "zoom out")
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1846 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1847 val = modestr = "zoom";
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1848 direction = "out";
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1849 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1850
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1851 if (__mouse_mode__.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1852 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1853 std::string mode = __mouse_mode__.current_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1854
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1855 octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1856 pm.setfield ("Enable", mode == "pan" ? "on" : "off");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1857 set___pan_mode__ (pm);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1858
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1859 octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1860 rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1861 set___rotate_mode__ (rm);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1862
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1863 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1864 zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1865 zm.setfield ("Direction", direction);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1866 set___zoom_mode__ (zm);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1867
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1868 mark_modified ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1869 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1870 else if (modestr == "zoom")
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1871 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1872 octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1873 std::string curr_direction
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1874 = zm.getfield ("Direction").string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1875
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1876 if (direction != curr_direction)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
1877 {
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1878 zm.setfield ("Direction", direction);
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1879 set___zoom_mode__ (zm);
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1880
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1881 mark_modified ();
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
1882 }
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1883 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1884 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1885 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
1886
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
1887 // ---------------------------------------------------------------------
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1888
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1889 void
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1890 property_list::set (const caseless_str& name, const octave_value& val)
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1891 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1892 size_t offset = 0;
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1893
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1894 size_t len = name.length ();
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1895
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1896 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1897 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
1898 caseless_str pfx = name.substr (0, 4);
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1899
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1900 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1901 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1902 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1903 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1904 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1905 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1906
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1907 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1908 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1909 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1910 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1911 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1912
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1913 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1914 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1915 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1916 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1917 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1918
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1919 if (pfx.compare ("surface") || pfx.compare ("hggroup")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1920 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1921 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1922 else if (len > 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1923 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1924 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1925
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1926 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1927 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1928 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1929 else if (len > 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1930 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1931 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1932
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1933 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1934 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1935 else if (len > 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1936 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1937 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1938
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1939 if (pfx.compare ("uitoogletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1940 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1941 else if (len > 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1942 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1943 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1944
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1945 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1946 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1947 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1948 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1949 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1950 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1951 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1952 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1953 }
6681
0458599c50d7 [project @ 2007-06-01 03:33:21 by jwe]
jwe
parents: 6678
diff changeset
1954
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
1955 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1956 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1957 // FIXME: should we validate property names and values here?
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1958
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1959 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1960
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1961 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1962 std::transform (pname.begin (), pname.end (), pname.begin (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1963 tolower);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1964
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1965 bool has_property = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1966 if (pfx == "axes")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1967 has_property = axes::properties::has_core_property (pname);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1968 else if (pfx == "figure")
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
1969 has_property = figure::properties::has_core_property (pname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1970 else if (pfx == "line")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1971 has_property = line::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1972 else if (pfx == "text")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1973 has_property = text::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1974 else if (pfx == "image")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1975 has_property = image::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1976 else if (pfx == "patch")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1977 has_property = patch::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1978 else if (pfx == "surface")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1979 has_property = surface::properties::has_core_property (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1980 else if (pfx == "hggroup")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1981 has_property = hggroup::properties::has_core_property (pname);
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents: 11259
diff changeset
1982 else if (pfx == "uimenu")
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
1983 has_property = uimenu::properties::has_core_property (pname);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1984 else if (pfx == "uicontrol")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1985 has_property = uicontrol::properties::has_core_property (pname);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1986 else if (pfx == "uipanel")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
1987 has_property = uipanel::properties::has_core_property (pname);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1988 else if (pfx == "uicontextmenu")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1989 has_property = uicontextmenu::properties::has_core_property (pname);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1990 else if (pfx == "uitoolbar")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1991 has_property = uitoolbar::properties::has_core_property (pname);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1992 else if (pfx == "uipushtool")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
1993 has_property = uipushtool::properties::has_core_property (pname);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1994
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1995 if (has_property)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1996 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1997 bool remove = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1998 if (val.is_string ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
1999 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2000 std::string sval = val.string_value ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2001
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2002 remove = (sval.compare ("remove") == 0);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2003 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2004
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2005 pval_map_type& pval_map = plist_map[pfx];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2006
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2007 if (remove)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2008 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2009 pval_map_iterator p = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2010
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2011 if (p != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2012 pval_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2013 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2014 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2015 pval_map[pname] = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2016 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2017 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
2018 error ("invalid %s property '%s'", pfx.c_str (), pname.c_str ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2019 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2020 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2021
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2022 if (offset == 0)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2023 error ("invalid default property specification");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2024 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2025
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2026 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2027 property_list::lookup (const caseless_str& name) const
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2028 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2029 octave_value retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2030
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2031 size_t offset = 0;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2032
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2033 size_t len = name.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2034
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2035 if (len > 4)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2036 {
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
2037 caseless_str pfx = name.substr (0, 4);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2038
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2039 if (pfx.compare ("axes") || pfx.compare ("line")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2040 || pfx.compare ("text"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2041 offset = 4;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2042 else if (len > 5)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2043 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2044 pfx = name.substr (0, 5);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2045
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2046 if (pfx.compare ("image") || pfx.compare ("patch"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2047 offset = 5;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2048 else if (len > 6)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2049 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2050 pfx = name.substr (0, 6);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2051
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
2052 if (pfx.compare ("figure") || pfx.compare ("uimenu"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2053 offset = 6;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2054 else if (len > 7)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2055 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2056 pfx = name.substr (0, 7);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2057
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2058 if (pfx.compare ("surface") || pfx.compare ("hggroup")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2059 || pfx.compare ("uipanel"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2060 offset = 7;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2061 else if (len > 9)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2062 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2063 pfx = name.substr (0, 9);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2064
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2065 if (pfx.compare ("uicontrol")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2066 || pfx.compare ("uitoolbar"))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2067 offset = 9;
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2068 else if (len > 10)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2069 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2070 pfx = name.substr (0, 10);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2071
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2072 if (pfx.compare ("uipushtool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2073 offset = 10;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2074 else if (len > 12)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2075 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2076 pfx = name.substr (0, 12);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2077
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2078 if (pfx.compare ("uitoggletool"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2079 offset = 12;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2080 else if (len > 13)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2081 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2082 pfx = name.substr (0, 13);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2083
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2084 if (pfx.compare ("uicontextmenu"))
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2085 offset = 13;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2086 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2087 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
2088 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2089 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2090 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2091 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2092 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2093
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2094 if (offset > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2095 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2096 std::string pname = name.substr (offset);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2097
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2098 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2099 std::transform (pname.begin (), pname.end (), pname.begin (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2100 tolower);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2101
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2102 plist_map_const_iterator p = find (pfx);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2103
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2104 if (p != end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2105 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2106 const pval_map_type& pval_map = p->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2107
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2108 pval_map_const_iterator q = pval_map.find (pname);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2109
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2110 if (q != pval_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2111 retval = q->second;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2112 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2113 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2114 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2115
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2116 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2117 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2118
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2119 octave_scalar_map
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2120 property_list::as_struct (const std::string& prefix_arg) const
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2121 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2122 octave_scalar_map m;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2123
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2124 for (plist_map_const_iterator p = begin (); p != end (); p++)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2125 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2126 std::string prefix = prefix_arg + p->first;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2127
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2128 const pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2129
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2130 for (pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2131 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2132 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2133 m.assign (prefix + q->first, q->second);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2134 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2135
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2136 return m;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2137 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
2138
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2139 // Set properties given as a cs-list of name, value pairs.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2140
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2141 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2142 graphics_object::set (const octave_value_list& args)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2143 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2144 int nargin = args.length ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2145
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2146 if (nargin == 0)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
2147 error ("graphics_object::set: Nothing to set");
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2148 else if (nargin % 2 != 0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2149 error ("set: invalid number of arguments");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2150 else
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2151 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2152 for (int i = 0; i < nargin; i += 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2153 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2154 caseless_str pname = args(i).string_value ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2155
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2156 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2157 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2158 octave_value val = args(i+1);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2159
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2160 set_value_or_default (pname, val);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2161 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2162 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2163 error ("set: expecting argument %d to be a property name", i);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2164 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2165 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2166 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2167
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2168 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2169 ## test set with name, value pairs
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2170 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2171 %! hf = figure ("visible", "off");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2172 %! h = plot (1:10, 10:-1:1);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2173 %! set (h, "linewidth", 10, "marker", "x");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2174 %! lw = get (h, "linewidth");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2175 %! mk = get (h, "marker");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2176 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2177 %! assert (lw, 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2178 %! assert (mk, "x");
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2179 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2180
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2181 // Set properties given in two cell arrays containing names and values.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2182 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2183 graphics_object::set (const Array<std::string>& pnames,
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2184 const Cell& values, octave_idx_type row)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2185 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2186 if (pnames.numel () != values.columns ())
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2187 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2188 error ("set: number of names must match number of value columns (%d != %d)",
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2189 pnames.numel (), values.columns ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2190 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2191
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2192 octave_idx_type k = pnames.columns ();
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2193
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2194 for (octave_idx_type column = 0; column < k; column++)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2195 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2196 caseless_str pname = pnames(column);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2197 octave_value val = values(row, column);
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2198
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2199 set_value_or_default (pname, val);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2200 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2201 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2202
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2203 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2204 ## test set with cell array arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2205 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2206 %! hf = figure ("visible", "off");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2207 %! h = plot (1:10, 10:-1:1);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2208 %! set (h, {"linewidth", "marker"}, {10, "x"});
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2209 %! lw = get (h, "linewidth");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2210 %! mk = get (h, "marker");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2211 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2212 %! assert (lw, 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2213 %! assert (mk, "x");
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2214
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2215 ## test set with multiple handles and cell array arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2216 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2217 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2218 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2219 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2220 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2221 %! assert (get (h, "linewidth"), {10; 5});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2222 %! assert (get (h, "marker"), {"x"; "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2223 %! set (h, {"linewidth", "marker"}, {10, "x"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2224 %! assert (get (h, "linewidth"), {10; 10});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2225 %! assert (get (h, "marker"), {"x"; "x"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2226 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2227 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2228 %! end_unwind_protect;
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2229
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2230 %!error <set: number of graphics handles must match number of value rows>
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2231 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2232 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2233 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2234 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2235 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2236 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2237 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2238
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2239 %!error <set: number of names must match number of value columns>
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2240 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2241 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2242 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2243 %! set (h, {"linewidth"}, {10, "x"; 5, "o"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2244 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2245 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2246 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2247 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2248
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2249 // Set properties given in a struct array
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2250 void
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2251 graphics_object::set (const octave_map& m)
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2252 {
15760
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2253 for (octave_idx_type p = 0; p < m.nfields (); p++)
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2254 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2255 // FIXME: Would it be better to extract all the keys at once rather than
20566
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20494
diff changeset
2256 // repeatedly call keys() inside a for loop?
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2257 caseless_str pname = m.keys ()[p];
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2258
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2259 octave_value val = octave_value (m.contents (pname).elem (m.numel () - 1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2260
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2261 set_value_or_default (pname, val);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2262 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2263 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2264
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2265 /*
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2266 ## test set ticklabels for compatibility
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2267 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2268 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2269 %! set (gca (), "xticklabel", [0, 0.2, 0.4, 0.6, 0.8, 1]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2270 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2271 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2272 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2273 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2274
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2275 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2276 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2277 %! set (gca (), "xticklabel", "0|0.2|0.4|0.6|0.8|1");
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2278 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2279 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2280 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2281 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2282
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2283 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2284 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2285 %! set (gca (), "xticklabel", ["0 "; "0.2"; "0.4"; "0.6"; "0.8"; "1 "]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2286 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2287 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2288 %! assert (class (xticklabel), "char");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2289 %! assert (size (xticklabel), [6, 3]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2290
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
2291 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2292 %! hf = figure ("visible", "off");
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2293 %! set (gca (), "xticklabel", {"0", "0.2", "0.4", "0.6", "0.8", "1"});
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2294 %! xticklabel = get (gca (), "xticklabel");
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2295 %! close (hf);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2296 %! assert (class (xticklabel), "cell");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
2297 %! assert (size (xticklabel), [6, 1]);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2298 */
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2299
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
2300 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2301 ## test set with struct arguments
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2302 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2303 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2304 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2305 %! h = plot (1:10, 10:-1:1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2306 %! set (h, struct ("linewidth", 10, "marker", "x"));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2307 %! assert (get (h, "linewidth"), 10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2308 %! assert (get (h, "marker"), "x");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2309 %! h = plot (1:10, 10:-1:1, 1:10, 1:10);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2310 %! set (h, struct ("linewidth", {5, 10}));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2311 %! assert (get (h, "linewidth"), {10; 10});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2312 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2313 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2314 %! end_unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2315
15760
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2316 ## test ordering
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2317 %!test
1ac3c906990a graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 15707
diff changeset
2318 %! markchanged = @(h, foobar, name) set (h, "userdata", [get(h,"userdata"); {name}]);
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2319 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2320 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2321 %! h = line ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2322 %! set (h, "userdata", {});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2323 %! addlistener (h, "color", {markchanged, "color"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2324 %! addlistener (h, "linewidth", {markchanged, "linewidth"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2325 %! ## "linewidth" first
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2326 %! props.linewidth = 2;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2327 %! props.color = "r";
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2328 %! set (h, props);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2329 %! assert (get (h, "userdata"), fieldnames (props));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2330 %! clear props;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2331 %! clf ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2332 %! h = line ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2333 %! set (h, "userdata", {});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2334 %! addlistener (h, "color", {markchanged, "color"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2335 %! addlistener (h, "linewidth", {markchanged, "linewidth"});
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2336 %! ## "color" first
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2337 %! props.color = "r";
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2338 %! props.linewidth = 2;
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2339 %! set (h, props);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2340 %! assert (get (h, "userdata"), fieldnames (props));
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2341 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2342 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
2343 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2344 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2345
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2346 // Set a property to a value or to its (factory) default value.
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2347
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2348 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2349 graphics_object::set_value_or_default (const caseless_str& pname,
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2350 const octave_value& val)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2351 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2352 if (val.is_string ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2353 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2354 std::string sval = val.string_value ();
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2355
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2356 octave_value default_val;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2357
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2358 if (sval.compare ("default") == 0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2359 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2360 default_val = get_default (pname);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2361
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2362 rep->set (pname, default_val);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2363 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2364 else if (sval.compare ("factory") == 0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2365 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2366 default_val = get_factory_default (pname);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2367
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2368 rep->set (pname, default_val);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2369 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2370 else
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2371 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2372 // Matlab specifically uses "\default" to escape string setting
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2373 if (sval.compare ("\\default") == 0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2374 rep->set (pname, "default");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2375 else if (sval.compare ("\\factory") == 0)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2376 rep->set (pname, "factory");
16312
d81ef5e64cf1 Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents: 16206
diff changeset
2377 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2378 rep->set (pname, val);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2379 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2380 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2381 else
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2382 rep->set (pname, val);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2383 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2384
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2385 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
2386 ## test setting of default values
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2387 %!test
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2388 %! old_lw = get (0, "defaultlinelinewidth");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2389 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2390 %! hf = figure ("visible", "off");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2391 %! h = plot (1:10, 10:-1:1);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2392 %! set (0, "defaultlinelinewidth", 20);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2393 %! set (h, "linewidth", "default");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2394 %! assert (get (h, "linewidth"), 20);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2395 %! set (h, "linewidth", "factory");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2396 %! assert (get (h, "linewidth"), 0.5);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2397 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2398 %! close (hf);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2399 %! set (0, "defaultlinelinewidth", old_lw);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
2400 %! end_unwind_protect
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2401 */
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
2402
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2403 static double
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2404 make_handle_fraction (void)
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2405 {
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2406 static double maxrand = RAND_MAX + 2.0;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2407
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2408 return (rand () + 1.0) / maxrand;
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2409 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2410
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2411 graphics_handle
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2412 gh_manager::do_get_handle (bool integer_figure_handle)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2413 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2414 graphics_handle retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2415
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
2416 if (integer_figure_handle)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2417 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2418 // Figure handles are positive integers corresponding
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2419 // to the figure number.
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2420
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2421 // We always want the lowest unused figure number.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2422
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2423 retval = 1;
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
2424
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2425 while (handle_map.find (retval) != handle_map.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2426 retval++;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2427 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2428 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2429 {
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2430 // Other graphics handles are negative integers plus some random
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2431 // fractional part. To avoid running out of integers, we recycle the
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2432 // integer part but tack on a new random part each time.
8234
8c4e79668a5e generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents: 8233
diff changeset
2433
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2434 free_list_iterator p = handle_free_list.begin ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2435
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2436 if (p != handle_free_list.end ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2437 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2438 retval = *p;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2439 handle_free_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2440 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2441 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2442 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2443 retval = graphics_handle (next_handle);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2444
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
2445 next_handle = std::ceil (next_handle) - 1.0 - make_handle_fraction ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2446 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2447 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2448
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2449 return retval;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2450 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2451
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2452 void
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2453 gh_manager::do_free (const graphics_handle& h)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2454 {
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2455 if (h.ok ())
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2456 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2457 if (h.value () != 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2458 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2459 iterator p = handle_map.find (h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2460
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2461 if (p != handle_map.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2462 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2463 base_properties& bp = p->second.get_properties ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
2464
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2465 bp.set_beingdeleted (true);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2466
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2467 bp.delete_children ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2468
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2469 octave_value val = bp.get_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2470
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2471 bp.execute_deletefcn ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2472
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2473 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2474 p->second.finalize ();
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
2475
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2476 // Note: this will be valid only for first explicitly deleted
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2477 // object. All its children will then have an
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2478 // unknown graphics toolkit.
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2479
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2480 // Graphics handles for non-figure objects are negative
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2481 // integers plus some random fractional part. To avoid
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2482 // running out of integers, we recycle the integer part
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2483 // but tack on a new random part each time.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2484
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2485 handle_map.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2486
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2487 if (h.value () < 0)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2488 handle_free_list.insert
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2489 (std::ceil (h.value ()) - make_handle_fraction ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2490 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2491 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2492 error ("graphics_handle::free: invalid object %g", h.value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2493 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2494 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2495 error ("graphics_handle::free: can't delete root figure");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2496 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2497 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2498
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2499 void
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2500 gh_manager::do_renumber_figure (const graphics_handle& old_gh,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2501 const graphics_handle& new_gh)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2502 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2503 iterator p = handle_map.find (old_gh);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2504
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2505 if (p != handle_map.end ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2506 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2507 graphics_object go = p->second;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2508
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2509 handle_map.erase (p);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2510
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2511 handle_map[new_gh] = go;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2512
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2513 if (old_gh.value () < 0)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2514 handle_free_list.insert (std::ceil (old_gh.value ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2515 - make_handle_fraction ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2516 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2517 else
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2518 error ("graphics_handle::free: invalid object %g", old_gh.value ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2519
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2520 for (figure_list_iterator q = figure_list.begin ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2521 q != figure_list.end (); q++)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2522 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2523 if (*q == old_gh)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2524 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2525 *q = new_gh;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2526 break;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2527 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2528 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2529 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2530
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2531 gh_manager *gh_manager::instance = 0;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2532
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2533 static void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2534 xset (const graphics_handle& h, const caseless_str& pname,
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2535 const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2536 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2537 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2538 go.set (pname, val);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2539 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2540
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2541 static void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2542 xset (const graphics_handle& h, const octave_value_list& args)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2543 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2544 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2545 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2546 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2547 go.set (args);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2548 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2549 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2550
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2551 static octave_value
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2552 xget (const graphics_handle& h, const caseless_str& pname)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2553 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2554 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2555 return go.get (pname);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2556 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2557
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2558 static graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2559 reparent (const octave_value& ov, const std::string& who,
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2560 const std::string& pname, const graphics_handle& new_parent,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2561 bool adopt = true)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2562 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2563 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2564
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2565 double hv = ov.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2566
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2567 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2568 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2569 h = gh_manager::lookup (hv);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2570
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2571 if (h.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2572 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2573 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2574
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2575 graphics_handle parent_h = go.get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2576
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2577 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2578
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2579 parent_go.remove_child (h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2580
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2581 if (adopt)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2582 go.set ("parent", new_parent.value ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2583 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2584 go.reparent (new_parent);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2585 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2586 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2587 error ("%s: invalid graphics handle (= %g) for %s",
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2588 who.c_str (), hv, pname.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2589 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2590 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2591 error ("%s: expecting %s to be a graphics handle",
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2592 who.c_str (), pname.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2593
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2594 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2595 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2596
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2597 // This function is NOT equivalent to the scripting language function gcf.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2598 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2599 gcf (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2600 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2601 octave_value val = xget (0, "currentfigure");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2602
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2603 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2604 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2605
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2606 // This function is NOT equivalent to the scripting language function gca.
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2607 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2608 gca (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2609 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2610 octave_value val = xget (gcf (), "currentaxes");
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2611
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2612 return val.is_empty () ? octave_NaN : val.double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2613 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2614
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2615 static void
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2616 delete_graphics_object (const graphics_handle& h)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2617 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2618 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2619 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2620 graphics_object go = gh_manager::get_object (h);
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2621
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2622 // Don't do recursive deleting, due to callbacks
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2623 if (! go.get_properties ().is_beingdeleted ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2624 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2625 graphics_handle parent_h = go.get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2626
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2627 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2628
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2629 // NOTE: free the handle before removing it from its parent's
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2630 // children, such that the object's state is correct when the
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2631 // deletefcn callback is executed
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2632
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2633 gh_manager::free (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2634
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2635 // A callback function might have already deleted the parent
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2636 if (parent_go.valid_object ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2637 parent_go.remove_child (h);
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2638
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2639 Vdrawnow_requested = true;
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2640 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2641 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2642 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2643
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2644 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2645 delete_graphics_object (double val)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2646 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2647 delete_graphics_object (gh_manager::lookup (val));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2648 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2649
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2650 static void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2651 delete_graphics_objects (const NDArray vals)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2652 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2653 for (octave_idx_type i = 0; i < vals.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2654 delete_graphics_object (vals.elem (i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2655 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2656
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2657 static void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2658 close_figure (const graphics_handle& h)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2659 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2660 octave_value closerequestfcn = xget (h, "closerequestfcn");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2661
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2662 OCTAVE_SAFE_CALL (gh_manager::execute_callback, (h, closerequestfcn));
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2663 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2664
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2665 static void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2666 force_close_figure (const graphics_handle& h)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2667 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2668 // Remove the deletefcn and closerequestfcn callbacks
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2669 // and delete the object directly.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2670
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2671 xset (h, "deletefcn", Matrix ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2672 xset (h, "closerequestfcn", Matrix ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2673
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2674 delete_graphics_object (h);
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2675 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2676
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2677 void
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2678 gh_manager::do_close_all_figures (void)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2679 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2680 // FIXME: should we process or discard pending events?
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2681
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2682 event_queue.clear ();
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2683
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2684 // Don't use figure_list_iterator because we'll be removing elements
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2685 // from the list elsewhere.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2686
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2687 Matrix hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2688
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2689 for (octave_idx_type i = 0; i < hlist.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2690 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2691 graphics_handle h = gh_manager::lookup (hlist(i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2692
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2693 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2694 close_figure (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2695 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2696
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2697 // They should all be closed now. If not, force them to close.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2698
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2699 hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2700
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2701 for (octave_idx_type i = 0; i < hlist.numel (); i++)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2702 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2703 graphics_handle h = gh_manager::lookup (hlist(i));
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2704
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2705 if (h.ok ())
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2706 force_close_figure (h);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2707 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2708
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2709 // None left now, right?
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2710
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2711 hlist = do_figure_handle_list (true);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2712
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2713 assert (hlist.numel () == 0);
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2714
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2715 // Clear all callback objects from our list.
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2716
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2717 callback_objects.clear ();
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2718 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2719
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2720 static void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2721 adopt (const graphics_handle& parent_h, const graphics_handle& h)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2722 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2723 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2724 parent_go.adopt (h);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2725 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2726
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2727 static bool
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2728 is_handle (const graphics_handle& h)
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2729 {
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2730 return h.ok ();
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2731 }
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2732
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
2733 static bool
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2734 is_handle (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2735 {
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2736 graphics_handle h = gh_manager::lookup (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2737
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
2738 return h.ok ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2739 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2740
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2741 static octave_value
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2742 is_handle (const octave_value& val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2743 {
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2744 octave_value retval = false;
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2745
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2746 if (val.is_real_scalar () && is_handle (val.double_value ()))
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2747 retval = true;
12587
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2748 else if (val.is_numeric_type () && val.is_real_type ())
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2749 {
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2750 const NDArray handles = val.array_value ();
c3d4542a4f06 graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents: 12549
diff changeset
2751
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2752 boolNDArray result (handles.dims ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2753
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2754 for (octave_idx_type i = 0; i < handles.numel (); i++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2755 result.xelem (i) = is_handle (handles(i));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2756
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2757 retval = result;
8183
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2758 }
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2759
277218396978 Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents: 8102
diff changeset
2760 return retval;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2761 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2762
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2763 static bool
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2764 is_figure (double val)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2765 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2766 graphics_object go = gh_manager::get_object (val);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2767
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2768 return go && go.isa ("figure");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2769 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2770
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2771 static void
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2772 xcreatefcn (const graphics_handle& h)
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2773 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2774 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2775 go.get_properties ().execute_createfcn ();
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2776 }
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
2777
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2778 static void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2779 xinitialize (const graphics_handle& h)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2780 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2781 graphics_object go = gh_manager::get_object (h);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
2782
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2783 if (go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2784 go.initialize ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2785 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2786
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2787 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2788
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2789 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2790 base_graphics_toolkit::update (const graphics_handle& h, int id)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2791 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2792 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2793
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2794 update (go, id);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2795 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2796
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2797 bool
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2798 base_graphics_toolkit::initialize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2799 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2800 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2801
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
2802 return initialize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2803 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2804
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2805 void
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
2806 base_graphics_toolkit::finalize (const graphics_handle& h)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2807 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2808 graphics_object go = gh_manager::get_object (h);
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2809
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10949
diff changeset
2810 finalize (go);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2811 }
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
2812
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2813 static void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2814 xreset_default_properties (graphics_handle h,
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2815 property_list::pval_map_type factory_pval)
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2816 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2817 graphics_object go = gh_manager::get_object (h);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2818
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2819 // Replace factory defaults by user defined ones
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2820 std::string go_name = go.get_properties ().graphics_object_name ();
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2821 property_list::pval_map_type pval;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2822 go.build_user_defaults_map (pval, go_name);
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2823
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2824 for (property_list::pval_map_const_iterator p = pval.begin ();
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2825 p != pval.end (); p++)
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2826 {
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2827 factory_pval[p->first] = p->second;
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2828 }
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2829
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
2830 // Reset defaults
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2831 for (property_list::pval_map_const_iterator it = factory_pval.begin ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2832 it != factory_pval.end (); it++)
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2833 {
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2834 std::string pname = it->first;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2835
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2836 // Don't reset internal properties and handle_properties
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2837 if (! go.has_readonly_property (pname)
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
2838 && pname.find ("__") != 0 && pname.find ("current") != 0
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
2839 && pname != "uicontextmenu" && pname != "parent")
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2840 {
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
2841 // Store *mode prop/val in order to set them last
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2842 if (pname.find ("mode") == (pname.length () - 4))
19120
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2843 pval[pname] = it->second;
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2844 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2845 go.set (pname, it->second);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2846 }
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2847 }
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2848
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2849 // set *mode properties
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2850 for (property_list::pval_map_const_iterator it = pval.begin ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2851 it != pval.end (); it++)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2852 go.set (it->first, it->second);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2853 }
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
2854
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2855 // ---------------------------------------------------------------------
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
2856
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2857 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2858 base_properties::set_from_list (base_graphics_object& bgo,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2859 property_list& defaults)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2860 {
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2861 std::string go_name = graphics_object_name ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2862
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2863 property_list::plist_map_const_iterator p = defaults.find (go_name);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2864
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2865 if (p != defaults.end ())
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2866 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2867 const property_list::pval_map_type pval_map = p->second;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2868
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2869 for (property_list::pval_map_const_iterator q = pval_map.begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2870 q != pval_map.end ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2871 q++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2872 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2873 std::string pname = q->first;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2874
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2875 bgo.set (pname, q->second);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2876
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2877 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2878 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2879 error ("error setting default property %s", pname.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2880 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2881 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2882 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2883 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2884 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2885
19120
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2886 /*
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2887 ## test defaults are set in the order they were stored
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2888 %!test
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2889 %! set(0, "defaultfigureunits", "normalized");
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2890 %! set(0, "defaultfigureposition", [0.7 0 0.3 0.3]);
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2891 %! hf = figure ("visible", "off");
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2892 %! tol = 20 * eps;
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2893 %! unwind_protect
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2894 %! assert (get (hf, "position"), [0.7 0 0.3 0.3], tol);
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2895 %! unwind_protect_cleanup
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2896 %! close (hf);
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2897 %! set(0, "defaultfigureunits", "remove");
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2898 %! set(0, "defaultfigureposition", "remove");
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2899 %! end_unwind_protect
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2900 */
dc88c5784f74 Respect the order in which default graphics properties are set (bug #38449)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19097
diff changeset
2901
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2902 octave_value
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2903 base_properties::get_dynamic (const caseless_str& pname) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2904 {
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2905 octave_value retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2906
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2907 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2908 all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2909
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2910 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2911 retval = it->second.get ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2912 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2913 error ("get: unknown property \"%s\"", pname.c_str ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2914
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2915 return retval;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2916 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2917
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2918 octave_value
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2919 base_properties::get_dynamic (bool all) const
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2920 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
2921 octave_scalar_map m;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2922
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2923 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2924 it = all_props.begin (); it != all_props.end (); ++it)
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2925 if (all || ! it->second.is_hidden ())
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
2926 m.assign (it->second.get_name (), it->second.get ());
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2927
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2928 return m;
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2929 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2930
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2931 std::set<std::string>
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2932 base_properties::dynamic_property_names (void) const
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2933 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2934 return dynamic_properties;
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2935 }
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
2936
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2937 bool
9972
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2938 base_properties::has_dynamic_property (const std::string& pname)
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2939 {
d32a6cc0193b unshare dynamic properties
John W. Eaton <jwe@octave.org>
parents: 9883
diff changeset
2940 const std::set<std::string>& dynprops = dynamic_property_names ();
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2941
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2942 if (dynprops.find (pname) != dynprops.end ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2943 return true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2944 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
2945 return all_props.find (pname) != all_props.end ();
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2946 }
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2947
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2948 void
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2949 base_properties::set_dynamic (const caseless_str& pname,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
2950 const octave_value& val)
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2951 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2952 std::map<caseless_str, property, cmp_caseless_str>::iterator it =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2953 all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2954
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2955 if (it != all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2956 it->second.set (val);
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2957 else
9185
1e5c11890f85 check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents: 9181
diff changeset
2958 error ("set: unknown property \"%s\"", pname.c_str ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2959
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2960 dynamic_properties.insert (pname);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2961
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
2962 mark_modified ();
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2963 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2964
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2965 property
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2966 base_properties::get_property_dynamic (const caseless_str& pname)
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2967 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2968 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2969 all_props.find (pname);
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2970
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2971 if (it == all_props.end ())
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2972 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2973 error ("get_property: unknown property \"%s\"", pname.c_str ());
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2974 return property ();
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2975 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2976 else
8061
f819e8992367 Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2977 return it->second;
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2978 }
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
2979
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2980 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
2981 base_properties::set_parent (const octave_value& val)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2982 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2983 double hp = val.double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2984
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2985 graphics_handle new_parent = octave_NaN;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
2986
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2987 if (! error_state)
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2988 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2989 if (hp == __myhandle__)
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2990 error ("set: can not set object parent to be object itself");
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
2991 else
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2992 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2993 new_parent = gh_manager::lookup (hp);
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2994
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2995 if (new_parent.ok ())
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
2996 {
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
2997 // Remove child from current parent
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2998 graphics_object old_parent_go;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
2999 old_parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3000
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3001 if (old_parent_go.get_handle () != hp)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3002 old_parent_go.remove_child (__myhandle__);
18449
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3003 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3004 return; // Do nothing more
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3005
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3006 // Check new parent's parent is not this child to avoid recursion
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3007 graphics_object new_parent_go;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3008 new_parent_go = gh_manager::get_object (new_parent);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3009 if (new_parent_go.get_parent () == __myhandle__)
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3010 {
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3011 // new parent's parent gets child's original parent
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3012 new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
17641
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3013 }
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3014
cd5a6008ae72 Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents: 17631
diff changeset
3015 // Set parent property to new_parent and do adoption
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
3016 parent = new_parent.as_octave_value ();
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
3017 ::adopt (parent.handle_value (), __myhandle__);
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
3018 }
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
3019 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3020 error ("set: invalid graphics handle (= %g) for parent", hp);
17626
82b1778798d3 Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents: 17608
diff changeset
3021 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3022 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3023 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3024 error ("set: expecting parent to be a graphics handle");
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3025 }
6432
5bec61ae1576 [project @ 2007-03-23 02:19:10 by jwe]
jwe
parents: 6425
diff changeset
3026
18449
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3027 /*
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3028 %!test
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3029 %! hf = figure ("visible", "off");
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3030 %! unwind_protect
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3031 %! hax = gca ();
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3032 %! set (hax, "parent", gcf ())
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3033 %! assert (gca (), hax)
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3034 %! unwind_protect_cleanup
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3035 %! close (hf);
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3036 %! end_unwind_protect
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3037 */
0cbd0d285541 Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18118
diff changeset
3038
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3039 void
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3040 base_properties::mark_modified (void)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3041 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3042 // Mark existing object as modified
20566
dcfbf4c1c3c8 eliminate trailing whitespace and tabs from sources
John W. Eaton <jwe@octave.org>
parents: 20494
diff changeset
3043 __modified__ = "on";
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3044 // Attempt to mark parent object as modified if it exists
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3045 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3046 if (parent_go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3047 parent_go.mark_modified ();
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3048 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3049
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3050 void
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3051 base_properties::override_defaults (base_graphics_object& obj)
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3052 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3053 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3054
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3055 if (parent_go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3056 parent_go.override_defaults (obj);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3057 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3058
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3059 void
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3060 base_properties::update_axis_limits (const std::string& axis_type) const
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3061 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3062 graphics_object go = gh_manager::get_object (__myhandle__);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3063
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3064 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3065 go.update_axis_limits (axis_type);
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3066 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3067
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
3068 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3069 base_properties::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3070 const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3071 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3072 graphics_object go = gh_manager::get_object (__myhandle__);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3073
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3074 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3075 go.update_axis_limits (axis_type, h);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3076 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3077
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3078 void
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3079 base_properties::update_uicontextmenu (void) const
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3080 {
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3081 if (uicontextmenu.get ().is_empty ())
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3082 return;
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20207
diff changeset
3083
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3084 graphics_object go = gh_manager::get_object (uicontextmenu.get ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3085 if (go && go.isa ("uicontextmenu"))
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3086 {
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3087 uicontextmenu::properties& props =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3088 reinterpret_cast<uicontextmenu::properties&> (go.get_properties ());
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3089 props.add_dependent_obj (__myhandle__);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3090 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3091 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
3092
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3093 bool
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3094 base_properties::is_handle_visible (void) const
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3095 {
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3096 return (handlevisibility.is ("on")
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
3097 || (executing_callback && ! handlevisibility.is ("off")));
13324
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3098 }
1e12601d2697 make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents: 13323
diff changeset
3099
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3100 graphics_toolkit
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3101 base_properties::get_toolkit (void) const
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3102 {
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3103 graphics_object go = gh_manager::get_object (get_parent ());
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3104
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3105 if (go)
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3106 return go.get_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3107 else
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
3108 return graphics_toolkit ();
7419
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3109 }
f62fb98f1da2 [project @ 2008-01-25 08:24:48 by jwe]
jwe
parents: 7409
diff changeset
3110
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3111 void
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3112 base_properties::update_boundingbox (void)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3113 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3114 Matrix kids = get_children ();
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3115
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3116 for (int i = 0; i < kids.numel (); i++)
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3117 {
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3118 graphics_object go = gh_manager::get_object (kids(i));
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3119
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3120 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3121 go.get_properties ().update_boundingbox ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3122 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3123 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3124
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
3125 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3126 base_properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
3127 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3128 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3129
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3130 if (parent_go.valid_object ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3131 parent_go.get_properties ().update_autopos (elem_type);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3132 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3133
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3134 void
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3135 base_properties::add_listener (const caseless_str& pname,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3136 const octave_value& val,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3137 listener_mode mode)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
3138 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3139 property p = get_property (pname);
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
3140
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3141 if (p.ok ())
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3142 p.add_listener (val, mode);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3143 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3144
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3145 void
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3146 base_properties::delete_listener (const caseless_str& pname,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3147 const octave_value& val,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3148 listener_mode mode)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3149 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3150 property p = get_property (pname);
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3151
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3152 if (p.ok ())
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3153 p.delete_listener (val, mode);
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3154 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3155
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3156 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3157
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3158 void
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3159 base_graphics_object::update_axis_limits (const std::string& axis_type)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3160 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3161 if (valid_object ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3162 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3163 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3164
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3165 if (parent_go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3166 parent_go.update_axis_limits (axis_type);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3167 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3168 else
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3169 error ("base_graphics_object::update_axis_limits: invalid graphics object");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3170 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3171
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3172 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3173 base_graphics_object::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3174 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3175 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3176 if (! valid_object ())
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3177 error ("base_graphics_object::update_axis_limits: invalid graphics object");
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3178 else
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3179 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3180 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3181
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3182 if (parent_go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3183 parent_go.update_axis_limits (axis_type, h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3184 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3185 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3186
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3187 void
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3188 base_graphics_object::remove_all_listeners (void)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3189 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3190 octave_map m = get (true).map_value ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3191
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3192 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3193 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
3194 // FIXME: there has to be a better way. I think we want to
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3195 // ask whether it is OK to delete the listener for the given
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3196 // property. How can we know in advance that it will be OK?
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3197
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
3198 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
3199
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
3200 frame.protect_var (discard_error_messages);
13849
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
3201 frame.protect_var (Vdebug_on_error);
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
3202 frame.protect_var (Vdebug_on_warning);
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3203
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3204 discard_error_messages = true;
13849
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
3205 Vdebug_on_error = false;
b4b8e525dee0 Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents: 13830
diff changeset
3206 Vdebug_on_warning = false;
9585
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3207
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3208 property p = get_properties ().get_property (pa->first);
06b8b51dca48 also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents: 9584
diff changeset
3209
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3210 if (p.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3211 p.delete_listener ();
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3212 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3213 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
3214
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20207
diff changeset
3215 void
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3216 base_graphics_object::build_user_defaults_map (property_list::pval_map_type &def, const std::string go_name) const
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3217 {
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3218 property_list local_defaults = get_defaults_list ();
19895
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3219 property_list::plist_map_const_iterator p =
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3220 local_defaults.find (go_name);
19895
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3221
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3222 if (p != local_defaults.end ())
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3223 {
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3224 property_list::pval_map_type pval = p->second;
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3225 for (property_list::pval_map_const_iterator q = pval.begin ();
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3226 q != pval.end (); q++)
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3227 {
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3228 std::string pname = q->first;
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3229 if (def.find (pname) == def.end ())
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3230 def[pname] = q->second;
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3231 }
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3232 }
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3233
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3234 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3235
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3236 if (parent_go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3237 parent_go.build_user_defaults_map (def, go_name);
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3238 }
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
3239
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3240 void
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3241 base_graphics_object::reset_default_properties (void)
19895
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3242 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3243 if (valid_object ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3244 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3245 property_list::pval_map_type factory_pval =
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3246 gh_manager::get_object (0).get_factory_defaults_list ()
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3247 .find (type ())->second;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3248
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3249 xreset_default_properties (get_handle (), factory_pval);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3250 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19868
diff changeset
3251 }
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3252
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3253 std::string
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3254 base_graphics_object::values_as_string (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3255 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3256 std::string retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3257
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3258 if (! valid_object ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3259 error ("base_graphics_object::values_as_string: invalid graphics object");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3260 else
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3261 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3262 octave_map m = get ().map_value ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3263 graphics_object go = gh_manager::get_object (get_handle ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3264
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3265 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3266 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3267 if (pa->first != "children" && ! go.has_readonly_property (pa->first))
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3268 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3269 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3270
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3271 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3272 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3273 retval += "\n\t" + std::string (pa->first) + ": ";
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3274 if (p.is_radio ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3275 retval += p.values_as_string ();
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3276 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3277 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3278 }
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3279
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3280 if (! retval.empty ())
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3281 retval += "\n";
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3282 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3283
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3284 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3285 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3286
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3287 std::string
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3288 base_graphics_object::value_as_string (const std::string& prop)
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3289 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3290 std::string retval;
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3291
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3292 if (! valid_object ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3293 error ("base_graphics_object::value_as_string: invalid graphics object");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3294 else
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3295 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3296 graphics_object go = gh_manager::get_object (get_handle ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3297
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3298 if (prop != "children" && ! go.has_readonly_property (prop))
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3299 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3300 property p = get_properties ().get_property (prop);
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3301
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3302 if (p.ok () && ! p.is_hidden ())
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3303 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3304 if (p.is_radio ())
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3305 retval += p.values_as_string ();
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3306 }
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3307 }
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3308
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
3309 if (! retval.empty ())
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3310 retval += "\n";
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3311 }
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3312
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3313 return retval;
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3314 }
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
3315
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3316 octave_scalar_map
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3317 base_graphics_object::values_as_struct (void)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3318 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3319 octave_scalar_map retval;
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3320
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3321 if (! valid_object ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3322 error ("base_graphics_object::values_as_struct: invalid graphics object");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3323 else
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3324 {
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3325 octave_scalar_map m = get ().scalar_map_value ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3326 graphics_object go = gh_manager::get_object (get_handle ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3327
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3328 for (octave_scalar_map::const_iterator pa = m.begin ();
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3329 pa != m.end (); pa++)
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3330 {
18580
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3331 if (pa->first != "children"
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3332 && ! go.has_readonly_property (pa->first))
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3333 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3334 property p = get_properties ().get_property (pa->first);
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3335
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3336 if (p.ok () && ! p.is_hidden ())
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3337 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3338 if (p.is_radio ())
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3339 retval.assign (p.get_name (), p.values_as_cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3340 else
11074
8a3b7e8fcbbc graphics.cc, graphics.h.in, genprops.awk: use octave_map and octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 10995
diff changeset
3341 retval.assign (p.get_name (), Cell ());
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3342 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3343 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3344 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3345 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3346
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3347 return retval;
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3348 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
3349
18580
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3350 /*
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3351 %!test
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3352 %! hfig = figure ("visible", "off");
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3353 %! unwind_protect
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3354 %! hax = axes ();
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3355 %! ret = set (hax, "tightinset");
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3356 %! assert (isempty (ret));
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3357 %! ret = set (hax, "type");
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3358 %! assert (isempty (ret));
19868
426525fb3b9f Hide Octave-only figure property __graphics_toolkit__.
Rik <rik@octave.org>
parents: 19829
diff changeset
3359 %! ret = set (hfig, "tag");
18580
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3360 %! assert (isempty (ret));
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3361 %! ret = set (0, "commandwindowsize");
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3362 %! assert (isempty (ret));
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3363 %! ret = set (0);
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3364 %! assert (! isfield (ret, "commandwindowsize"));
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3365 %! unwind_protect_cleanup
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3366 %! close (hfig);
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3367 %! end_unwind_protect
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
3368 */
19868
426525fb3b9f Hide Octave-only figure property __graphics_toolkit__.
Rik <rik@octave.org>
parents: 19829
diff changeset
3369
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3370 graphics_object
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3371 graphics_object::get_ancestor (const std::string& obj_type) const
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3372 {
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3373 if (valid_object ())
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3374 {
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3375 if (isa (obj_type))
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3376 return *this;
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3377 else
11492
d86389a6dc3f graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents: 11456
diff changeset
3378 return gh_manager::get_object (get_parent ()).get_ancestor (obj_type);
11250
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3379 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3380 else
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3381 return graphics_object ();
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3382 }
830b940e7ff4 Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents: 11239
diff changeset
3383
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3384 // ---------------------------------------------------------------------
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
3385
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3386 #include "graphics-props.cc"
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3387
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3388 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3389
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
3390 void
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3391 root_figure::properties::set_callbackobject (const octave_value& v)
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3392 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3393 graphics_handle val (v);
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3394
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3395 if (xisnan (val.value ()))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3396 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3397 if (! cbo_stack.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3398 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3399 val = cbo_stack.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3400
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3401 cbo_stack.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3402 }
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3403
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3404 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3405 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3406 else if (is_handle (val))
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3407 {
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3408 if (get_callbackobject ().ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3409 cbo_stack.push_front (get_callbackobject ());
7822
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3410
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3411 callbackobject = val;
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3412 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3413 else
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3414 gripe_set_invalid ("callbackobject");
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3415 }
edbaa13397ee Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7820
diff changeset
3416
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3417 void
18771
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3418 root_figure::properties::set_currentfigure (const octave_value& v)
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3419 {
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3420 graphics_handle val (v);
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3421
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3422 if (xisnan (val.value ()) || is_handle (val))
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3423 {
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3424 currentfigure = val;
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3425
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3426 if (val.ok ())
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3427 gh_manager::push_figure (val);
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3428 }
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3429 else
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3430 gripe_set_invalid ("currentfigure");
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3431 }
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3432
9fbb254c09e6 build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents: 18761
diff changeset
3433 void
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3434 figure::properties::set_integerhandle (const octave_value& val)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3435 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3436 if (integerhandle.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3437 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3438 bool int_fig_handle = integerhandle.is_on ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3439
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3440 graphics_object this_go = gh_manager::get_object (__myhandle__);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3441
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3442 graphics_handle old_myhandle = __myhandle__;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3443
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3444 __myhandle__ = gh_manager::get_handle (int_fig_handle);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3445
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3446 gh_manager::renumber_figure (old_myhandle, __myhandle__);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3447
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3448 graphics_object parent_go = gh_manager::get_object (get_parent ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3449
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3450 base_properties& props = parent_go.get_properties ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3451
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3452 props.renumber_child (old_myhandle, __myhandle__);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3453
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3454 Matrix kids = get_children ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3455
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3456 for (octave_idx_type i = 0; i < kids.numel (); i++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3457 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3458 graphics_object kid = gh_manager::get_object (kids(i));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3459
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3460 kid.get_properties ().renumber_parent (__myhandle__);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3461 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3462
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3463 graphics_handle cf = gh_manager::current_figure ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3464
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3465 if (__myhandle__ == cf)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3466 xset (0, "currentfigure", __myhandle__.value ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3467
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3468 this_go.update (integerhandle.get_id ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3469
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3470 mark_modified ();
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3471 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3472 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
3473
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3474 // FIXME: This should update monitorpositions and pointerlocation, but as these
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3475 // properties aren't yet used, it doesn't matter that they aren't set either.
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3476 void
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3477 root_figure::properties::update_units (void)
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3478 {
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3479 caseless_str xunits = get_units ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3480
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3481 Matrix scrn_sz = default_screensize ();
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3482
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3483 double dpi = get_screenpixelsperinch ();
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3484
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3485 if (xunits.compare ("inches"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3486 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3487 scrn_sz(0) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3488 scrn_sz(1) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3489 scrn_sz(2) /= dpi;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3490 scrn_sz(3) /= dpi;
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3491 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3492 else if (xunits.compare ("centimeters"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3493 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3494 scrn_sz(0) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3495 scrn_sz(1) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3496 scrn_sz(2) *= 2.54 / dpi;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3497 scrn_sz(3) *= 2.54 / dpi;
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3498 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3499 else if (xunits.compare ("normalized"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3500 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3501 scrn_sz = Matrix (1, 4, 1.0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3502 scrn_sz(0) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3503 scrn_sz(1) = 0;
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3504 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3505 else if (xunits.compare ("points"))
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3506 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3507 scrn_sz(0) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3508 scrn_sz(1) = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3509 scrn_sz(2) *= 72 / dpi;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3510 scrn_sz(3) *= 72 / dpi;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3511 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3512
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3513 set_screensize (scrn_sz);
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3514 }
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3515
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3516 Matrix
14604
de72463862c4 Silence warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14498
diff changeset
3517 root_figure::properties::get_boundingbox (bool, const Matrix&) const
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3518 {
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3519 Matrix screen_size = screen_size_pixels ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3520 Matrix pos = Matrix (1, 4, 0.0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3521
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3522 pos(2) = screen_size(0);
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3523 pos(3) = screen_size(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3524
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3525 return pos;
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3526 }
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14326
diff changeset
3527
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3528 /*
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3529 %!test
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3530 %! old_units = get (0, "units");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3531 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3532 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3533 %! sz = get (0, "screensize") - [1, 1, 0, 0];
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3534 %! dpi = get (0, "screenpixelsperinch");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3535 %! set (0, "units", "inches");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3536 %! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3537 %! set (0, "units", "centimeters");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3538 %! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3539 %! set (0, "units", "points");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3540 %! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3541 %! set (0, "units", "normalized");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3542 %! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3543 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3544 %! assert (get (0, "screensize"), sz + [1, 1, 0, 0]);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3545 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3546 %! set (0, "units", old_units);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
3547 %! end_unwind_protect
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3548 */
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
3549
8560
5cc594679cdc get display characteristics from system
John W. Eaton <jwe@octave.org>
parents: 8557
diff changeset
3550 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3551 root_figure::properties::remove_child (const graphics_handle& h)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3552 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3553 gh_manager::pop_figure (h);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3554
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3555 graphics_handle cf = gh_manager::current_figure ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3556
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3557 xset (0, "currentfigure", cf.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3558
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3559 base_properties::remove_child (h);
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3560 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
3561
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3562 property_list
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3563 root_figure::factory_properties = root_figure::init_factory_properties ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3564
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3565 void
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3566 root_figure::reset_default_properties (void)
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3567 {
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3568 // empty list of local defaults
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3569 default_properties = property_list ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3570
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3571 xreset_default_properties (get_handle (),
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
3572 xproperties.factory_defaults ());
10733
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3573 }
f72a761a784c eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents: 10722
diff changeset
3574
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3575 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
3576
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
3577 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3578 figure::properties::set_currentaxes (const octave_value& val)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3579 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3580 graphics_handle hax (val);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
3581
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3582 if (xisnan (hax.value ()) || is_handle (hax))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3583 currentaxes = hax;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3584 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3585 gripe_set_invalid ("currentaxes");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3586 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3587
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3588 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3589 figure::properties::remove_child (const graphics_handle& h)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3590 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3591 base_properties::remove_child (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3592
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3593 if (h == currentaxes.handle_value ())
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3594 {
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3595 graphics_handle new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3596
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3597 Matrix kids = get_children ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3598
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3599 for (octave_idx_type i = 0; i < kids.numel (); i++)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3600 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
3601 graphics_handle kid = kids(i);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3602
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3603 graphics_object go = gh_manager::get_object (kid);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3604
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3605 if (go.isa ("axes"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3606 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3607 new_currentaxes = kid;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3608 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3609 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
3610 }
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3611
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3612 currentaxes = new_currentaxes;
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3613 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3614 }
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3615
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3616 void
19078
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3617 figure::properties::adopt (const graphics_handle& h)
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3618 {
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3619 base_properties::adopt (h);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3620
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3621 if (! get_currentaxes ().ok ())
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3622 {
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3623 graphics_object go = gh_manager::get_object (h);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3624
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3625 if (go.type () == "axes")
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3626 set_currentaxes (h.as_octave_value ());
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3627 }
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3628 }
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3629
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3630 /*
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3631 %!test
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3632 %! hf1 = figure ("visible", "off");
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3633 %! ax1 = subplot (1,2,1);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3634 %! ax2 = subplot (1,2,2);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3635 %! hf2 = figure ("visible", "off");
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3636 %! unwind_protect
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3637 %! set (ax2, "parent", hf2);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3638 %! assert (get (hf2, "currentaxes"), ax2);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3639 %! assert (get (hf1, "currentaxes"), ax1);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3640 %! set (ax1, "parent", hf2);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3641 %! assert (get (hf2, "currentaxes"), ax2);
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3642 %! unwind_protect_cleanup
19097
f984fc55a825 Remove lef-tover figures in test from cset 4c59f69fa52c
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19081
diff changeset
3643 %! close (hf1);
f984fc55a825 Remove lef-tover figures in test from cset 4c59f69fa52c
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19081
diff changeset
3644 %! close (hf2);
19078
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3645 %! end_unwind_protect
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3646 */
4c59f69fa52c figure: define adopted axes "currentaxes" if none is defined (bug #41573)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19051
diff changeset
3647
8266
81b124f463f9 properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents: 8249
diff changeset
3648 void
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3649 figure::properties::set_visible (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3650 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3651 std::string sval = val.string_value ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3652
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3653 if (sval == "on")
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3654 xset (0, "currentfigure", __myhandle__.value ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3655
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3656 visible = val;
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3657 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
3658
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3659 Matrix
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3660 figure::properties::get_boundingbox (bool internal, const Matrix&) const
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3661 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3662 Matrix screen_size = screen_size_pixels ();
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3663 Matrix pos = (internal ?
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3664 get_position ().matrix_value () :
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3665 get_outerposition ().matrix_value ());
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3666
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3667 pos = convert_position (pos, get_units (), "pixels", screen_size);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3668
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3669 pos(0)--;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3670 pos(1)--;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
3671 pos(1) = screen_size(1) - pos(1) - pos(3);
7445
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3672
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3673 return pos;
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3674 }
af92b34f3a3a [project @ 2008-02-04 07:53:07 by jwe]
jwe
parents: 7440
diff changeset
3675
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3676 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3677 figure::properties::set_boundingbox (const Matrix& bb, bool internal,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3678 bool do_notify_toolkit)
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3679 {
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3680 Matrix screen_size = screen_size_pixels ();
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3681 Matrix pos = bb;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3682
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3683 pos(1) = screen_size(1) - pos(1) - pos(3);
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3684 pos(1)++;
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3685 pos(0)++;
9238
0ae2b6617005 Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9185
diff changeset
3686 pos = convert_position (pos, "pixels", get_units (), screen_size);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3687
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3688 if (internal)
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3689 set_position (pos, do_notify_toolkit);
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3690 else
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3691 set_outerposition (pos, do_notify_toolkit);
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3692 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3693
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3694 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3695 figure::properties::map_from_boundingbox (double x, double y) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3696 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3697 Matrix bb = get_boundingbox (true);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3698 Matrix pos (1, 2, 0.0);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3699
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3700 pos(0) = x;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3701 pos(1) = y;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3702
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3703 pos(1) = bb(3) - pos(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3704 pos(0)++;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3705 pos = convert_position (pos, "pixels", get_units (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3706 bb.extract_n (0, 2, 1, 2));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3707
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3708 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3709 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3710
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3711 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3712 figure::properties::map_to_boundingbox (double x, double y) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3713 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3714 Matrix bb = get_boundingbox (true);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3715 Matrix pos (1, 2, 0.0);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3716
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3717 pos(0) = x;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3718 pos(1) = y;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3719
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3720 pos = convert_position (pos, get_units (), "pixels",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3721 bb.extract_n (0, 2, 1, 2));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3722 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3723 pos(1) = bb(3) - pos(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3724
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3725 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3726 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
3727
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3728 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3729 figure::properties::set_position (const octave_value& v,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3730 bool do_notify_toolkit)
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3731 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3732 Matrix old_bb, new_bb;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3733 bool modified = false;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3734
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3735 old_bb = get_boundingbox (true);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3736 modified = position.set (v, false, do_notify_toolkit);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3737 new_bb = get_boundingbox (true);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3738
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3739 if (old_bb != new_bb)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3740 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3741 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3742 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3743 execute_resizefcn ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3744 update_boundingbox ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3745 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3746 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3747
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3748 if (modified)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3749 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3750 position.run_listeners (POSTSET);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3751 mark_modified ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3752 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3753
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3754 if (paperpositionmode.is ("auto"))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3755 paperposition.set (get_auto_paperposition ());
7828
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3756 }
4739b6a1925c Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7827
diff changeset
3757
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3758 void
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3759 figure::properties::set_outerposition (const octave_value& v,
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3760 bool do_notify_toolkit)
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3761 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3762 if (outerposition.set (v, true, do_notify_toolkit))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3763 mark_modified ();
13713
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3764 }
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3765
d99aa455296e Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13703
diff changeset
3766 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3767 figure::properties::set_paperunits (const octave_value& val)
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3768 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3769 caseless_str punits = val.string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3770 caseless_str ptype = get_papertype ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3771
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3772 if (punits.compare ("normalized") && ptype.compare ("<custom>"))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3773 error ("set: can't set paperunits to normalized when papertype is custom");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3774 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3775 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3776 caseless_str old_paperunits = get_paperunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3777 if (paperunits.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3778 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3779 update_paperunits (old_paperunits);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3780 mark_modified ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3781 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3782 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3783 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3784
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3785 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3786 figure::properties::set_papertype (const octave_value& val)
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3787 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3788 caseless_str ptype = val.string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3789 caseless_str punits = get_paperunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3790
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3791 if (punits.compare ("normalized") && ptype.compare ("<custom>"))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3792 error ("set: can't set paperunits to normalized when papertype is custom");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3793 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3794 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3795 if (papertype.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3796 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3797 update_papertype ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
3798 mark_modified ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3799 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3800 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3801 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3802
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3803 static Matrix
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3804 papersize_from_type (const caseless_str punits, const caseless_str ptype)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3805 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3806 Matrix retval (1, 2, 1.0);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3807
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3808 if (! punits.compare ("normalized"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3809 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3810 double in2units;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3811 double mm2units;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
3812
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3813 if (punits.compare ("inches"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3814 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3815 in2units = 1.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3816 mm2units = 1 / 25.4 ;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3817 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3818 else if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3819 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3820 in2units = 2.54;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3821 mm2units = 1 / 10.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3822 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3823 else // points
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3824 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3825 in2units = 72.0;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3826 mm2units = 72.0 / 25.4;
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3827 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3828
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3829 if (ptype.compare ("usletter"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3830 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3831 retval(0) = 8.5 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3832 retval(1) = 11.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3833 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3834 else if (ptype.compare ("uslegal"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3835 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3836 retval(0) = 8.5 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3837 retval(1) = 14.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3838 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3839 else if (ptype.compare ("tabloid"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3840 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3841 retval(0) = 11.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3842 retval(1) = 17.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3843 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3844 else if (ptype.compare ("a0"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3845 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3846 retval(0) = 841.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3847 retval(1) = 1189.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3848 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3849 else if (ptype.compare ("a1"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3850 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3851 retval(0) = 594.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3852 retval(1) = 841.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3853 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3854 else if (ptype.compare ("a2"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3855 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3856 retval(0) = 420.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3857 retval(1) = 594.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3858 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3859 else if (ptype.compare ("a3"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3860 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3861 retval(0) = 297.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3862 retval(1) = 420.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3863 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3864 else if (ptype.compare ("a4"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3865 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3866 retval(0) = 210.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3867 retval(1) = 297.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3868 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3869 else if (ptype.compare ("a5"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3870 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3871 retval(0) = 148.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3872 retval(1) = 210.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3873 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3874 else if (ptype.compare ("b0"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3875 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3876 retval(0) = 1029.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3877 retval(1) = 1456.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3878 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3879 else if (ptype.compare ("b1"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3880 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3881 retval(0) = 728.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3882 retval(1) = 1028.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3883 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3884 else if (ptype.compare ("b2"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3885 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3886 retval(0) = 514.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3887 retval(1) = 728.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3888 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3889 else if (ptype.compare ("b3"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3890 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3891 retval(0) = 364.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3892 retval(1) = 514.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3893 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3894 else if (ptype.compare ("b4"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3895 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3896 retval(0) = 257.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3897 retval(1) = 364.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3898 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3899 else if (ptype.compare ("b5"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3900 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3901 retval(0) = 182.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3902 retval(1) = 257.0 * mm2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3903 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3904 else if (ptype.compare ("arch-a"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3905 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3906 retval(0) = 9.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3907 retval(1) = 12.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3908 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3909 else if (ptype.compare ("arch-b"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3910 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3911 retval(0) = 12.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3912 retval(1) = 18.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3913 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3914 else if (ptype.compare ("arch-c"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3915 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3916 retval(0) = 18.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3917 retval(1) = 24.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3918 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3919 else if (ptype.compare ("arch-d"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3920 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3921 retval(0) = 24.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3922 retval(1) = 36.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3923 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3924 else if (ptype.compare ("arch-e"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3925 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3926 retval(0) = 36.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3927 retval(1) = 48.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3928 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3929 else if (ptype.compare ("a"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3930 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3931 retval(0) = 8.5 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3932 retval(1) = 11.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3933 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3934 else if (ptype.compare ("b"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3935 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3936 retval(0) = 11.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3937 retval(1) = 17.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3938 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3939 else if (ptype.compare ("c"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3940 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3941 retval(0) = 17.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3942 retval(1) = 22.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3943 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3944 else if (ptype.compare ("d"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3945 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3946 retval(0) = 22.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3947 retval(1) = 34.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3948 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3949 else if (ptype.compare ("e"))
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3950 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3951 retval(0) = 34.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3952 retval(1) = 43.0 * in2units;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3953 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3954 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3955
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
3956 return retval;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3957 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
3958
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3959
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3960 Matrix
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3961 figure::properties::get_auto_paperposition (void)
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3962 {
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3963 Matrix pos = get_position ().matrix_value ();
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3964 Matrix sz;
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3965
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3966 caseless_str funits = get_units ();
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3967 caseless_str punits = get_paperunits ();
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3968
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3969 // Convert position from figure units to paperunits
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3970 if (funits == "normalized" || punits == "normalized")
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3971 {
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3972 sz = screen_size_pixels ();
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3973 pos = convert_position (pos, funits, "inches", sz);
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3974
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3975 if (punits == "normalized")
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3976 sz = papersize_from_type ("points", get_papertype ());
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3977
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3978 pos = convert_position (pos, "inches", punits, sz);
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3979 }
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3980 else
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3981 pos = convert_position (pos, funits, punits, sz);
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3982
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3983 // Center the figure on the page
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3984 sz = get_papersize ().matrix_value ();
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3985
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3986 pos(0) = sz(0)/2 - pos(2)/2;
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3987 pos(1) = sz(1)/2 - pos(3)/2;
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3988
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3989 return pos;
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3990 }
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3991
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3992 /*
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3993 %!test
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
3994 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
3995 %! in_pos = [0 0 4 5];
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
3996 %! tol = 20 * eps ();
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3997 %! unwind_protect
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
3998 %! ## paperpositionmode "auto" converts figure size to paper units
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
3999 %! set (hf, "units", "inches");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4000 %! set (hf, "position", in_pos);
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4001 %! set (hf, "paperunits", "centimeters");
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4002 %! psz = get (hf, "papersize");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4003 %! fsz = in_pos(3:4) * 2.54;
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4004 %! pos = [(psz/2 .- fsz/2) fsz];
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4005 %! set (hf, "paperpositionmode", "auto");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4006 %! assert (get (hf, "paperposition"), pos, tol)
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4007 %! unwind_protect_cleanup
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4008 %! close (hf);
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4009 %! end_unwind_protect
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4010
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4011 %!test
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4012 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4013 %! in_pos = [0 0 4 5];
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4014 %! tol = 20 * eps ();
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4015 %! unwind_protect
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4016 %! ## likewise with normalized units
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4017 %! set (hf, "units", "inches");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4018 %! set (hf, "position", in_pos);
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4019 %! psz = get (hf, "papersize");
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4020 %! set (hf, "paperunits", "normalized");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4021 %! fsz = in_pos(3:4) ./ psz;
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4022 %! pos = [([0.5 0.5] .- fsz/2) fsz];
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4023 %! assert (get (hf, "paperposition"), pos, tol)
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4024 %! unwind_protect_cleanup
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4025 %! close (hf);
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4026 %! end_unwind_protect
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4027
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4028 %!test
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4029 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4030 %! in_pos = [0 0 4 5];
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4031 %! tol = 20 * eps ();
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4032 %! unwind_protect
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4033 %! ## changing papertype updates paperposition
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4034 %! set (hf, "units", "inches");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4035 %! set (hf, "position", in_pos);
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4036 %! set (hf, "papertype", "a4");
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4037 %! psz = get (hf, "papersize");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4038 %! fsz = in_pos(3:4);
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4039 %! pos = [(psz/2 .- fsz/2) fsz];
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4040 %! assert (get (hf, "paperposition"), pos, tol)
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4041 %! unwind_protect_cleanup
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4042 %! close (hf);
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4043 %! end_unwind_protect
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4044
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4045 %!test
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4046 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4047 %! in_pos = [0 0 4 5];
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4048 %! tol = 20 * eps ();
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4049 %! unwind_protect
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4050 %! ## lanscape updates paperposition
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4051 %! set (hf, "units", "inches");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4052 %! set (hf, "position", in_pos);
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4053 %! set (hf, "paperorientation", "landscape");
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4054 %! psz = get (hf, "papersize");
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4055 %! fsz = in_pos(3:4);
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4056 %! pos = [(psz/2 .- fsz/2) fsz];
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4057 %! assert (get (hf, "paperposition"), pos, tol)
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4058 %! unwind_protect_cleanup
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4059 %! close (hf);
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4060 %! end_unwind_protect
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4061
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4062 %!test
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4063 %! hf = figure ("visible", "off", "paperpositionmode", "auto");
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4064 %! in_pos = [0 0 4 5];
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4065 %! unwind_protect
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4066 %! ## back to manual mode
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4067 %! set (hf, "paperposition", in_pos * 1.1)
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4068 %! assert (get (hf, "paperpositionmode"), "manual")
18926
2420a4f22998 Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18925
diff changeset
4069 %! assert (get (hf, "paperposition"), in_pos * 1.1)
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4070 %! unwind_protect_cleanup
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4071 %! close (hf);
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4072 %! end_unwind_protect
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4073 */
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4074
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4075 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4076 figure::properties::update_paperunits (const caseless_str& old_paperunits)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4077 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4078 Matrix pos = get_paperposition ().matrix_value ();
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4079 Matrix sz = get_papersize ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4080
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4081 pos(0) /= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4082 pos(1) /= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4083 pos(2) /= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4084 pos(3) /= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4085
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4086 std::string porient = get_paperorientation ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4087 caseless_str punits = get_paperunits ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4088 caseless_str ptype = get_papertype ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4089
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4090 if (ptype.compare ("<custom>"))
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4091 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4092 if (old_paperunits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4093 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4094 sz(0) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4095 sz(1) /= 2.54;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4096 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4097 else if (old_paperunits.compare ("points"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4098 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4099 sz(0) /= 72.0;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4100 sz(1) /= 72.0;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4101 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4102
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4103 if (punits.compare ("centimeters"))
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4104 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4105 sz(0) *= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4106 sz(1) *= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4107 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4108 else if (punits.compare ("points"))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4109 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4110 sz(0) *= 72.0;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4111 sz(1) *= 72.0;
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4112 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4113 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4114 else
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4115 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4116 sz = papersize_from_type (punits, ptype);
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4117 if (porient == "landscape")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4118 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4119 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4120
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4121 pos(0) *= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4122 pos(1) *= sz(1);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4123 pos(2) *= sz(0);
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4124 pos(3) *= sz(1);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4125
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4126 papersize.set (octave_value (sz));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4127 paperposition.set (octave_value (pos));
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4128 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4129
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4130 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4131 figure::properties::update_papertype (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4132 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4133 caseless_str typ = get_papertype ();
10994
9e1270a84a10 graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents: 10991
diff changeset
4134 if (! typ.compare ("<custom>"))
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4135 {
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4136 Matrix sz = papersize_from_type (get_paperunits (), typ);
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4137 if (get_paperorientation () == "landscape")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4138 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4139 // Call papersize.set rather than set_papersize to avoid loops
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4140 // between update_papersize and update_papertype.
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4141 papersize.set (octave_value (sz));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4142 }
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4143
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4144 if (paperpositionmode.is ("auto"))
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4145 paperposition.set (get_auto_paperposition ());
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4146 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4147
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4148 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4149 figure::properties::update_papersize (void)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4150 {
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4151 Matrix sz = get_papersize ().matrix_value ();
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4152 if (sz(0) > sz(1))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4153 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4154 std::swap (sz(0), sz(1));
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4155 papersize.set (octave_value (sz));
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4156 paperorientation.set (octave_value ("landscape"));
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4157 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4158 else
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4159 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4160 paperorientation.set ("portrait");
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4161 }
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4162
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4163 std::string punits = get_paperunits ();
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4164 if (punits == "centimeters")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4165 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4166 sz(0) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4167 sz(1) /= 2.54;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4168 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4169 else if (punits == "points")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4170 {
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4171 sz(0) /= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4172 sz(1) /= 72.0;
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4173 }
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4174 if (punits == "normalized")
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4175 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4176 if (get_papertype () == "<custom>")
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4177 error ("set: can't set the papertype to <custom> when the paperunits is normalized");
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4178 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4179 else
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4180 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4181 // FIXME: The papersizes info is also in papersize_from_type().
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4182 // Both should be rewritten to avoid the duplication.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4183 // Don't Repeat Yourself (DRY) principle.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4184 std::string ptype = "<custom>";
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4185 const double mm2in = 1.0 / 25.4;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4186 const double tol = 0.01;
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4187
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4188 if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4189 ptype = "usletter";
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4190 else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4191 ptype = "uslegal";
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4192 else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4193 ptype = "tabloid";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4194 else if (std::abs (sz(0) - 841.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4195 + std::abs (sz(1) - 1198.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4196 ptype = "a0";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4197 else if (std::abs (sz(0) - 594.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4198 + std::abs (sz(1) - 841.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4199 ptype = "a1";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4200 else if (std::abs (sz(0) - 420.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4201 + std::abs (sz(1) - 594.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4202 ptype = "a2";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4203 else if (std::abs (sz(0) - 297.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4204 + std::abs (sz(1) - 420.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4205 ptype = "a3";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4206 else if (std::abs (sz(0) - 210.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4207 + std::abs (sz(1) - 297.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4208 ptype = "a4";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4209 else if (std::abs (sz(0) - 148.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4210 + std::abs (sz(1) - 210.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4211 ptype = "a5";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4212 else if (std::abs (sz(0) - 1029.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4213 + std::abs (sz(1) - 1456.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4214 ptype = "b0";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4215 else if (std::abs (sz(0) - 728.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4216 + std::abs (sz(1) - 1028.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4217 ptype = "b1";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4218 else if (std::abs (sz(0) - 514.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4219 + std::abs (sz(1) - 728.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4220 ptype = "b2";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4221 else if (std::abs (sz(0) - 364.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4222 + std::abs (sz(1) - 514.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4223 ptype = "b3";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4224 else if (std::abs (sz(0) - 257.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4225 + std::abs (sz(1) - 364.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4226 ptype = "b4";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4227 else if (std::abs (sz(0) - 182.0 * mm2in)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4228 + std::abs (sz(1) - 257.0 * mm2in) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4229 ptype = "b5";
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18806
diff changeset
4230 else if (std::abs (sz(0) - 9.0)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4231 + std::abs (sz(1) - 12.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4232 ptype = "arch-a";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4233 else if (std::abs (sz(0) - 12.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4234 + std::abs (sz(1) - 18.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4235 ptype = "arch-b";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4236 else if (std::abs (sz(0) - 18.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4237 + std::abs (sz(1) - 24.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4238 ptype = "arch-c";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4239 else if (std::abs (sz(0) - 24.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4240 + std::abs (sz(1) - 36.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4241 ptype = "arch-d";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4242 else if (std::abs (sz(0) - 36.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4243 + std::abs (sz(1) - 48.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4244 ptype = "arch-e";
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18806
diff changeset
4245 else if (std::abs (sz(0) - 8.5)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4246 + std::abs (sz(1) - 11.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4247 ptype = "a";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4248 else if (std::abs (sz(0) - 11.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4249 + std::abs (sz(1) - 17.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4250 ptype = "b";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4251 else if (std::abs (sz(0) - 17.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4252 + std::abs (sz(1) - 22.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4253 ptype = "c";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4254 else if (std::abs (sz(0) - 22.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4255 + std::abs (sz(1) - 34.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4256 ptype = "d";
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4257 else if (std::abs (sz(0) - 34.0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4258 + std::abs (sz(1) - 43.0) < tol)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4259 ptype = "e";
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4260 // Call papertype.set rather than set_papertype to avoid loops between
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4261 // update_papersize and update_papertype
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4262 papertype.set (ptype);
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4263 }
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4264 if (punits == "centimeters")
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4265 {
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4266 sz(0) *= 2.54;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4267 sz(1) *= 2.54;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4268 }
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4269 else if (punits == "points")
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4270 {
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4271 sz(0) *= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4272 sz(1) *= 72.0;
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4273 }
14457
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
4274 if (get_paperorientation () == "landscape")
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
4275 {
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
4276 std::swap (sz(0), sz(1));
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
4277 papersize.set (octave_value (sz));
008a29999c3d Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents: 14429
diff changeset
4278 }
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4279
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4280 if (paperpositionmode.is ("auto"))
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4281 paperposition.set (get_auto_paperposition ());
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4282 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4283
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4284 /*
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4285 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4286 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4287 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4288 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4289 %! set (hf, "papersize", [5, 4]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4290 %! set (hf, "paperunits", "points");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4291 %! assert (get (hf, "papersize"), [5, 4] * 72, 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4292 %! papersize = get (hf, "papersize");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4293 %! set (hf, "papersize", papersize + 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4294 %! set (hf, "papersize", papersize);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4295 %! assert (get (hf, "papersize"), [5, 4] * 72, 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4296 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4297 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4298 %! end_unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4299
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4300 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4301 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4302 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4303 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4304 %! set (hf, "papersize", [5, 4]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4305 %! set (hf, "paperunits", "centimeters");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4306 %! assert (get (hf, "papersize"), [5, 4] * 2.54, 2.54/72);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4307 %! papersize = get (hf, "papersize");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4308 %! set (hf, "papersize", papersize + 1);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4309 %! set (hf, "papersize", papersize);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4310 %! assert (get (hf, "papersize"), [5, 4] * 2.54, 2.54/72);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4311 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4312 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4313 %! end_unwind_protect
14498
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4314 */
36cfbd23fe9f Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents: 14483
diff changeset
4315
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4316 void
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4317 figure::properties::update_paperorientation (void)
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4318 {
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4319 std::string porient = get_paperorientation ();
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4320 Matrix sz = get_papersize ().matrix_value ();
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4321 Matrix pos = get_paperposition ().matrix_value ();
14258
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4322 if ((sz(0) > sz(1) && porient == "portrait")
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4323 || (sz(0) < sz(1) && porient == "landscape"))
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4324 {
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4325 std::swap (sz(0), sz(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4326 std::swap (pos(0), pos(1));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4327 std::swap (pos(2), pos(3));
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4328 // Call papertype.set rather than set_papertype to avoid loops
08779abcb640 maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents: 14257
diff changeset
4329 // between update_papersize and update_papertype
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4330 papersize.set (octave_value (sz));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4331 paperposition.set (octave_value (pos));
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4332 }
18807
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4333
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4334 if (paperpositionmode.is ("auto"))
70ea5a2856fe Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18798
diff changeset
4335 paperposition.set (get_auto_paperposition ());
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4336 }
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4337
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4338 /*
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4339 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4340 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4341 %! unwind_protect
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4342 %! tol = 100 * eps ();
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4343 %! ## UPPER case and MiXed case is part of test and should not be changed.
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4344 %! set (hf, "paperorientation", "PORTRAIT");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4345 %! set (hf, "paperunits", "inches");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4346 %! set (hf, "papertype", "USletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4347 %! assert (get (hf, "papersize"), [8.5, 11.0], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4348 %! set (hf, "paperorientation", "Landscape");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4349 %! assert (get (hf, "papersize"), [11.0, 8.5], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4350 %! set (hf, "paperunits", "centimeters");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4351 %! assert (get (hf, "papersize"), [11.0, 8.5] * 2.54, tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4352 %! set (hf, "papertype", "a4");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4353 %! assert (get (hf, "papersize"), [29.7, 21.0], tol);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4354 %! set (hf, "paperunits", "inches", "papersize", [8.5, 11.0]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4355 %! assert (get (hf, "papertype"), "usletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4356 %! assert (get (hf, "paperorientation"), "portrait");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4357 %! set (hf, "papersize", [11.0, 8.5]);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4358 %! assert (get (hf, "papertype"), "usletter");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4359 %! assert (get (hf, "paperorientation"), "landscape");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4360 %! unwind_protect_cleanup
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4361 %! close (hf);
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4362 %! end_unwind_protect
14257
5cc69bafe3b9 Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents: 14138
diff changeset
4363 */
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4364
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4365 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4366 figure::properties::set_units (const octave_value& val)
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4367 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4368 caseless_str old_units = get_units ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4369
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4370 if (units.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4371 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4372 update_units (old_units);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4373 mark_modified ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4374 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4375 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4376
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4377 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4378 figure::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4379 {
14367
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
4380 position.set (convert_position (get_position ().matrix_value (), old_units,
ba01a38bc5c1 Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
4381 get_units (), screen_size_pixels ()), false);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4382 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
4383
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
4384 /*
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
4385 %!test
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4386 %! hf = figure ("visible", "off");
17237
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4387 %! old_units = get (0, "units");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4388 %! unwind_protect
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4389 %! set (0, "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4390 %! rsz = get (0, "screensize");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4391 %! set (gcf (), "units", "pixels");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4392 %! fsz = get (gcf (), "position");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4393 %! set (gcf (), "units", "normalized");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4394 %! pos = get (gcf (), "position");
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4395 %! assert (pos, (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4]));
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4396 %! unwind_protect_cleanup
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4397 %! close (hf);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4398 %! set (0, "units", old_units);
5f14fc8feba3 graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents: 17223
diff changeset
4399 %! end_unwind_protect
14266
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
4400 */
37ca58f9a887 When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents: 14258
diff changeset
4401
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4402 std::string
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4403 figure::properties::get_title (void) const
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4404 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4405 if (is_numbertitle ())
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4406 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4407 std::ostringstream os;
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
4408 std::string nm = get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4409
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4410 os << "Figure " << __myhandle__.value ();
8062
e04a4beeb283 graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents: 8061
diff changeset
4411 if (! nm.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4412 os << ": " << get_name ();
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4413
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4414 return os.str ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4415 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4416 else
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4417 return get_name ();
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4418 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 8058
diff changeset
4419
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4420 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
4421 figure::get_default (const caseless_str& name) const
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4422 {
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4423 octave_value retval = default_properties.lookup (name);
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4424
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4425 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4426 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4427 graphics_handle parent_h = get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4428 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4429
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4430 retval = parent_go.get_default (name);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4431 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4432
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4433 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4434 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
4435
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4436 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4437 figure::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4438 {
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4439 // empty list of local defaults
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4440 default_properties = property_list ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4441
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4442 property_list::pval_map_type plist = xproperties.factory_defaults ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4443 plist.erase ("units");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4444 plist.erase ("position");
19684
50f14692e33b Freset: do not reset figure outerposition (part of bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19680
diff changeset
4445 plist.erase ("outerposition");
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4446 plist.erase ("paperunits");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4447 plist.erase ("paperposition");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4448 plist.erase ("windowstyle");
19700
e7df12f37f71 Freset: avoid multiple reseting of properties (bug #43960)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19697
diff changeset
4449
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4450 xreset_default_properties (get_handle (), plist);
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4451 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
4452
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4453 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4454
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4455 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4456 axes::properties::init (void)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4457 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4458 position.add_constraint (dim_vector (1, 4));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4459 outerposition.add_constraint (dim_vector (1, 4));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4460 tightinset.add_constraint (dim_vector (1, 4));
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4461 looseinset.add_constraint (dim_vector (1, 4));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4462 colororder.add_constraint (dim_vector (-1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4463 dataaspectratio.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4464 plotboxaspectratio.add_constraint (dim_vector (1, 3));
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4465 // FIXME: Should these use dimension vectors? Currently can set 'xlim' to
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4466 // any matrix size, but only first two elements are used.
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4467 alim.add_constraint (2);
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4468 clim.add_constraint (2);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4469 xlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4470 ylim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4471 zlim.add_constraint (2);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4472 xtick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4473 ytick.add_constraint (dim_vector (1, -1));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4474 ztick.add_constraint (dim_vector (1, -1));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4475 ticklength.add_constraint (dim_vector (1, 2));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4476 Matrix vw (1, 2, 0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4477 vw(1) = 90;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4478 view = vw;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4479 view.add_constraint (dim_vector (1, 2));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4480 cameraposition.add_constraint (dim_vector (1, 3));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4481 cameratarget.add_constraint (dim_vector (1, 3));
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4482 Matrix upv (1, 3, 0.0);
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4483 upv(2) = 1.0;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4484 cameraupvector = upv;
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4485 cameraupvector.add_constraint (dim_vector (1, 3));
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4486 currentpoint.add_constraint (dim_vector (2, 3));
17631
94dd9bba06a0 Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents: 17626
diff changeset
4487 // No constraints for hidden transform properties
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
4488 update_font ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4489
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4490 x_zlim.resize (1, 2);
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4491
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4492 sx = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4493 sy = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4494 sz = "linear";
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4495
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4496 calc_ticklabels (xtick, xticklabel, xscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4497 calc_ticklabels (ytick, yticklabel, yscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4498 calc_ticklabels (ztick, zticklabel, zscale.is ("log"));
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4499
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4500 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4501 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4502 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4503 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4504
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4505 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4506 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4507 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4508 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4509 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4510 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4511 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4512 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4513
16204
92f8bfae9b13 Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents: 16201
diff changeset
4514 xset (xlabel.handle_value (), "verticalalignment", "top");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4515 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4516 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4517 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4518 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4519 xset (title.handle_value (), "verticalalignmentmode", "auto");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4520
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4521 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4522 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4523
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4524 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4525
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4526 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4527 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4528 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4529 xset (title.handle_value (), "clipping", "off");
8557
ab82e19002c4 better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents: 8503
diff changeset
4530
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4531 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4532 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4533 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4534 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4535
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4536 adopt (xlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4537 adopt (ylabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4538 adopt (zlabel.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4539 adopt (title.handle_value ());
12467
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4540
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4541 Matrix tlooseinset = default_axes_position ();
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4542 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4543 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3);
2f83974d5a6d implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12458
diff changeset
4544 looseinset = tlooseinset;
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4545 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4546
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4547 Matrix
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4548 axes::properties::calc_tightbox (const Matrix& init_pos)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4549 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4550 Matrix pos = init_pos;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4551 graphics_object go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4552 Matrix parent_bb = go.get_properties ().get_boundingbox (true);
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
4553 Matrix ext = get_extent (true, true);
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4554 ext(1) = parent_bb(3) - ext(1) - ext(3);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4555 ext(0)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4556 ext(1)++;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4557 ext = convert_position (ext, "pixels", get_units (),
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4558 parent_bb.extract_n (0, 2, 1, 2));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4559 if (ext(0) < pos(0))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4560 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4561 pos(2) += pos(0)-ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4562 pos(0) = ext(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4563 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4564 if (ext(0)+ext(2) > pos(0)+pos(2))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4565 pos(2) = ext(0)+ext(2)-pos(0);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4566
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4567 if (ext(1) < pos(1))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4568 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4569 pos(3) += pos(1)-ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4570 pos(1) = ext(1);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4571 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4572 if (ext(1)+ext(3) > pos(1)+pos(3))
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4573 pos(3) = ext(1)+ext(3)-pos(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4574
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4575 return pos;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4576 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
4577
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4578 void
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4579 axes::properties::sync_positions (void)
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4580 {
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4581 // First part is equivalent to `update_tightinset ()'
17216
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4582 if (activepositionproperty.is ("position"))
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4583 update_position ();
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4584 else
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4585 update_outerposition ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4586 caseless_str old_units = get_units ();
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4587 set_units ("normalized");
16832
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4588 Matrix pos = position.get ().matrix_value ();
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4589 Matrix outpos = outerposition.get ().matrix_value ();
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4590 Matrix tightpos = calc_tightbox (pos);
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4591 Matrix tinset (1, 4, 1.0);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4592 tinset(0) = pos(0)-tightpos(0);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4593 tinset(1) = pos(1)-tightpos(1);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4594 tinset(2) = tightpos(0)+tightpos(2)-pos(0)-pos(2);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4595 tinset(3) = tightpos(1)+tightpos(3)-pos(1)-pos(3);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4596 tightinset = tinset;
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4597 set_units (old_units);
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4598 update_transform ();
17260
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4599 if (activepositionproperty.is ("position"))
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4600 update_position ();
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4601 else
92effb035b97 Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17237
diff changeset
4602 update_outerposition ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4603 }
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4604
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4605 /*
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4606 %!testif HAVE_FLTK
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4607 %! hf = figure ("visible", "off");
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4608 %! graphics_toolkit (hf, "fltk");
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4609 %! unwind_protect
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4610 %! subplot(2,1,1); plot(rand(10,1)); subplot(2,1,2); plot(rand(10,1));
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4611 %! hax = findall (gcf (), "type", "axes");
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4612 %! positions = cell2mat (get (hax, "position"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4613 %! outerpositions = cell2mat (get (hax, "outerposition"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4614 %! looseinsets = cell2mat (get (hax, "looseinset"));
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4615 %! tightinsets = cell2mat (get (hax, "tightinset"));
17150
e7723410ec32 Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents: 17123
diff changeset
4616 %! subplot(2,1,1); plot(rand(10,1)); subplot(2,1,2); plot(rand(10,1));
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4617 %! hax = findall (gcf (), "type", "axes");
17216
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4618 %! assert (cell2mat (get (hax, "position")), positions, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4619 %! assert (cell2mat (get (hax, "outerposition")), outerpositions, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4620 %! assert (cell2mat (get (hax, "looseinset")), looseinsets, 1e-4);
283422a219a2 Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents: 17192
diff changeset
4621 %! assert (cell2mat (get (hax, "tightinset")), tightinsets, 1e-4);
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4622 %! unwind_protect_cleanup
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4623 %! close (hf);
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4624 %! end_unwind_protect
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4625 %!testif HAVE_FLTK
17222
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4626 %! hf = figure ("visible", "off");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4627 %! graphics_toolkit (hf, "fltk");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4628 %! fpos = get (hf, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4629 %! unwind_protect
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4630 %! plot (rand (3))
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4631 %! position = get (gca, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4632 %! outerposition = get (gca, "outerposition");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4633 %! looseinset = get (gca, "looseinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4634 %! tightinset = get (gca, "tightinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4635 %! set (hf, "position", [fpos(1:2), 2*fpos(3:4)])
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4636 %! set (hf, "position", fpos);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4637 %! assert (get (gca, "outerposition"), outerposition, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4638 %! assert (get (gca, "position"), position, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4639 %! assert (get (gca, "looseinset"), looseinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4640 %! assert (get (gca, "tightinset"), tightinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4641 %! unwind_protect_cleanup
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4642 %! close (hf);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4643 %! end_unwind_protect
17286
d5efffe5a789 graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents: 17281
diff changeset
4644 %!testif HAVE_FLTK
17222
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4645 %! hf = figure ("visible", "off");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4646 %! graphics_toolkit (hf, "fltk");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4647 %! fpos = get (hf, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4648 %! set (gca, "activepositionproperty", "position")
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4649 %! unwind_protect
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4650 %! plot (rand (3))
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4651 %! position = get (gca, "position");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4652 %! outerposition = get (gca, "outerposition");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4653 %! looseinset = get (gca, "looseinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4654 %! tightinset = get (gca, "tightinset");
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4655 %! set (hf, "position", [fpos(1:2), 2*fpos(3:4)])
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4656 %! set (hf, "position", fpos);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4657 %! assert (get (gca, "position"), position, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4658 %! assert (get (gca, "outerposition"), outerposition, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4659 %! assert (get (gca, "looseinset"), looseinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4660 %! assert (get (gca, "tightinset"), tightinset, 0.001)
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4661 %! unwind_protect_cleanup
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4662 %! close (hf);
8e196132bbea Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents: 17216
diff changeset
4663 %! end_unwind_protect
17024
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4664 */
c358c6e7416b Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents: 17011
diff changeset
4665
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4666 void
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4667 axes::properties::set_text_child (handle_property& hp,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4668 const std::string& who,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4669 const octave_value& v)
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4670 {
19121
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4671 if (v.is_string ())
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4672 {
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4673 xset (hp.handle_value (), "string", v);
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4674 return;
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4675 }
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4676
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4677 graphics_handle val;
19121
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4678 graphics_object go = gh_manager::get_object (gh_manager::lookup (v));
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4679
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4680 if (go.isa ("text"))
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4681 val = ::reparent (v, "set", who, __myhandle__, false);
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4682 else
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4683 {
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4684 std::string cname = v.class_name ();
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4685
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4686 error ("set: expecting text graphics object or character string for %s property, found %s",
3e0720bd6bfc Fix setting axes default x/y/zlabel with string values (bug #34755)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19120
diff changeset
4687 who.c_str (), cname.c_str ());
10265
8c583af2cf64 validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
4688 }
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4689
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4690 xset (val, "handlevisibility", "off");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4691
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4692 gh_manager::free (hp.handle_value ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4693
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4694 base_properties::remove_child (hp.handle_value ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4695
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4696 hp = val;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4697
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
4698 adopt (hp.handle_value ());
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4699 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4700
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4701 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4702 axes::properties::set_xlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4703 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4704 set_text_child (xlabel, "xlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4705 xset (xlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4706 xset (xlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4707 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4708 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4709 xset (xlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4710 xset (xlabel.handle_value (), "color", get_xcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4711 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4712 update_xlabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4713 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4714
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4715 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4716 axes::properties::set_ylabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4717 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4718 set_text_child (ylabel, "ylabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4719 xset (ylabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4720 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4721 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4722 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4723 xset (ylabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4724 xset (ylabel.handle_value (), "color", get_ycolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4725 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4726 update_ylabel_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4727 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4728
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4729 void
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4730 axes::properties::set_zlabel (const octave_value& v)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4731 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4732 set_text_child (zlabel, "zlabel", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4733 xset (zlabel.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4734 xset (zlabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4735 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4736 xset (zlabel.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4737 xset (zlabel.handle_value (), "clipping", "off");
11598
62b7ea59a6ff fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents: 11586
diff changeset
4738 xset (zlabel.handle_value (), "color", get_zcolor ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4739 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4740 update_zlabel_position ();
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4741 }
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4742
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4743 void
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4744 axes::properties::set_title (const octave_value& v)
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4745 {
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4746 set_text_child (title, "title", v);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4747 xset (title.handle_value (), "positionmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4748 xset (title.handle_value (), "horizontalalignment", "center");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4749 xset (title.handle_value (), "horizontalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4750 xset (title.handle_value (), "verticalalignment", "bottom");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4751 xset (title.handle_value (), "verticalalignmentmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4752 xset (title.handle_value (), "clipping", "off");
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4753 xset (title.handle_value (), "autopos_tag", "title");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
4754 update_title_position ();
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4755 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4756
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4757 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4758 axes::properties::set_defaults (base_graphics_object& bgo,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4759 const std::string& mode)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4760 {
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4761 box = "on";
6962
9ac23c7f1c37 [project @ 2007-10-05 20:52:19 by jwe]
jwe
parents: 6945
diff changeset
4762 colororder = default_colororder ();
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4763 // Note: dataspectratio will be set through update_aspectratios
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4764 dataaspectratiomode = "auto";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4765 layer = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4766
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4767 Matrix tlim (1, 2, 0.0);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4768 tlim(1) = 1;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4769 alim = tlim;
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4770 xlim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4771 ylim = tlim;
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4772 zlim = tlim;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4773
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4774 Matrix cl (1, 2, 0.0);
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4775 cl(1) = 1;
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
4776 clim = cl;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4777
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4778 xlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4779 ylimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4780 zlimmode = "auto";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4781 climmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4782 alimmode = "auto";
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4783
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4784 xgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4785 ygrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4786 zgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4787 xminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4788 yminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4789 zminorgrid = "off";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4790 xtick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4791 ytick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4792 ztick = Matrix ();
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4793 xtickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4794 ytickmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4795 ztickmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4796 xminortick = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4797 yminortick = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4798 zminortick = "off";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4799 xticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4800 yticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4801 zticklabel = "";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4802 xticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4803 yticklabelmode = "auto";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4804 zticklabelmode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4805
20320
6db2ea5556a4 Make use of the axes "ticklabelinterpreter" property (bug #45438)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20307
diff changeset
4806 ticklabelinterpreter = "tex";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4807
14798
fce841c941a5 The color property for new plot axes should take on the default value.
Ben Abbott <bpabbott@mac.com>
parents: 14691
diff changeset
4808 color = color_values ("white");
7364
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4809 xcolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4810 ycolor = color_values ("black");
0e07f78369d1 [project @ 2008-01-12 08:38:17 by jwe]
jwe
parents: 7363
diff changeset
4811 zcolor = color_values ("black");
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4812 xscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4813 yscale = "linear";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4814 zscale = "linear";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4815 xdir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4816 ydir = "normal";
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4817 zdir = "normal";
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4818 yaxislocation = "left";
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4819 xaxislocation = "bottom";
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4820
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4821 Matrix tview (1, 2, 0.0);
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4822 tview(1) = 90;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4823 view = tview;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4824
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4825 __hold_all__ = "off";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4826 nextplot = "replace";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4827
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4828 ambientlightcolor = Matrix (1, 3, 1.0);
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4829
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4830 // Note: camera properties (not mode) will be set in update_transform
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4831 camerapositionmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4832 cameratargetmode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4833 cameraupvectormode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4834 cameraviewanglemode = "auto";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4835
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4836 drawmode = "normal";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4837
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4838 fontangle = "normal";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4839 fontname = OCTAVE_DEFAULT_FONTNAME;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4840 fontsize = 10;
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4841 fontunits = "points";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4842 fontweight = "normal";
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4843
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
4844 gridlinestyle = ":";
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4845 linestyleorder = "-";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4846 linewidth = 0.5;
7820
cb4838d70ab2 Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7680
diff changeset
4847 minorgridlinestyle = ":";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4848
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4849 // Note: plotboxaspectratio will be set through update_aspectratios
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4850 plotboxaspectratiomode = "auto";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4851 projection = "orthographic";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4852
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4853 tickdir = "in";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4854 tickdirmode = "auto";
8740
cb0ea772a4af Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents: 8687
diff changeset
4855 ticklength = default_axes_ticklength ();
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4856
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4857 tightinset = Matrix (1, 4, 0.0);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4858
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4859 sx = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4860 sy = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4861 sz = "linear";
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4862
6765
e6b528a3a2a9 [project @ 2007-06-28 15:25:43 by jwe]
jwe
parents: 6761
diff changeset
4863 visible = "on";
17081
86067af51d5e Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents: 17024
diff changeset
4864
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4865 // Replace/Reset preserves Position and Units properties
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4866 if (mode != "replace" && mode != "reset")
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4867 {
16832
e528beb2d774 Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents: 16831
diff changeset
4868 outerposition = default_axes_outerposition ();
7860
67edbcb19665 rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7859
diff changeset
4869 position = default_axes_position ();
8228
53dbbd331498 Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents: 8209
diff changeset
4870 activepositionproperty = "outerposition";
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4871 }
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
4872
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4873 if (mode != "reset")
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4874 {
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4875 delete_children (true);
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4876
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4877 xlabel.invalidate ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4878 ylabel.invalidate ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4879 zlabel.invalidate ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4880 title.invalidate ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4881
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4882 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__,
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4883 false, false, false);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4884 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__,
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4885 false, false, false);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4886 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__,
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4887 false, false, false);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4888 title = gh_manager::make_graphics_handle ("text", __myhandle__,
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4889 false, false, false);
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4890
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4891 adopt (xlabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4892 adopt (ylabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4893 adopt (zlabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4894 adopt (title.handle_value ());
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4895
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4896 update_xlabel_position ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4897 update_ylabel_position ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4898 update_zlabel_position ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
4899 update_title_position ();
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4900 }
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4901 else
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4902 {
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4903 graphics_object go = gh_manager::get_object (xlabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4904 go.reset_default_properties ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4905 go = gh_manager::get_object (ylabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4906 go.reset_default_properties ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4907 go = gh_manager::get_object (zlabel.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4908 go.reset_default_properties ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4909 go = gh_manager::get_object (title.handle_value ());
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4910 go.reset_default_properties ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
4911 }
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4912
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4913 xset (xlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4914 xset (ylabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4915 xset (zlabel.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4916 xset (title.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4917
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4918 xset (xlabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4919 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4920 xset (ylabel.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4921 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4922 xset (zlabel.handle_value (), "horizontalalignment", "right");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4923 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4924 xset (title.handle_value (), "horizontalalignment", "center");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4925 xset (title.handle_value (), "horizontalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4926
16204
92f8bfae9b13 Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents: 16201
diff changeset
4927 xset (xlabel.handle_value (), "verticalalignment", "top");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4928 xset (xlabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4929 xset (ylabel.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4930 xset (ylabel.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4931 xset (title.handle_value (), "verticalalignment", "bottom");
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4932 xset (title.handle_value (), "verticalalignmentmode", "auto");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4933
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4934 xset (ylabel.handle_value (), "rotation", 90.0);
11385
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4935 xset (ylabel.handle_value (), "rotationmode", "auto");
71e7467fbd34 Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11384
diff changeset
4936
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4937 xset (zlabel.handle_value (), "visible", "off");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
4938
9403
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4939 xset (xlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4940 xset (ylabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4941 xset (zlabel.handle_value (), "clipping", "off");
4af6e29449c1 [mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9396
diff changeset
4942 xset (title.handle_value (), "clipping", "off");
8636
ee70d438a5b4 [mq]: grfx
John W. Eaton <jwe@octave.org>
parents: 8599
diff changeset
4943
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4944 xset (xlabel.handle_value (), "autopos_tag", "xlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4945 xset (ylabel.handle_value (), "autopos_tag", "ylabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4946 xset (zlabel.handle_value (), "autopos_tag", "zlabel");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4947 xset (title.handle_value (), "autopos_tag", "title");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
4948
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
4949 update_transform ();
17011
350cad34b0f8 Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents: 16971
diff changeset
4950 sync_positions ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
4951 override_defaults (bgo);
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4952 }
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4953
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4954 void
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4955 axes::properties::delete_text_child (handle_property& hp)
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents: 6845
diff changeset
4956 {
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4957 graphics_handle h = hp.handle_value ();
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4958
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4959 if (h.ok ())
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4960 {
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4961 graphics_object go = gh_manager::get_object (h);
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4962
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4963 if (go.valid_object ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
4964 gh_manager::free (h);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4965
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4966 base_properties::remove_child (h);
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4967 }
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4968
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
4969 // FIXME: is it necessary to check whether the axes object is
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4970 // being deleted now? I think this function is only called when an
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4971 // individual child object is delete and not when the parent axes
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4972 // object is deleted.
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4973
8208
f6ca8ff51818 [mq]: graphics-backend
John W. Eaton <jwe@octave.org>
parents: 8196
diff changeset
4974 if (! is_beingdeleted ())
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4975 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4976 hp = gh_manager::make_graphics_handle ("text", __myhandle__,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
4977 false, false);
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4978
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4979 xset (hp.handle_value (), "handlevisibility", "off");
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4980
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4981 adopt (hp.handle_value ());
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4982 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4983 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
4984
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4985 void
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
4986 axes::properties::remove_child (const graphics_handle& h)
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
4987 {
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
4988 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ())
18925
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4989 {
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4990 delete_text_child (xlabel);
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4991 update_xlabel_position ();
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4992 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4993 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ())
18925
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4994 {
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4995 delete_text_child (ylabel);
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4996 update_ylabel_position ();
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4997 }
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
4998 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ())
18925
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
4999 {
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5000 delete_text_child (zlabel);
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5001 update_zlabel_position ();
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5002 }
8249
1f429086565c [mq]: hidden-children
John W. Eaton <jwe@octave.org>
parents: 8234
diff changeset
5003 else if (title.handle_value ().ok () && h == title.handle_value ())
18925
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5004 {
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5005 delete_text_child (title);
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5006 update_title_position ();
284f7fa221e9 Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18815
diff changeset
5007 }
6705
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
5008 else
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
5009 base_properties::remove_child (h);
0ee6bda23b87 [project @ 2007-06-13 05:42:24 by jwe]
jwe
parents: 6684
diff changeset
5010 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
5011
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5012 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5013 xform_matrix (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5014 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5015 Matrix m (4, 4, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5016
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5017 for (int i = 0; i < 4; i++)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5018 m(i,i) = 1;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5019
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5020 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5021 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5022
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5023 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5024 xform_vector (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5025 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5026 ColumnVector v (4, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5027
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5028 v(3) = 1;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5029
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5030 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5031 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5032
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5033 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5034 xform_vector (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5035 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5036 ColumnVector v (4, 1.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5037
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5038 v(0) = x;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5039 v(1) = y;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5040 v(2) = z;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5041
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5042 return v;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5043 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5044
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5045 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5046 transform (const Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5047 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5048 return (m * xform_vector (x, y, z));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5049 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5050
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5051 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5052 xform_scale (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5053 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5054 Matrix m (4, 4, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5055
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5056 m(0,0) = x;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5057 m(1,1) = y;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5058 m(2,2) = z;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5059 m(3,3) = 1;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5060
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5061 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5062 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5063
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5064 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5065 xform_translate (double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5066 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5067 Matrix m = xform_matrix ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5068
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5069 m(0,3) = x;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5070 m(1,3) = y;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5071 m(2,3) = z;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5072 m(3,3) = 1;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5073
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5074 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5075 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5076
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5077 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5078 scale (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5079 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5080 m = m * xform_scale (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5081 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5082
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5083 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5084 translate (Matrix& m, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5085 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5086 m = m * xform_translate (x, y, z);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5087 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5088
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5089 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5090 xform (ColumnVector& v, const Matrix& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5091 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5092 v = m * v;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5093 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5094
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5095 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5096 scale (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5097 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5098 v(0) *= x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5099 v(1) *= y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5100 v(2) *= z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5101 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5102
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5103 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5104 translate (ColumnVector& v, double x, double y, double z)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5105 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5106 v(0) += x;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5107 v(1) += y;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5108 v(2) += z;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5109 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5110
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5111 inline void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5112 normalize (ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5113 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5114 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5115 scale (v, fact, fact, fact);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5116 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5117
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5118 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5119 dot (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5120 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5121 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5122 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5123
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5124 inline double
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5125 norm (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5126 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5127 return sqrt (dot (v, v));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5128 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5129
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5130 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5131 cross (const ColumnVector& v1, const ColumnVector& v2)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5132 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5133 ColumnVector r = xform_vector ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5134
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5135 r(0) = v1(1)*v2(2) - v1(2)*v2(1);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5136 r(1) = v1(2)*v2(0) - v1(0)*v2(2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5137 r(2) = v1(0)*v2(1) - v1(1)*v2(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5138
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5139 return r;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5140 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5141
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5142 inline Matrix
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5143 unit_cube (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5144 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5145 static double data[32] =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5146 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5147 0,0,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5148 1,0,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5149 0,1,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5150 0,0,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5151 1,1,0,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5152 1,0,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5153 0,1,1,1,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5154 1,1,1,1
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5155 };
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5156 Matrix m (4, 8);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5157
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5158 memcpy (m.fortran_vec (), data, sizeof (double)*32);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5159
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5160 return m;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5161 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5162
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5163 inline ColumnVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5164 cam2xform (const Array<double>& m)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5165 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5166 ColumnVector retval (4, 1.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5167
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5168 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5169
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5170 return retval;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5171 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5172
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5173 inline RowVector
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5174 xform2cam (const ColumnVector& v)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5175 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5176 return v.extract_n (0, 3).transpose ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5177 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5178
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5179 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5180 axes::properties::update_camera (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5181 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5182 double xd = (xdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5183 double yd = (ydir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5184 double zd = (zdir_is ("normal") ? 1 : -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5185
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5186 Matrix xlimits = sx.scale (get_xlim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5187 Matrix ylimits = sy.scale (get_ylim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5188 Matrix zlimits = sz.scale (get_zlim ().matrix_value ());
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5189
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5190 double xo = xlimits(xd > 0 ? 0 : 1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5191 double yo = ylimits(yd > 0 ? 0 : 1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5192 double zo = zlimits(zd > 0 ? 0 : 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5193
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
5194 Matrix pb = get_plotboxaspectratio ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5195
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5196 bool autocam = (camerapositionmode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5197 && cameratargetmode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5198 && cameraupvectormode_is ("auto")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5199 && cameraviewanglemode_is ("auto"));
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5200 bool dowarp = (autocam && dataaspectratiomode_is ("auto")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5201 && plotboxaspectratiomode_is ("auto"));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5202
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5203 ColumnVector c_eye (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5204 ColumnVector c_center (xform_vector ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5205 ColumnVector c_upv (xform_vector ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5206
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5207 if (cameratargetmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5208 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5209 c_center(0) = (xlimits(0) + xlimits(1)) / 2;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5210 c_center(1) = (ylimits(0) + ylimits(1)) / 2;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5211 c_center(2) = (zlimits(0) + zlimits(1)) / 2;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5212
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5213 cameratarget = xform2cam (c_center);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5214 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5215 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5216 c_center = cam2xform (get_cameratarget ().matrix_value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5217
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5218 if (camerapositionmode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5219 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5220 Matrix tview = get_view ().matrix_value ();
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5221 double az = tview(0);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5222 double el = tview(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5223 double d = 5 * sqrt (pb(0)*pb(0) + pb(1)*pb(1) + pb(2)*pb(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5224
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5225 if (el == 90 || el == -90)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5226 c_eye(2) = d*signum (el);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5227 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5228 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5229 az *= M_PI/180.0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5230 el *= M_PI/180.0;
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5231 c_eye(0) = d * cos (el) * sin (az);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5232 c_eye(1) = -d* cos (el) * cos (az);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5233 c_eye(2) = d * sin (el);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5234 }
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5235 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5236 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1);
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5237 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5238
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5239 cameraposition = xform2cam (c_eye);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5240 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5241 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5242 c_eye = cam2xform (get_cameraposition ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5243
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5244 if (cameraupvectormode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5245 {
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5246 Matrix tview = get_view ().matrix_value ();
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5247 double az = tview(0);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5248 double el = tview(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5249
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5250 if (el == 90 || el == -90)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5251 {
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5252 c_upv(0) =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5253 -signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0);
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
5254 c_upv(1) =
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5255 signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5256 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5257 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5258 c_upv(2) = 1;
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5259
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5260 cameraupvector = xform2cam (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5261 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5262 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5263 c_upv = cam2xform (get_cameraupvector ().matrix_value ());
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5264
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5265 Matrix x_view = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5266 Matrix x_projection = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5267 Matrix x_viewport = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5268 Matrix x_normrender = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5269 Matrix x_pre = xform_matrix ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5270
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5271 x_render = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5272 x_render_inv = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5273
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5274 scale (x_pre, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5275 translate (x_pre, -0.5, -0.5, -0.5);
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5276 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5277 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5278 translate (x_pre, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5279
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5280 xform (c_eye, x_pre);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5281 xform (c_center, x_pre);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
5282 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5283 pb(2)/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5284 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5285
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5286 ColumnVector F (c_center), f (F), UP (c_upv);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5287 normalize (f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5288 normalize (UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5289
7440
4e3b073e910e [project @ 2008-02-02 18:23:50 by jwe]
jwe
parents: 7435
diff changeset
5290 if (std::abs (dot (f, UP)) > 1e-15)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5291 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5292 double fa = 1 / sqrt (1 - f(2)*f(2));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5293 scale (UP, fa, fa, fa);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5294 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5295
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5296 ColumnVector s = cross (f, UP);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5297 ColumnVector u = cross (s, f);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5298
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5299 scale (x_view, 1, 1, -1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5300 Matrix l = xform_matrix ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5301 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5302 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5303 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5304 x_view = x_view * l;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5305 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5306 scale (x_view, pb(0), pb(1), pb(2));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5307 translate (x_view, -0.5, -0.5, -0.5);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5308
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5309 Matrix x_cube = x_view * unit_cube ();
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5310 ColumnVector cmin = x_cube.row_min ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5311 ColumnVector cmax = x_cube.row_max ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5312 double xM = cmax(0) - cmin(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5313 double yM = cmax(1) - cmin(1);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5314
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
5315 Matrix bb = get_boundingbox (true);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5316
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5317 double v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5318
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5319 if (cameraviewanglemode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5320 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5321 double af;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5322
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5323 // FIXME: was this really needed? When compared to Matlab, it
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5324 // does not seem to be required. Need investigation with concrete
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
5325 // graphics toolkit to see results visually.
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5326 if (false && dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5327 af = 1.0 / (xM > yM ? xM : yM);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5328 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5329 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5330 if ((bb(2)/bb(3)) > (xM/yM))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5331 af = 1.0 / yM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5332 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5333 af = 1.0 / xM;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5334 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5335 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F)));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5336
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5337 cameraviewangle = v_angle;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5338 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5339 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5340 v_angle = get_cameraviewangle ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5341
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5342 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F));
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5343 scale (x_projection, pf, pf, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5344
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5345 if (dowarp)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5346 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5347 xM *= pf;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5348 yM *= pf;
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
5349 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5350 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5351 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5352 else
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5353 {
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5354 double pix = 1;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5355 if (autocam)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5356 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5357 if ((bb(2)/bb(3)) > (xM/yM))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5358 pix = bb(3);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5359 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5360 pix = bb(2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5361 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5362 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5363 pix = (bb(2) < bb(3) ? bb(2) : bb(3));
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
5364 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5365 scale (x_viewport, pix, -pix, 1);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5366 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5367
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5368 x_normrender = x_viewport * x_projection * x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5369
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5370 x_cube = x_normrender * unit_cube ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5371 cmin = x_cube.row_min ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5372 cmax = x_cube.row_max ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5373 x_zlim.resize (1, 2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5374 x_zlim(0) = cmin(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5375 x_zlim(1) = cmax(2);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5376
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5377 x_render = x_normrender;
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5378 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5379 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5380 translate (x_render, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5381
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5382 x_viewtransform = x_view;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5383 x_projectiontransform = x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5384 x_viewporttransform = x_viewport;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5385 x_normrendertransform = x_normrender;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5386 x_rendertransform = x_render;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5387
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5388 x_render_inv = x_render.inverse ();
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5389
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5390 // Note: these matrices are a slight modified version of the regular matrices,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5391 // more suited for OpenGL rendering (x_gl_mat1 => light => x_gl_mat2)
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5392 x_gl_mat1 = x_view;
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
5393 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
5394 zd/(zlimits(1)-zlimits(0)));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5395 translate (x_gl_mat1, -xo, -yo, -zo);
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5396 x_gl_mat2 = x_viewport * x_projection;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5397 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
5398
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5399 static bool updating_axes_layout = false;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5400
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5401 void
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5402 axes::properties::update_axes_layout (void)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5403 {
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5404 if (updating_axes_layout)
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5405 return;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5406
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5407 graphics_xform xform = get_transform ();
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5408
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5409 double xd = (xdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5410 double yd = (ydir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5411 double zd = (zdir_is ("normal") ? 1 : -1);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5412
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5413 const Matrix xlims = xform.xscale (get_xlim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5414 const Matrix ylims = xform.yscale (get_ylim ().matrix_value ());
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5415 const Matrix zlims = xform.zscale (get_zlim ().matrix_value ());
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5416
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5417 double x_min, x_max, y_min, y_max, z_min, z_max;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5418 x_min = xlims(0), x_max = xlims(1);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5419 y_min = ylims(0), y_max = ylims(1);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5420 z_min = zlims(0), z_max = zlims(1);
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5421
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5422 ColumnVector p1, p2, dir (3);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5423
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5424 xstate = ystate = zstate = AXE_ANY_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5425
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5426 p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5427 p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5428 dir(0) = xround (p2(0) - p1(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5429 dir(1) = xround (p2(1) - p1(1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5430 dir(2) = (p2(2) - p1(2));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5431 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5432 xstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5433 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5434 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5435 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5436 xstate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5437 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5438 xstate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5439 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5440
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5441 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5442 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5443 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5444 xPlane = (dir(0) > 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5445 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5446 xPlane = (dir(1) < 0 ? x_max : x_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5447 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5448 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5449 xPlane = (dir(2) < 0 ? x_min : x_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5450
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5451 xPlaneN = (xPlane == x_min ? x_max : x_min);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5452 fx = (x_max - x_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5453
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5454 p1 = xform.transform ((x_min + x_max)/2, y_min, (z_min + z_max)/2, false);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5455 p2 = xform.transform ((x_min + x_max)/2, y_max, (z_min + z_max)/2, false);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5456 dir(0) = xround (p2(0) - p1(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5457 dir(1) = xround (p2(1) - p1(1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5458 dir(2) = (p2(2) - p1(2));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5459 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5460 ystate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5461 else if (dir(2) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5462 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5463 if (dir(0) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5464 ystate = AXE_VERT_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5465 else if (dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5466 ystate = AXE_HORZ_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5467 }
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5468
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5469 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5470 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5471 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5472 yPlane = (dir(0) > 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5473 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5474 yPlane = (dir(1) < 0 ? y_max : y_min);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5475 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5476 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5477 yPlane = (dir(2) < 0 ? y_min : y_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5478
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5479 yPlaneN = (yPlane == y_min ? y_max : y_min);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5480 fy = (y_max - y_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5481
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5482 p1 = xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_min, false);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5483 p2 = xform.transform ((x_min + x_max)/2, (y_min + y_max)/2, z_max, false);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5484 dir(0) = xround (p2(0) - p1(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5485 dir(1) = xround (p2(1) - p1(1));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5486 dir(2) = (p2(2) - p1(2));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5487 if (dir(0) == 0 && dir(1) == 0)
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5488 zstate = AXE_DEPTH_DIR;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5489 else if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5490 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5491 if (dir(0) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5492 zstate = AXE_VERT_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5493 else if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5494 zstate = AXE_HORZ_DIR;
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5495 }
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5496
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5497 if (dir(2) == 0)
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5498 {
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5499 if (dir(1) == 0)
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5500 zPlane = (dir(0) > 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5501 else
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5502 zPlane = (dir(1) < 0 ? z_min : z_max);
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5503 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5504 else
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5505 zPlane = (dir(2) < 0 ? z_min : z_max);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5506
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5507 zPlaneN = (zPlane == z_min ? z_max : z_min);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5508 fz = (z_max - z_min) / sqrt (dir(0)*dir(0) + dir(1)*dir(1));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5509
12347
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5510 unwind_protect frame;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5511 frame.protect_var (updating_axes_layout);
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5512 updating_axes_layout = true;
f6763ab98609 Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents: 12334
diff changeset
5513
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5514 xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5515 zSign = (zd*(zPlane-zPlaneN) <= 0);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5516 xyzSym = zSign ? xySym : !xySym;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5517 xpTick = (zSign ? xPlaneN : xPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5518 ypTick = (zSign ? yPlaneN : yPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5519 zpTick = (zSign ? zPlane : zPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5520 xpTickN = (zSign ? xPlane : xPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5521 ypTickN = (zSign ? yPlane : yPlaneN);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5522 zpTickN = (zSign ? zPlaneN : zPlane);
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5523
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5524 /* 2D mode */
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5525 x2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5526 y2Dright = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5527 layer2Dtop = false;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5528 if (xstate == AXE_HORZ_DIR && ystate == AXE_VERT_DIR)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5529 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5530 if (xaxislocation_is ("top"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5531 {
18711
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18701
diff changeset
5532 std::swap (yPlane, yPlaneN);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5533 x2Dtop = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5534 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5535 ypTick = yPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5536 ypTickN = yPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5537 if (yaxislocation_is ("right"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5538 {
18711
f684f7075aee Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents: 18701
diff changeset
5539 std::swap (xPlane, xPlaneN);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5540 y2Dright = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5541 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5542 xpTick = xPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5543 xpTickN = xPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5544 if (layer_is ("top"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5545 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5546 zpTick = zPlaneN;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5547 layer2Dtop = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5548 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5549 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5550 zpTick = zPlane;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5551 }
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5552
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5553 Matrix viewmat = get_view ().matrix_value ();
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
5554 nearhoriz = std::abs (viewmat(1)) <= 5;
18701
e42843ceff48 Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents: 18680
diff changeset
5555 is2D = viewmat(1) == 90;
13830
462b5f556346 avoid uninitialized variable warning from valgrind
John W. Eaton <jwe@octave.org>
parents: 13816
diff changeset
5556
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5557 update_ticklength ();
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5558 }
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5559
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5560 void
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5561 axes::properties::update_ticklength (void)
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5562 {
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5563 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5564 (ystate > AXE_DEPTH_DIR ? 1 : 0) +
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5565 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2);
14395
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5566
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5567 if (tickdirmode_is ("auto"))
14395
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5568 tickdir.set (mode2d ? "in" : "out", true);
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5569
e41e538e9d03 Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents: 14391
diff changeset
5570 double ticksign = (tickdir_is ("in") ? -1 : 1);
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5571
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5572 Matrix bbox = get_boundingbox (true);
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5573 Matrix ticklen = get_ticklength ().matrix_value ();
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5574 ticklen(0) *= std::max (bbox(2), bbox(3));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5575 ticklen(1) *= std::max (bbox(2), bbox(3));
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5576
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5577 xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5578 yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5579 zticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5580
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5581 xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5582 ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5;
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
5583 ztickoffset = (mode2d ? std::max (0., zticklen) : std::abs (zticklen)) + 5;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5584
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5585 update_xlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5586 update_ylabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5587 update_zlabel_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5588 update_title_position ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5589 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5590
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5591 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5592 ## FIXME: A demo can't be called in a C++ file. This should be made a test
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5593 ## or moved to a .m file where it can be called.
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5594 %!demo
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5595 %! clf;
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5596 %! subplot (2,1,1);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5597 %! plot (rand (3));
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5598 %! xlabel xlabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5599 %! ylabel ylabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5600 %! title title;
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
5601 %! subplot (2,1,2);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5602 %! plot (rand (3));
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5603 %! set (gca, "ticklength", get (gca, "ticklength") * 2, "tickdir", "out");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5604 %! xlabel xlabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5605 %! ylabel ylabel;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
5606 %! title title;
14391
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5607 */
c9ec21bef97a Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents: 14367
diff changeset
5608
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5609 static ColumnVector
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5610 convert_label_position (const ColumnVector& p,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5611 const text::properties& props,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5612 const graphics_xform& xform,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5613 const Matrix& bbox)
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5614 {
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5615 ColumnVector retval;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5616
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5617 caseless_str to_units = props.get_units ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5618
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5619 if (! to_units.compare ("data"))
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5620 {
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5621 ColumnVector v = xform.transform (p(0), p(1), p(2));
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5622
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5623 retval.resize (3);
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5624
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5625 retval(0) = v(0) - bbox(0) + 1;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5626 retval(1) = bbox(1) + bbox(3) - v(1) + 1;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5627 retval(2) = 0;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5628
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5629 retval = convert_position (retval, "pixels", to_units,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5630 bbox.extract_n (0, 2, 1, 2));
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5631 }
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5632 else
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5633 retval = p;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5634
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5635 return retval;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5636 }
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5637
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5638 static bool updating_xlabel_position = false;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5639
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5640 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5641 axes::properties::update_xlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5642 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5643 if (updating_xlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5644 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5645
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5646 graphics_object go = gh_manager::get_object (get_xlabel ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5647
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5648 if (! go.valid_object ())
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5649 return;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5650
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5651 text::properties& xlabel_props
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5652 = reinterpret_cast<text::properties&> (go.get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5653
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5654 bool is_empty = xlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5655
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5656 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5657 frame.protect_var (updating_xlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5658 updating_xlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5659
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5660 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5661 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5662 if (xlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5663 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5664 xlabel_props.set_horizontalalignment
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5665 (xstate > AXE_DEPTH_DIR ? "center" : (xyzSym ? "left" : "right"));
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5666
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5667 xlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5668 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5669
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5670 if (xlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5671 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5672 xlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5673 (xstate == AXE_VERT_DIR || x2Dtop ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5674
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5675 xlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5676 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5677 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5678
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5679 if (xlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5680 || xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5681 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5682 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5683
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5684 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5685 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5686 get_xticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5687 get_xlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5688
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5689 double wmax = ext(0);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5690 double hmax = ext(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5691 double angle = 0.0;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5692 ColumnVector p =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5693 graphics_xform::xform_vector ((xpTickN + xpTick)/2, ypTick, zpTick);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5694
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5695 bool tick_along_z = nearhoriz || xisinf (fy);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5696 if (tick_along_z)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5697 p(2) += (signum (zpTick - zpTickN) * fz * xtickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5698 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5699 p(1) += (signum (ypTick - ypTickN) * fy * xtickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5700
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5701 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5702
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5703 switch (xstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5704 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5705 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5706 p(0) += (xyzSym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5707 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5708 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5709
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5710 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5711 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5712 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5713 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5714
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5715 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5716 p(1) += (x2Dtop ? -hmax : hmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5717 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5718 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5719
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5720 if (xlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5721 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5722 p = xform.untransform (p(0), p(1), p(2), true);
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5723
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5724 p = convert_label_position (p, xlabel_props, xform,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5725 get_extent (false));
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5726
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5727 xlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5728 xlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5729 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5730
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5731 if (! is_empty && xlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5732 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5733 xlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5734 xlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5735 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5736 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5737 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5738
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5739 static bool updating_ylabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5740
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5741 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5742 axes::properties::update_ylabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5743 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5744 if (updating_ylabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5745 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5746
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5747 graphics_object go = gh_manager::get_object (get_ylabel ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5748
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5749 if (! go.valid_object ())
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5750 return;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5751
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5752 text::properties& ylabel_props
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5753 = reinterpret_cast<text::properties&> (go.get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5754
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5755 bool is_empty = ylabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5756
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5757 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5758 frame.protect_var (updating_ylabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5759 updating_ylabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5760
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5761 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5762 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5763 if (ylabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5764 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5765 ylabel_props.set_horizontalalignment
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5766 (ystate > AXE_DEPTH_DIR ? "center" : (!xyzSym ? "left" : "right"));
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5767
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5768 ylabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5769 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5770
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5771 if (ylabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5772 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5773 ylabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5774 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5775
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5776 ylabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5777 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5778 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5779
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5780 if (ylabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5781 || ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5782 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5783 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5784
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5785 Matrix ext (1, 2, 0.0);
16201
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5786
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5787 // The underlying get_extents() from FreeType produces mismatched values.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5788 // x-extent accurately measures the width of the glyphs.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5789 // y-extent instead measures from baseline-to-baseline.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5790 // Pad x-extent (+4) so that it approximately matches y-extent.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5791 // This keeps ylabels about the same distance from y-axis as
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5792 // xlabels are from x-axis.
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5793 // ALWAYS use an even number for padding or horizontal alignment
2338a92e9782 Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents: 15760
diff changeset
5794 // will be off.
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5795 ext = get_ticklabel_extents (get_ytick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5796 get_yticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5797 get_ylim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5798
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5799 double wmax = ext(0)+4;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5800 double hmax = ext(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5801 double angle = 0.0;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5802 ColumnVector p =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5803 graphics_xform::xform_vector (xpTick, (ypTickN + ypTick)/2, zpTick);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5804
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5805 bool tick_along_z = nearhoriz || xisinf (fx);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5806 if (tick_along_z)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5807 p(2) += (signum (zpTick - zpTickN) * fz * ytickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5808 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5809 p(0) += (signum (xpTick - xpTickN) * fx * ytickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5810
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5811 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5812
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5813 switch (ystate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5814 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5815 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5816 p(0) += (!xyzSym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5817 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5818 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5819
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5820 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5821 p(0) += (y2Dright ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5822 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5823 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5824
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5825 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5826 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5827 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5828 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5829
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5830 if (ylabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5831 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5832 p = xform.untransform (p(0), p(1), p(2), true);
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5833
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5834 p = convert_label_position (p, ylabel_props, xform,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5835 get_extent (false));
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5836
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5837 ylabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5838 ylabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5839 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5840
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5841 if (! is_empty && ylabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5842 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5843 ylabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5844 ylabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5845 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5846 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5847 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5848
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5849 static bool updating_zlabel_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5850
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5851 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5852 axes::properties::update_zlabel_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5853 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5854 if (updating_zlabel_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5855 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5856
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5857 graphics_object go = gh_manager::get_object (get_zlabel ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5858
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5859 if (! go.valid_object ())
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5860 return;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5861
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5862 text::properties& zlabel_props
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5863 = reinterpret_cast<text::properties&> (go.get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5864
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5865 bool camAuto = cameraupvectormode_is ("auto");
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
5866 bool is_empty = zlabel_props.get_string ().is_empty ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5867
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5868 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5869 frame.protect_var (updating_zlabel_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5870 updating_zlabel_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5871
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5872 if (! is_empty)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5873 {
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5874 if (zlabel_props.horizontalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5875 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5876 zlabel_props.set_horizontalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5877 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5878
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5879 zlabel_props.set_horizontalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5880 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5881
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5882 if (zlabel_props.verticalalignmentmode_is ("auto"))
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5883 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5884 zlabel_props.set_verticalalignment
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5885 (zstate == AXE_VERT_DIR
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5886 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top"));
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5887
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5888 zlabel_props.set_verticalalignmentmode ("auto");
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
5889 }
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5890 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5891
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5892 if (zlabel_props.positionmode_is ("auto")
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5893 || zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5894 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5895 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5896
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5897 Matrix ext (1, 2, 0.0);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5898 ext = get_ticklabel_extents (get_ztick ().matrix_value (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5899 get_zticklabel ().all_strings (),
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5900 get_zlim ().matrix_value ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5901
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5902 double wmax = ext(0);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
5903 double hmax = ext(1);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5904 double angle = 0.0;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5905 ColumnVector p;
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5906
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5907 if (xySym)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5908 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5909 p = graphics_xform::xform_vector (xPlaneN, yPlane,
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5910 (zpTickN + zpTick)/2);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5911 if (xisinf (fy))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5912 p(0) += (signum (xPlaneN - xPlane) * fx * ztickoffset);
12348
d1e48a4a9a0b Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents: 12347
diff changeset
5913 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5914 p(1) += (signum (yPlane - yPlaneN) * fy * ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5915 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5916 else
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5917 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5918 p = graphics_xform::xform_vector (xPlane, yPlaneN,
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5919 (zpTickN + zpTick)/2);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5920 if (xisinf (fx))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5921 p(1) += (signum (yPlaneN - yPlane) * fy * ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5922 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5923 p(0) += (signum (xPlane - xPlaneN) * fx * ztickoffset);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5924 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5925
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5926 p = xform.transform (p(0), p(1), p(2), false);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5927
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5928 switch (zstate)
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5929 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5930 case AXE_ANY_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5931 if (camAuto)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5932 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5933 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5934 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5935 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5936
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5937 // FIXME: what's the correct offset?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5938 //
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5939 // p[0] += (!xySym ? wmax : -wmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5940 // p[1] += (zSign ? hmax : -hmax);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5941
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5942 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5943
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5944 case AXE_VERT_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5945 p(0) -= wmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5946 angle = 90;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5947 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5948
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5949 case AXE_HORZ_DIR:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5950 p(1) += hmax;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5951 break;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5952 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5953
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5954 if (zlabel_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5955 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5956 p = xform.untransform (p(0), p(1), p(2), true);
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5957
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5958 p = convert_label_position (p, zlabel_props, xform,
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5959 get_extent (false));
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5960
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5961 zlabel_props.set_position (p.extract_n (0, 3).transpose ());
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5962 zlabel_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5963 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5964
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5965 if (! is_empty && zlabel_props.rotationmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5966 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5967 zlabel_props.set_rotation (angle);
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5968 zlabel_props.set_rotationmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5969 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5970 }
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5971 }
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5972
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5973 static bool updating_title_position = false;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5974
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5975 void
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5976 axes::properties::update_title_position (void)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5977 {
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5978 if (updating_title_position)
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5979 return;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5980
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5981 graphics_object go = gh_manager::get_object (get_title ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5982
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5983 if (! go.valid_object ())
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5984 return;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
5985
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
5986 text::properties& title_props
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
5987 = reinterpret_cast<text::properties&> (go.get_properties ());
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
5988
12910
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5989 unwind_protect frame;
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5990 frame.protect_var (updating_title_position);
e77284b6dac6 avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12777
diff changeset
5991 updating_title_position = true;
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5992
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5993 if (title_props.positionmode_is ("auto"))
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5994 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5995 graphics_xform xform = get_transform ();
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5996
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5997 // FIXME: bbox should be stored in axes::properties
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
5998 Matrix bbox = get_extent (false);
13910
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
5999
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6000 ColumnVector p =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6001 graphics_xform::xform_vector (bbox(0) + bbox(2)/2,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6002 bbox(1) - 10,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6003 (x_zlim(0) + x_zlim(1))/2);
13910
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6004
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6005 if (x2Dtop)
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6006 {
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6007 Matrix ext (1, 2, 0.0);
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6008 ext = get_ticklabel_extents (get_xtick ().matrix_value (),
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6009 get_xticklabel ().all_strings (),
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6010 get_xlim ().matrix_value ());
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6011 p(1) -= ext(1);
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6012 }
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6013
2af665333b86 title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents: 13908
diff changeset
6014 p = xform.untransform (p(0), p(1), p(2), true);
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6015
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
6016 p = convert_label_position (p, title_props, xform, bbox);
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
6017
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
6018 title_props.set_position (p.extract_n (0, 3).transpose ());
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6019 title_props.set_positionmode ("auto");
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6020 }
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6021 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6022
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6023 void
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6024 axes::properties::update_autopos (const std::string& elem_type)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6025 {
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6026 if (elem_type == "xlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6027 update_xlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6028 else if (elem_type == "ylabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6029 update_ylabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6030 else if (elem_type == "zlabel")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6031 update_zlabel_position ();
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6032 else if (elem_type == "title")
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
6033 update_title_position ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6034 else if (elem_type == "sync")
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6035 sync_positions ();
12327
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
6036 }
2ad37783bf01 Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents: 12221
diff changeset
6037
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6038 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6039 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6040 double xlength, double ylength, double zlength)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6041 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6042 double xval = xlength / scalefactors(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6043 double yval = ylength / scalefactors(1);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6044 double zval = zlength / scalefactors(2);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6045
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6046 double minval = xmin (xmin (xval, yval), zval);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6047
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6048 aspectratios(0) = xval / minval;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6049 aspectratios(1) = yval / minval;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6050 aspectratios(2) = zval / minval;
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6051 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6052
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6053 static void
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6054 max_axes_scale (double& s, Matrix& limits, const Matrix& kids,
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6055 double pbfactor, double dafactor, char limit_type, bool tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6056 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6057 if (tight)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6058 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6059 double minval = octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6060 double maxval = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6061 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6062 double max_neg = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6063 get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6064 if (xfinite (minval) && xfinite (maxval))
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6065 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6066 limits(0) = minval;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6067 limits(1) = maxval;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6068 s = xmax (s, (maxval - minval) / (pbfactor * dafactor));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6069 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6070 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6071 else
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6072 s = xmax (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6073 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6074
18761
868dcab453bd Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18746
diff changeset
6075 static std::set<double> updating_aspectratios;
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6076
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6077 void
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6078 axes::properties::update_aspectratios (void)
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6079 {
19900
726df008104d maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19898
diff changeset
6080 if (updating_aspectratios.find (get___myhandle__ ().value ())
726df008104d maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19898
diff changeset
6081 != updating_aspectratios.end ())
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6082 return;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6083
7526
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
6084 Matrix xlimits = get_xlim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
6085 Matrix ylimits = get_ylim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
6086 Matrix zlimits = get_zlim ().matrix_value ();
52d58b0463ed graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents: 7523
diff changeset
6087
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6088 double dx = (xlimits(1) - xlimits(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6089 double dy = (ylimits(1) - ylimits(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6090 double dz = (zlimits(1) - zlimits(0));
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6091
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6092 Matrix da = get_dataaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6093 Matrix pba = get_plotboxaspectratio ().matrix_value ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6094
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6095 if (dataaspectratiomode_is ("auto"))
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6096 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6097 if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6098 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6099 pba = Matrix (1, 3, 1.0);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6100 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6101 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6102
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6103 normalized_aspectratios (da, pba, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6104 dataaspectratio.set (da, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6105 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6106 else if (plotboxaspectratiomode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6107 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6108 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6109 plotboxaspectratio.set (pba, false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6110 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6111 else
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6112 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6113 double s = -octave_Inf;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6114 bool modified_limits = false;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6115 Matrix kids;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6116
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6117 if (xlimmode_is ("auto") && ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6118 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6119 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6120 kids = get_children ();
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6121 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6122 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6123 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', true);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6124 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6125 else if (xlimmode_is ("auto") && ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6126 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6127 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6128 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6129 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6130 else if (ylimmode_is ("auto") && zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6131 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6132 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6133 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6134 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6135 else if (zlimmode_is ("auto") && xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6136 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6137 modified_limits = true;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6138 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', false);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6139 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6140
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6141 if (modified_limits)
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6142 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6143 unwind_protect frame;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6144 frame.protect_var (updating_aspectratios);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6145
18761
868dcab453bd Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18746
diff changeset
6146 updating_aspectratios.insert (get___myhandle__ ().value ());
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6147
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6148 dx = pba(0) * da(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6149 dy = pba(1) * da(1);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6150 dz = pba(2) * da(2);
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6151 if (xisinf (s))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6152 s = 1 / xmin (xmin (dx, dy), dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6153
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6154 if (xlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6155 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6156 dx = s * dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6157 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6158 xlimits(1) = xlimits(0) + dx;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6159 set_xlim (xlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6160 set_xlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6161 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6162
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6163 if (ylimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6164 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6165 dy = s * dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6166 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6167 ylimits(1) = ylimits(0) + dy;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6168 set_ylim (ylimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6169 set_ylimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6170 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6171
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6172 if (zlimmode_is ("auto"))
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6173 {
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6174 dz = s * dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6175 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6176 zlimits(1) = zlimits(0) + dz;
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6177 set_zlim (zlimits);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6178 set_zlimmode ("auto");
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6179 }
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6180 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6181 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6182 {
11167
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6183 normalized_aspectratios (pba, da, dx, dy, dz);
51ac3a08e53c Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents: 11163
diff changeset
6184 plotboxaspectratio.set (pba, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6185 }
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6186 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6187 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6188
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6189 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6190 axes::properties::update_font (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6191 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6192 #ifdef HAVE_FREETYPE
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6193 #ifdef HAVE_FONTCONFIG
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6194 text_renderer.set_font (get ("fontname").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6195 get ("fontweight").string_value (),
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6196 get ("fontangle").string_value (),
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
6197 get ("fontsize_points").double_value ());
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6198 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6199 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6200 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6201
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
6202 // The INTERNAL flag defines whether position or outerposition is used.
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
6203
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6204 Matrix
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6205 axes::properties::get_boundingbox (bool internal,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6206 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6207 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6208 Matrix pos = internal ? get_position ().matrix_value ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6209 : get_outerposition ().matrix_value ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6210 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6211
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6212 if (parent_size.is_empty ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6213 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6214 graphics_object go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6215
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6216 if (go.valid_object ())
17607
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
6217 parent_size =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6218 go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
17607
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
6219 else
07a4597fcbac graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17564
diff changeset
6220 parent_size = default_figure_position ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6221 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6222
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6223 pos = convert_position (pos, get_units (), "pixels", parent_size);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
6224
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6225 pos(0)--;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6226 pos(1)--;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6227 pos(1) = parent_size(1) - pos(1) - pos(3);
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6228
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6229 return pos;
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6230 }
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
6231
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6232 Matrix
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6233 axes::properties::get_extent (bool with_text, bool only_text_height) const
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6234 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6235 graphics_xform xform = get_transform ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6236
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6237 Matrix ext (1, 4, 0.0);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6238 ext(0) = ext(1) = octave_Inf;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6239 ext(2) = ext(3) = -octave_Inf;
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6240 for (int i = 0; i <= 1; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6241 for (int j = 0; j <= 1; j++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6242 for (int k = 0; k <= 1; k++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6243 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6244 ColumnVector p = xform.transform (i ? xPlaneN : xPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6245 j ? yPlaneN : yPlane,
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6246 k ? zPlaneN : zPlane, false);
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6247 ext(0) = std::min (ext(0), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6248 ext(1) = std::min (ext(1), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6249 ext(2) = std::max (ext(2), p(0));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6250 ext(3) = std::max (ext(3), p(1));
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6251 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6252
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6253 if (with_text)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6254 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6255 for (int i = 0; i < 4; i++)
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6256 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6257 graphics_handle htext;
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6258 if (i == 0)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6259 htext = get_title ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6260 else if (i == 1)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6261 htext = get_xlabel ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6262 else if (i == 2)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6263 htext = get_ylabel ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6264 else if (i == 3)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6265 htext = get_zlabel ();
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6266
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6267 text::properties& text_props
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6268 = reinterpret_cast<text::properties&>
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6269 (gh_manager::get_object (htext).get_properties ());
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6270
14483
6a736395ff7d fix wrong axes extents for text elements with custom units (bug #35856)
Konstantinos Poulios <logari81@googlemail.com>
parents: 14457
diff changeset
6271 Matrix text_pos = text_props.get_data_position ();
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6272 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
6273 if (text_props.get_string ().is_empty ())
12502
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6274 {
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6275 ext(0) = std::min (ext(0), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6276 ext(1) = std::min (ext(1), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6277 ext(2) = std::max (ext(2), text_pos(0));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6278 ext(3) = std::max (ext(3), text_pos(1));
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6279 }
13640f7f40bb improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents: 12496
diff changeset
6280 else
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6281 {
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6282 Matrix text_ext = text_props.get_extent_matrix ();
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6283
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6284 bool ignore_horizontal = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6285 bool ignore_vertical = false;
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6286 if (only_text_height)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6287 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
6288 double text_rotation = text_props.get_rotation ();
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6289 if (text_rotation == 0. || text_rotation == 180.)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6290 ignore_horizontal = true;
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6291 else if (text_rotation == 90. || text_rotation == 270.)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6292 ignore_vertical = true;
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6293 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6294
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6295 if (! ignore_horizontal)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6296 {
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6297 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6298 ext(2) = std::max (ext(2),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6299 text_pos(0)+text_ext(0)+text_ext(2));
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6300 }
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6301
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6302 if (! ignore_vertical)
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6303 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6304 ext(1) = std::min (ext(1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6305 text_pos(1)-text_ext(1)-text_ext(3));
12496
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6306 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
245b5efb07c2 fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents: 12483
diff changeset
6307 }
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6308 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6309 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6310 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6311
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6312 ext(2) = ext(2) - ext(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6313 ext(3) = ext(3) - ext(1);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
6314
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6315 return ext;
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6316 }
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
6317
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6318 static octave_value
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6319 convert_ticklabel_string (const octave_value& val)
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6320 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6321 octave_value retval = val;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6322
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6323 if (val.is_cellstr ())
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6324 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6325 // Always return a column vector for Matlab compatibility
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6326 if (val.columns () > 1)
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6327 retval = val.reshape (dim_vector (val.numel (), 1));
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6328 }
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6329 else
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6330 {
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6331 string_vector sv;
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6332 if (val.is_numeric_type ())
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6333 {
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6334 NDArray data = val.array_value ();
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6335 std::ostringstream oss;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6336 oss.precision (5);
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6337 for (octave_idx_type i = 0; i < val.numel (); i++)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6338 {
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6339 oss.str ("");
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6340 oss << data(i);
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6341 sv.append (oss.str ());
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6342 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6343 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6344 else if (val.is_string () && val.rows () == 1)
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6345 {
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6346 std::string valstr = val.string_value ();
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6347 std::istringstream iss (valstr);
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6348 std::string tmpstr;
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6349
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6350 // Split string with delimiter '|'
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6351 while (std::getline (iss, tmpstr, '|'))
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6352 sv.append (tmpstr);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6353
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6354 // If string ends with '|' Matlab appends a null string
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6355 if (*valstr.rbegin () == '|')
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6356 sv.append (std::string (""));
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6357 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6358 else
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6359 return retval;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6360
16854
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6361 charMatrix chmat (sv, ' ');
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6362
563f8f0a7e29 Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents: 16841
diff changeset
6363 retval = octave_value (chmat);
16841
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6364 }
2ce1ddead134 Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents: 16840
diff changeset
6365
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6366 return retval;
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6367 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6368
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6369 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6370 axes::properties::set_xticklabel (const octave_value& val)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6371 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6372 if (xticklabel.set (convert_ticklabel_string (val), false))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6373 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6374 set_xticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6375 xticklabel.run_listeners (POSTSET);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6376 mark_modified ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6377 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6378 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6379 set_xticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6380
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6381 sync_positions ();
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6382 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6383
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6384 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6385 axes::properties::set_yticklabel (const octave_value& val)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6386 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6387 if (yticklabel.set (convert_ticklabel_string (val), false))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6388 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6389 set_yticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6390 yticklabel.run_listeners (POSTSET);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6391 mark_modified ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6392 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6393 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6394 set_yticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6395
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6396 sync_positions ();
16840
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6397 }
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6398
969233a27bce maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents: 16832
diff changeset
6399 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6400 axes::properties::set_zticklabel (const octave_value& val)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6401 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6402 if (zticklabel.set (convert_ticklabel_string (val), false))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6403 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6404 set_zticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6405 zticklabel.run_listeners (POSTSET);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6406 mark_modified ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6407 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6408 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6409 set_zticklabelmode ("manual");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6410
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6411 sync_positions ();
16750
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6412 }
fd5a4b7f59f7 add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents: 16312
diff changeset
6413
17382
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6414 // Almost identical to convert_ticklabel_string but it only accepts
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6415 // cellstr or string, not numeric input.
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6416 static octave_value
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6417 convert_linestyleorder_string (const octave_value& val)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6418 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6419 octave_value retval = val;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6420
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6421 if (val.is_cellstr ())
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6422 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6423 // Always return a column vector for Matlab Compatibility
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6424 if (val.columns () > 1)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6425 retval = val.reshape (dim_vector (val.numel (), 1));
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6426 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6427 else
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6428 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6429 string_vector sv;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6430 if (val.is_string () && val.rows () == 1)
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6431 {
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6432 std::string valstr = val.string_value ();
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6433 std::istringstream iss (valstr);
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6434 std::string tmpstr;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6435
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6436 // Split string with delimiter '|'
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6437 while (std::getline (iss, tmpstr, '|'))
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6438 sv.append (tmpstr);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6439
17382
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6440 // If string ends with '|' Matlab appends a null string
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6441 if (*valstr.rbegin () == '|')
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6442 sv.append (std::string (""));
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6443 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6444 else
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6445 return retval;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6446
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6447 charMatrix chmat (sv, ' ');
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6448
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6449 retval = octave_value (chmat);
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6450 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6451
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6452 return retval;
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6453 }
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6454
50b2863d10a6 Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents: 17319
diff changeset
6455 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6456 axes::properties::set_linestyleorder (const octave_value& val)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6457 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6458 linestyleorder.set (convert_linestyleorder_string (val), false);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6459 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6460
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6461 void
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6462 axes::properties::set_units (const octave_value& val)
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6463 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6464 caseless_str old_units = get_units ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6465
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6466 if (units.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6467 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6468 update_units (old_units);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6469 mark_modified ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6470 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6471 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6472
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6473 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6474 axes::properties::update_units (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6475 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6476 graphics_object parent_go = gh_manager::get_object (get_parent ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6477 Matrix parent_bb
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6478 = parent_go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6479 caseless_str new_units = get_units ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6480 position.set (octave_value (convert_position (get_position ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6481 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6482 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6483 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6484 outerposition.set (octave_value (convert_position (get_outerposition ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6485 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6486 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6487 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6488 tightinset.set (octave_value (convert_position (get_tightinset ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6489 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6490 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6491 false);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6492 looseinset.set (octave_value (convert_position (get_looseinset ().matrix_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6493 old_units, new_units,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6494 parent_bb)),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6495 false);
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6496 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6497
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6498 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6499 axes::properties::set_fontunits (const octave_value& val)
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6500 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6501 caseless_str old_fontunits = get_fontunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6502
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6503 if (fontunits.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6504 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6505 update_fontunits (old_fontunits);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6506 mark_modified ();
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6507 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6508 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6509
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6510 void
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6511 axes::properties::update_fontunits (const caseless_str& old_units)
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6512 {
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6513 caseless_str new_units = get_fontunits ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6514 double parent_height = get_boundingbox (true).elem (3);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6515 double fontsz = get_fontsize ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6516
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6517 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6518
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6519 set_fontsize (octave_value (fontsz));
10991
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6520 }
9d3a7ad94ee6 Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents: 10990
diff changeset
6521
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6522 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6523 axes::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6524 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6525 double fontsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6526 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6527
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6528 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
6529 parent_height = get_boundingbox (true).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6530
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6531 return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6532 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
6533
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6534 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6535 graphics_xform::xform_vector (double x, double y, double z)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6536 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6537 return ::xform_vector (x, y, z);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6538 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6539
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6540 Matrix
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6541 graphics_xform::xform_eye (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6542 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6543 return ::xform_matrix ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6544 }
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6545
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6546 ColumnVector
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6547 graphics_xform::transform (double x, double y, double z, bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6548 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6549 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6550 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6551 x = sx.scale (x);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6552 y = sy.scale (y);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6553 z = sz.scale (z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6554 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6555
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6556 return ::transform (xform, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6557 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6558
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6559 ColumnVector
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6560 graphics_xform::untransform (double x, double y, double z,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6561 bool use_scale) const
7435
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6562 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6563 ColumnVector v = ::transform (xform_inv, x, y, z);
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6564
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6565 if (use_scale)
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6566 {
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6567 v(0) = sx.unscale (v(0));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6568 v(1) = sy.unscale (v(1));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6569 v(2) = sz.unscale (v(2));
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6570 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6571
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6572 return v;
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6573 }
464a55f1a5c2 [project @ 2008-02-01 06:47:48 by jwe]
jwe
parents: 7427
diff changeset
6574
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6575 octave_value
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6576 axes::get_default (const caseless_str& pname) const
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6577 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6578 octave_value retval = default_properties.lookup (pname);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6579
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6580 if (retval.is_undefined ())
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6581 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6582 graphics_handle parent_h = get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6583 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6584
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6585 retval = parent_go.get_default (pname);
6836
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6586 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6587
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6588 return retval;
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6589 }
ea6ae3af82d1 [project @ 2007-08-27 19:50:22 by jwe]
jwe
parents: 6829
diff changeset
6590
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6591 // FIXME: remove.
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6592 // FIXME: maybe this should go into array_property class?
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6593 /*
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6594 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6595 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6596 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6597 const array_property& data)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6598 {
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6599 double val = data.min_val ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6600 if (xfinite (val) && val < min_val)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6601 min_val = val;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6602 val = data.max_val ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6603 if (xfinite (val) && val > max_val)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6604 max_val = val;
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6605 val = data.min_pos ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6606 if (xfinite (val) && val > 0 && val < min_pos)
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6607 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6608 val = data.max_neg ();
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6609 if (xfinite (val) && val < 0 && val > max_neg)
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6610 max_neg = val;
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6611 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6612 */
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6613
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6614 static void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6615 check_limit_vals (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6616 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6617 const octave_value& data)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6618 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6619 if (data.is_matrix_type ())
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6620 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6621 Matrix m = data.matrix_value ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6622
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
6623 if (m.numel () == 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6624 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6625 double val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6626
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6627 val = m(0);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6628 if (xfinite (val) && val < min_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6629 min_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6630
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6631 val = m(1);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6632 if (xfinite (val) && val > max_val)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6633 max_val = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6634
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6635 val = m(2);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6636 if (xfinite (val) && val > 0 && val < min_pos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6637 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6638
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6639 val = m(3);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
6640 if (xfinite (val) && val < 0 && val > max_neg)
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6641 max_neg = val;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6642 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6643 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
6644 }
7836
4fb2db9c87dd Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7835
diff changeset
6645
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6646 // magform(x) Returns (a, b),
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6647 // where x = a * 10^b, abs (a) >= 1., and b is integer.
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6648
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6649 static void
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6650 magform (double x, double& a, int& b)
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6651 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6652 if (x == 0)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6653 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6654 a = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6655 b = 0;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6656 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6657 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6658 {
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
6659 b = static_cast<int> (gnulib::floor (std::log10 (std::abs (x))));
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 13132
diff changeset
6660 a = x / std::pow (10.0, b);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6661 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6662 }
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6663
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6664 // A translation from Tom Holoryd's python code at
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6665 // http://kurage.nimh.nih.gov/tomh/tics.py
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6666 // FIXME: add log ticks
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6667
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6668 double
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6669 axes::properties::calc_tick_sep (double lo, double hi)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6670 {
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6671 int ticint = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6672
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6673 // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and SCALE3 for
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6674 // Determination of Scales on Computer Generated Plots", Communications of
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6675 // the ACM, 10 (1973), 639-640.
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6676 // Also cited as ACM Algorithm 463.
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6677
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6678 double a;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6679 int b, x;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6680
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6681 magform ((hi - lo) / ticint, a, b);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6682
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6683 static const double sqrt_2 = sqrt (2.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6684 static const double sqrt_10 = sqrt (10.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6685 static const double sqrt_50 = sqrt (50.0);
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6686
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6687 if (a < sqrt_2)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6688 x = 1;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6689 else if (a < sqrt_10)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6690 x = 2;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6691 else if (a < sqrt_50)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6692 x = 5;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6693 else
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6694 x = 10;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6695
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6696 return x * std::pow (10., b);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6697 }
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6698
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6699 // Attempt to make "nice" limits from the actual max and min of the data.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6700 // For log plots, we will also use the smallest strictly positive value.
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6701
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6702 Matrix
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6703 axes::properties::get_axis_limits (double xmin, double xmax,
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6704 double min_pos, double max_neg,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6705 bool logscale)
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6706 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6707 Matrix retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6708
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6709 double min_val = xmin;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6710 double max_val = xmax;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6711
13757
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6712 if (xisinf (min_val) && min_val > 0 && xisinf (max_val) && max_val < 0)
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6713 {
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6714 retval = default_lim (logscale);
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6715 return retval;
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6716 }
1e81e2e30af3 default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents: 13756
diff changeset
6717 else if (! (xisinf (min_val) || xisinf (max_val)))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6718 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6719 if (logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6720 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6721 if (xisinf (min_pos) && xisinf (max_neg))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6722 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6723 // FIXME: max_neg is needed for "loglog ([0 -Inf])"
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6724 // This is the *only* place where max_neg is needed.
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6725 // Is there another way?
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6726 retval = default_lim ();
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6727 retval(0) = pow (10., retval(0));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6728 retval(1) = pow (10., retval(1));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6729 return retval;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6730 }
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6731 if (min_val <= 0 && max_val > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6732 {
14062
5b49cafe0599 Use non-negative, non-positive with hyphens in error messages.
Rik <octave@nomad.inbox5.com>
parents: 14022
diff changeset
6733 warning ("axis: omitting non-positive data in log plot");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6734 min_val = min_pos;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6735 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6736 // FIXME: maybe this test should also be relative?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6737 if (std::abs (min_val - max_val)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6738 < sqrt (std::numeric_limits<double>::epsilon ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6739 {
14691
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6740 // Widen range when too small
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6741 if (min_val >= 0)
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6742 {
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6743 min_val *= 0.9;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6744 max_val *= 1.1;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6745 }
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6746 else
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6747 {
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6748 min_val *= 1.1;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6749 max_val *= 0.9;
e3da2a68d709 Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents: 14604
diff changeset
6750 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6751 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6752 if (min_val > 0)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6753 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6754 // Log plots with all positive data
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6755 min_val = pow (10, gnulib::floor (log10 (min_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6756 max_val = pow (10, std::ceil (log10 (max_val)));
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6757 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6758 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6759 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6760 // Log plots with all negative data
13756
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13736
diff changeset
6761 min_val = -pow (10, std::ceil (log10 (-min_val)));
6dfebfa334cb allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents: 13736
diff changeset
6762 max_val = -pow (10, gnulib::floor (log10 (-max_val)));
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6763 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6764 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6765 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6766 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6767 if (min_val == 0 && max_val == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6768 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6769 min_val = -1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6770 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6771 }
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
6772 // FIXME: maybe this test should also be relative?
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6773 else if (std::abs (min_val - max_val)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6774 < sqrt (std::numeric_limits<double>::epsilon ()))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6775 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6776 min_val -= 0.1 * std::abs (min_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6777 max_val += 0.1 * std::abs (max_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6778 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6779
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6780 double tick_sep = calc_tick_sep (min_val, max_val);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6781 double min_tick = gnulib::floor (min_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6782 double max_tick = std::ceil (max_val / tick_sep);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6783 // Prevent round-off from cropping ticks
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6784 min_val = std::min (min_val, tick_sep * min_tick);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6785 max_val = std::max (max_val, tick_sep * max_tick);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6786 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6787 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6788
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6789 retval.resize (1, 2);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6790
14022
de90542b7afc Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
6791 retval(1) = max_val;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6792 retval(0) = min_val;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6793
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6794 return retval;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6795 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
6796
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6797 void
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7868
diff changeset
6798 axes::properties::calc_ticks_and_lims (array_property& lims,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6799 array_property& ticks,
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6800 array_property& mticks,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6801 bool limmode_is_auto, bool is_logscale)
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6802 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
6803 // FIXME: add log ticks and lims
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6804
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6805 if (lims.get ().is_empty ())
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6806 return;
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6807
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6808 double lo = (lims.get ().matrix_value ())(0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6809 double hi = (lims.get ().matrix_value ())(1);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6810 bool is_negative = lo < 0 && hi < 0;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6811 double tmp;
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17842
diff changeset
6812 // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6813 if (hi < lo)
18736
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6814 std::swap (hi, lo);
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6815
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6816 if (is_logscale)
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6817 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6818 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6819 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6820 tmp = hi;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6821 hi = std::log10 (-lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6822 lo = std::log10 (-tmp);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6823 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6824 else
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6825 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6826 hi = std::log10 (hi);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6827 lo = std::log10 (lo);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6828 }
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6829 }
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6830
18736
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6831 double tick_sep;
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
6832
18736
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6833 if (is_logscale)
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6834 {
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6835 if (! (xisinf (hi) || xisinf (lo)))
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6836 tick_sep = 1; // Tick is every order of magnitude (bug #39449)
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6837 else
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6838 tick_sep = 0;
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6839 }
ec55f6870efb Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents: 18717
diff changeset
6840 else
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6841 tick_sep = calc_tick_sep (lo, hi);
13106
c7512d0d52e8 src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents: 12587
diff changeset
6842
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
6843 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6844 int i2 = static_cast<int> (std::ceil (hi / tick_sep));
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6845
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6846 if (limmode_is_auto)
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6847 {
20323
494a5ed628b5 Fix segfault when zooming in on logscale axes (bug #45412).
Rik <rik@octave.org>
parents: 20320
diff changeset
6848 // Adjust limits to include min and max ticks
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6849 Matrix tmp_lims (1,2);
12549
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6850 tmp_lims(0) = std::min (tick_sep * i1, lo);
570193964185 graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents: 12508
diff changeset
6851 tmp_lims(1) = std::max (tick_sep * i2, hi);
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6852
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6853 if (is_logscale)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6854 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6855 tmp_lims(0) = std::pow (10., tmp_lims(0));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6856 tmp_lims(1) = std::pow (10., tmp_lims(1));
10941
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
6857 if (tmp_lims(0) <= 0)
97294dd3ccd4 graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents: 10923
diff changeset
6858 tmp_lims(0) = std::pow (10., lo);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6859 if (is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6860 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6861 tmp = tmp_lims(0);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6862 tmp_lims(0) = -tmp_lims(1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6863 tmp_lims(1) = -tmp;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6864 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
6865 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6866 lims = tmp_lims;
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6867 }
20302
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6868 else
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6869 {
20323
494a5ed628b5 Fix segfault when zooming in on logscale axes (bug #45412).
Rik <rik@octave.org>
parents: 20320
diff changeset
6870 // adjust min and max ticks to be within limits
20302
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6871 if (i1*tick_sep < lo)
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6872 i1++;
20323
494a5ed628b5 Fix segfault when zooming in on logscale axes (bug #45412).
Rik <rik@octave.org>
parents: 20320
diff changeset
6873 if (i2*tick_sep > hi && i2 > i1)
20302
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6874 i2--;
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6875 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6876
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6877 Matrix tmp_ticks (1, i2-i1+1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
6878 for (int i = 0; i <= i2-i1; i++)
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6879 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6880 tmp_ticks(i) = tick_sep * (i+i1);
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6881 if (is_logscale)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6882 tmp_ticks(i) = std::pow (10., tmp_ticks(i));
7857
09b1a9c88128 added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7855
diff changeset
6883 }
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6884 if (is_logscale && is_negative)
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6885 {
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6886 Matrix rev_ticks (1, i2-i1+1);
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6887 rev_ticks = -tmp_ticks;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6888 for (int i = 0; i <= i2-i1; i++)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6889 tmp_ticks(i) = rev_ticks(i2-i1-i);
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
6890 }
7827
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6891
3584f37eac69 better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents: 7824
diff changeset
6892 ticks = tmp_ticks;
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6893
14321
a9a42d630bd5 use 8 minor tick marks per decade for log scale plots, not 9.
John W. Eaton <jwe@octave.org>
parents: 14312
diff changeset
6894 int n = is_logscale ? 8 : 4;
12157
0b9c1a7e350a fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents: 12126
diff changeset
6895 Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1));
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6896
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6897 for (int i = 0; i < tmp_ticks.numel ()-1; i++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6898 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6899 double d = (tmp_ticks(i+1) - tmp_ticks(i)) / (n + 1);
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6900 for (int j = 0; j < n; j++)
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6901 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6902 tmp_mticks(n*i+j) = tmp_ticks(i) + d * (j+1);
12126
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6903 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6904 }
85f9a5b211fd restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents: 11598
diff changeset
6905 mticks = tmp_mticks;
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6906 }
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
6907
20302
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6908 /*
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6909 %!test # Bug #45356
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6910 %! hf = figure ("visible", "off");
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6911 %! unwind_protect
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6912 %! plot (1:10);
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6913 %! xlim ([4.75, 8.5]);
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6914 %! tics = get (gca, "xtick");
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6915 %! assert (tics, [5 6 7 8]);
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6916 %! unwind_protect_cleanup
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6917 %! close (hf);
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6918 %! end_unwind_protect
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6919 */
ce8fda51d236 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356).
Rik <rik@octave.org>
parents: 20267
diff changeset
6920
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6921 void
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6922 axes::properties::calc_ticklabels (const array_property& ticks,
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6923 any_property& labels, bool logscale)
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6924 {
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6925 Matrix values = ticks.get ().matrix_value ();
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6926 Cell c (values.dims ());
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6927 std::ostringstream os;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6928
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6929 if (logscale)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6930 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6931 double significand;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6932 double exponent;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6933 double exp_max = 0.0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6934 double exp_min = 0.0;
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6935
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6936 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6937 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6938 exp_max = std::max (exp_max, std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6939 exp_min = std::max (exp_min, std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6940 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6941
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6942 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6943 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6944 if (values(i) < 0.0)
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6945 exponent = gnulib::floor (std::log10 (-values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6946 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6947 exponent = gnulib::floor (std::log10 (values(i)));
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6948 significand = values(i) * std::pow (10., -exponent);
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6949 os.str (std::string ());
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6950 os << significand;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6951 if (exponent < 0.0)
13211
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6952 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6953 os << "e-";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6954 exponent = -exponent;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6955 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6956 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6957 os << "e+";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6958 if (exponent < 10. && (exp_max > 9 || exp_min < -9))
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6959 os << "0";
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6960 os << exponent;
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6961 c(i) = os.str ();
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6962 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6963 }
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6964 else
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6965 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6966 for (int i = 0; i < values.numel (); i++)
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6967 {
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6968 os.str (std::string ());
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6969 os << values(i);
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6970 c(i) = os.str ();
78744376463a src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents: 13210
diff changeset
6971 }
9347
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6972 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6973
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6974 labels = c;
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6975 }
3da821b161e9 imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents: 9316
diff changeset
6976
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6977 Matrix
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6978 axes::properties::get_ticklabel_extents (const Matrix& ticks,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6979 const string_vector& ticklabels,
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6980 const Matrix& limits)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6981 {
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
6982 #ifndef HAVE_FREETYPE
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6983 double fontsize = get ("fontsize").double_value ();
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6984 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6985
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6986 Matrix ext (1, 2, 0.0);
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
6987 double wmax, hmax;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
6988 wmax = hmax = 0.0;
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6989 int n = std::min (ticklabels.numel (), ticks.numel ());
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6990 for (int i = 0; i < n; i++)
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6991 {
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6992 double val = ticks(i);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6993 if (limits(0) <= val && val <= limits(1))
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6994 {
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6995 std::string label (ticklabels(i));
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6996 label.erase (0, label.find_first_not_of (" "));
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
6997 label = label.substr (0, label.find_last_not_of (" ")+1);
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
6998 #ifdef HAVE_FREETYPE
17269
5b088598df1d Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17260
diff changeset
6999 ext = text_renderer.get_extent (label, 0.0, "none");
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7000 wmax = std::max (wmax, ext(0));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7001 hmax = std::max (hmax, ext(1));
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7002 #else
16855
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
7003 // FIXME: find a better approximation
359ac80ecb30 Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents: 16854
diff changeset
7004 int len = label.length ();
12334
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7005 wmax = std::max (wmax, 0.5*fontsize*len);
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7006 hmax = fontsize;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7007 #endif
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7008 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7009 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7010
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7011 ext(0) = wmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7012 ext(1) = hmax;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7013 return ext;
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7014 }
63dc132a1000 Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents: 12327
diff changeset
7015
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7016 void
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7017 get_children_limits (double& min_val, double& max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7018 double& min_pos, double& max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7019 const Matrix& kids, char limit_type)
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7020 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7021 octave_idx_type n = kids.numel ();
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7022
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7023 switch (limit_type)
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7024 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7025 case 'x':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7026 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7027 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7028 graphics_object go = gh_manager::get_object (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7029
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7030 if (go.is_xliminclude ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7031 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7032 octave_value lim = go.get_xlim ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7033
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7034 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7035 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7036 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7037 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7038
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7039 case 'y':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7040 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7041 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7042 graphics_object go = gh_manager::get_object (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7043
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7044 if (go.is_yliminclude ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7045 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7046 octave_value lim = go.get_ylim ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7047
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7048 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7049 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7050 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7051 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7052
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7053 case 'z':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7054 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7055 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7056 graphics_object go = gh_manager::get_object (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7057
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7058 if (go.is_zliminclude ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7059 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7060 octave_value lim = go.get_zlim ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7061
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7062 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7063 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7064 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7065 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7066
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7067 case 'c':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7068 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7069 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7070 graphics_object go = gh_manager::get_object (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7071
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7072 if (go.is_climinclude ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7073 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7074 octave_value lim = go.get_clim ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7075
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7076 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7077 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7078 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7079 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7080
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7081 case 'a':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7082 for (octave_idx_type i = 0; i < n; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7083 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7084 graphics_object go = gh_manager::get_object (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7085
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7086 if (go.is_aliminclude ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7087 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7088 octave_value lim = go.get_alim ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7089
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7090 check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7091 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7092 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7093 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7094
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7095 default:
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7096 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7097 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7098 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7099
18761
868dcab453bd Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18746
diff changeset
7100 static std::set<double> updating_axis_limits;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7101
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
7102 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7103 axes::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7104 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7105 {
19900
726df008104d maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19898
diff changeset
7106 if (updating_axis_limits.find (get_handle ().value ())
726df008104d maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19898
diff changeset
7107 != updating_axis_limits.end ())
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7108 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7109
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7110 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7111
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7112 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7113 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7114 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7115 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7116
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7117 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7118
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7119 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7120 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7121
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7122 #define FIX_LIMITS \
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7123 if (limits.numel () == 4) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7124 { \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7125 val = limits(0); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7126 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7127 min_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7128 val = limits(1); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7129 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7130 max_val = val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7131 val = limits(2); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7132 if (xfinite (val)) \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7133 min_pos = val; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7134 val = limits(3); \
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
7135 if (xfinite (val)) \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7136 max_neg = val; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7137 } \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7138 else \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7139 { \
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7140 limits.resize (4, 1); \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7141 limits(0) = min_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7142 limits(1) = max_val; \
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7143 limits(2) = min_pos; \
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7144 limits(3) = max_neg; \
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7145 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7146
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7147 if (axis_type == "xdata" || axis_type == "xscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7148 || axis_type == "xlimmode" || axis_type == "xliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7149 || axis_type == "xlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7150 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7151 if (xproperties.xlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7152 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7153 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7154 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7155
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7156 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7157
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7158 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7159 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7160 xproperties.xscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7161
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7162 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7163 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7164 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7165 else if (axis_type == "ydata" || axis_type == "yscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7166 || axis_type == "ylimmode" || axis_type == "yliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7167 || axis_type == "ylim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7168 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7169 if (xproperties.ylimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7170 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7171 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7172 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7173
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7174 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7175
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7176 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7177 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7178 xproperties.yscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7179
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7180 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7181 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7182 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7183 else if (axis_type == "zdata" || axis_type == "zscale"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7184 || axis_type == "zlimmode" || axis_type == "zliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7185 || axis_type == "zlim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7186 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7187 if (xproperties.zlimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7188 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7189 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7190 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7191
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7192 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7193
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7194 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7195 min_pos, max_neg,
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7196 xproperties.zscale_is ("log"));
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7197
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7198 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7199 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7200 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7201 else if (axis_type == "cdata" || axis_type == "climmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7202 || axis_type == "cdatamapping" || axis_type == "climinclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7203 || axis_type == "clim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7204 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7205 if (xproperties.climmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7206 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7207 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7208 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7209
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7210 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7211
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7212 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7213 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7214 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7215 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7216 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7217 else if (min_val == max_val)
13247
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7218 {
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7219 max_val = min_val + 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7220 min_val -= 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7221 }
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7222
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7223 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7224
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7225 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7226 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7227
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7228 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7229 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7230
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7231 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7232 else if (axis_type == "alphadata" || axis_type == "alimmode"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7233 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7234 || axis_type == "alim")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7235 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7236 if (xproperties.alimmode_is ("auto"))
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7237 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7238 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7239 FIX_LIMITS ;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7240
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7241 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7242
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7243 if (min_val > max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7244 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7245 min_val = min_pos = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7246 max_val = 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7247 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7248 else if (min_val == max_val)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7249 max_val = min_val + 1;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7250
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7251 limits.resize (1, 2);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7252
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7253 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7254 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7255
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7256 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7257 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7258
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7259 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7260
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7261 #undef FIX_LIMITS
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7262
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7263 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7264 frame.protect_var (updating_axis_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7265
18761
868dcab453bd Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18746
diff changeset
7266 updating_axis_limits.insert (get_handle ().value ());
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7267
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7268 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7269 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7270 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7271 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7272 xproperties.set_xlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7273 xproperties.update_xlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7274 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7275
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7276 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7277 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7278 xproperties.set_ylimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7279 xproperties.update_ylim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7280 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7281
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7282 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7283 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7284 xproperties.set_zlimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7285 xproperties.update_zlim ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7286 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7287
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7288 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7289 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7290 xproperties.set_climmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7291 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7292
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7293 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7294 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7295 xproperties.set_alimmode ("auto");
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7296 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7297
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7298 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7299 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7300 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7301
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7302 xproperties.update_transform ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7303 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7304
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
7305 void
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7306 axes::update_axis_limits (const std::string& axis_type)
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
7307 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
7308 if ((updating_axis_limits.find (get_handle ().value ())
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
7309 != updating_axis_limits.end ())
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
7310 || (updating_aspectratios.find (get_handle ().value ())
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
7311 != updating_aspectratios.end ()))
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7312 return;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7313
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7314 Matrix kids = xproperties.get_children ();
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7315
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7316 double min_val = octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7317 double max_val = -octave_Inf;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7318 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7319 double max_neg = -octave_Inf;
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7320
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7321 char update_type = 0;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7322
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7323 Matrix limits;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7324
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7325 if (axis_type == "xdata" || axis_type == "xscale"
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7326 || axis_type == "xlimmode" || axis_type == "xliminclude"
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7327 || axis_type == "xlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7328 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7329 if (xproperties.xlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7330 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7331 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7332
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7333 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7334 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7335 xproperties.xscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7336
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7337 update_type = 'x';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7338 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7339 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7340 else if (axis_type == "ydata" || axis_type == "yscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7341 || axis_type == "ylimmode" || axis_type == "yliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7342 || axis_type == "ylim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7343 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7344 if (xproperties.ylimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7345 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7346 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7347
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7348 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7349 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7350 xproperties.yscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7351
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7352 update_type = 'y';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7353 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7354 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7355 else if (axis_type == "zdata" || axis_type == "zscale"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7356 || axis_type == "zlimmode" || axis_type == "zliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7357 || axis_type == "zlim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7358 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7359 if (xproperties.zlimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7360 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7361 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7362
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7363 limits = xproperties.get_axis_limits (min_val, max_val,
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7364 min_pos, max_neg,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7365 xproperties.zscale_is ("log"));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7366
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7367 update_type = 'z';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7368 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7369 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7370 else if (axis_type == "cdata" || axis_type == "climmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7371 || axis_type == "cdatamapping" || axis_type == "climinclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7372 || axis_type == "clim")
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7373 {
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7374 if (xproperties.climmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7375 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7376 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7377
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7378 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7379 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7380 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7381 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7382 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7383 else if (min_val == max_val)
13247
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7384 {
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7385 max_val = min_val + 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7386 min_val -= 1;
e36c2f4ea8f5 Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents: 13236
diff changeset
7387 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7388
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7389 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7390
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7391 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7392 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7393
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7394 update_type = 'c';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7395 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7396
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7397 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7398 else if (axis_type == "alphadata" || axis_type == "alimmode"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7399 || axis_type == "alphadatamapping" || axis_type == "aliminclude"
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7400 || axis_type == "alim")
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7401 {
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7402 if (xproperties.alimmode_is ("auto"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7403 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7404 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7405
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7406 if (min_val > max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7407 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7408 min_val = min_pos = 0;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7409 max_val = 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7410 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7411 else if (min_val == max_val)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7412 max_val = min_val + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7413
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7414 limits.resize (1, 2);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7415
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7416 limits(0) = min_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7417 limits(1) = max_val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7418
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7419 update_type = 'a';
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
7420 }
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7421
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7422 }
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7423
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7424 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7425 frame.protect_var (updating_axis_limits);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
7426
18761
868dcab453bd Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18746
diff changeset
7427 updating_axis_limits.insert (get_handle ().value ());
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7428
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7429 switch (update_type)
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7430 {
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7431 case 'x':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7432 xproperties.set_xlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7433 xproperties.set_xlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
7434 xproperties.update_xlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7435 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7436
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7437 case 'y':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7438 xproperties.set_ylim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7439 xproperties.set_ylimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
7440 xproperties.update_ylim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7441 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7442
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7443 case 'z':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7444 xproperties.set_zlim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7445 xproperties.set_zlimmode ("auto");
7446
4bfbec4b0e24 [project @ 2008-02-04 21:17:18 by jwe]
jwe
parents: 7445
diff changeset
7446 xproperties.update_zlim ();
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7447 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7448
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7449 case 'c':
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7450 xproperties.set_clim (limits);
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7451 xproperties.set_climmode ("auto");
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7452 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7453
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7454 case 'a':
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7455 xproperties.set_alim (limits);
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7456 xproperties.set_alimmode ("auto");
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7457 break;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7458
7222
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7459 default:
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7460 break;
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7461 }
dd8b3bbeeaf9 [project @ 2007-11-30 06:23:25 by jwe]
jwe
parents: 7214
diff changeset
7462
7427
65f0a8ced9d2 [project @ 2008-01-28 22:42:18 by jwe]
jwe
parents: 7419
diff changeset
7463 xproperties.update_transform ();
7214
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
7464 }
86d0b16f2bb2 [project @ 2007-11-29 03:40:04 by jwe]
jwe
parents: 7213
diff changeset
7465
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7466 inline
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
7467 double force_in_range (double x, double lower, double upper)
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7468 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7469 if (x < lower)
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
7470 return lower;
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7471 else if (x > upper)
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
7472 return upper;
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7473 else
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
7474 return x;
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7475 }
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7476
14311
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7477 static Matrix
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7478 do_zoom (double val, double factor, const Matrix& lims, bool is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7479 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7480 Matrix new_lims = lims;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7481
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7482 double lo = lims(0);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7483 double hi = lims(1);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7484
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7485 bool is_negative = lo < 0 && hi < 0;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7486
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7487 if (is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7488 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7489 if (is_negative)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7490 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7491 double tmp = hi;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7492 hi = std::log10 (-lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7493 lo = std::log10 (-tmp);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7494 val = std::log10 (-val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7495 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7496 else
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7497 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7498 hi = std::log10 (hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7499 lo = std::log10 (lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7500 val = std::log10 (val);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7501 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7502 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7503
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7504 // Perform the zooming
19901
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
7505 lo = val + (lo - val) / factor;
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19900
diff changeset
7506 hi = val + (hi - val) / factor;
14311
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7507
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7508 if (is_logscale)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7509 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7510 if (is_negative)
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7511 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7512 double tmp = -std::pow (10.0, hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7513 hi = -std::pow (10.0, lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7514 lo = tmp;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7515 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7516 else
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7517 {
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7518 lo = std::pow (10.0, lo);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7519 hi = std::pow (10.0, hi);
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7520 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7521 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7522
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7523 new_lims(0) = lo;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7524 new_lims(1) = hi;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7525
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7526 return new_lims;
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7527 }
d4f37aa5d126 fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
7528
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7529 void
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7530 axes::properties::zoom_about_point (const std::string& mode,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7531 double x, double y, double factor,
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7532 bool push_to_zoom_stack)
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7533 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7534 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7535 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7536 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7537
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7538 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7539 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7540 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7541 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7542 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7543 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7544 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7545
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7546 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7547 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7548 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7549 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7550 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7551
14324
5a2b012b10c7 allow zooming for logscale plots
John W. Eaton <jwe@octave.org>
parents: 14323
diff changeset
7552 xlims = do_zoom (x, factor, xlims, xscale_is ("log"));
5a2b012b10c7 allow zooming for logscale plots
John W. Eaton <jwe@octave.org>
parents: 14323
diff changeset
7553 ylims = do_zoom (y, factor, ylims, yscale_is ("log"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7554
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7555 zoom (mode, xlims, ylims, push_to_zoom_stack);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7556 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7557
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7558 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7559 axes::properties::zoom (const std::string& mode, double factor,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7560 bool push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7561 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7562 // FIXME: Do we need error checking here?
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7563 Matrix xlims = get_xlim ().matrix_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7564 Matrix ylims = get_ylim ().matrix_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7565
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7566 double x = (xlims(0) + xlims(1)) / 2;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7567 double y = (ylims(0) + ylims(1)) / 2;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7568
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7569 zoom_about_point (mode, x, y, factor, push_to_zoom_stack);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7570 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7571
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7572 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7573 axes::properties::push_zoom_stack (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7574 {
19927
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7575 if (zoom_stack.empty ())
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7576 {
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7577 zoom_stack.push_front (xlimmode.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7578 zoom_stack.push_front (xlim.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7579 zoom_stack.push_front (ylimmode.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7580 zoom_stack.push_front (ylim.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7581 zoom_stack.push_front (zlimmode.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7582 zoom_stack.push_front (zlim.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7583 zoom_stack.push_front (view.get ());
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7584 }
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7585 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7586
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7587 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7588 axes::properties::zoom (const std::string& mode,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7589 const Matrix& xl, const Matrix& yl,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
7590 bool push_to_zoom_stack)
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7591 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7592 if (push_to_zoom_stack)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7593 push_zoom_stack ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7594
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7595 if (mode == "horizontal" || mode == "both")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7596 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7597 xlim = xl;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7598 xlimmode = "manual";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7599 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7600
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7601 if (mode == "vertical" || mode == "both")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7602 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7603 ylim = yl;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7604 ylimmode = "manual";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7605 }
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7606
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7607 update_transform ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7608
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7609 if (mode == "horizontal" || mode == "both")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7610 update_xlim ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7611
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7612 if (mode == "vertical" || mode == "both")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7613 update_ylim ();
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7614 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7615
14314
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7616 static Matrix
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7617 do_translate (double x0, double x1, const Matrix& lims, bool is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7618 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7619 Matrix new_lims = lims;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7620
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7621 double lo = lims(0);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7622 double hi = lims(1);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7623
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7624 bool is_negative = lo < 0 && hi < 0;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7625
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7626 double delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7627
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7628 if (is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7629 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7630 if (is_negative)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7631 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7632 double tmp = hi;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7633 hi = std::log10 (-lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7634 lo = std::log10 (-tmp);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7635 x0 = -x0;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7636 x1 = -x1;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7637 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7638 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7639 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7640 hi = std::log10 (hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7641 lo = std::log10 (lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7642 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7643
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7644 delta = std::log10 (x0) - std::log10 (x1);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7645 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7646 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7647 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7648 delta = x0 - x1;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7649 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7650
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7651 // Perform the translation
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7652 lo += delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7653 hi += delta;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7654
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7655 if (is_logscale)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7656 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7657 if (is_negative)
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7658 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7659 double tmp = -std::pow (10.0, hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7660 hi = -std::pow (10.0, lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7661 lo = tmp;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7662 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7663 else
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7664 {
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7665 lo = std::pow (10.0, lo);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7666 hi = std::pow (10.0, hi);
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7667 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7668 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7669
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7670 new_lims(0) = lo;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7671 new_lims(1) = hi;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7672
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7673 return new_lims;
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7674 }
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7675
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7676 void
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7677 axes::properties::translate_view (const std::string& mode,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7678 double x0, double x1, double y0, double y1,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7679 bool push_to_zoom_stack)
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7680 {
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7681 // FIXME: Do we need error checking here?
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7682 Matrix xlims = get_xlim ().matrix_value ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7683 Matrix ylims = get_ylim ().matrix_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7684
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7685 // Get children axes limits
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7686 Matrix kids = get_children ();
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7687 double minx = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7688 double maxx = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7689 double min_pos_x = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7690 double max_neg_x = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7691 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7692
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7693 double miny = octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7694 double maxy = -octave_Inf;
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
7695 double min_pos_y = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7696 double max_neg_y = -octave_Inf;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7697 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7698
14314
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7699 xlims = do_translate (x0, x1, xlims, xscale_is ("log"));
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14313
diff changeset
7700 ylims = do_translate (y0, y1, ylims, yscale_is ("log"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7701
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7702 zoom (mode, xlims, ylims, push_to_zoom_stack);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7703 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7704
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7705 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7706 axes::properties::pan (const std::string& mode, double factor,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7707 bool push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7708 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7709 // FIXME: Do we need error checking here?
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7710 Matrix xlims = get_xlim ().matrix_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7711 Matrix ylims = get_ylim ().matrix_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7712
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7713 double x0 = (xlims(0) + xlims(1)) / 2;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7714 double y0 = (ylims(0) + ylims(1)) / 2;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7715
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7716 double x1 = x0 + (xlims(1) - xlims(0)) * factor;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7717 double y1 = y0 + (ylims(1) - ylims(0)) * factor;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7718
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7719 translate_view (mode, x0, x1, y0, y1, push_to_zoom_stack);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7720 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7721
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7722 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7723 axes::properties::rotate3d (double x0, double x1, double y0, double y1,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7724 bool push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7725 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7726 if (push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7727 push_zoom_stack ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7728
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7729 Matrix bb = get_boundingbox (true);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7730 Matrix new_view = get_view ().matrix_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7731
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7732 // Compute new view angles
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7733 new_view(0) += ((x0 - x1) * (180.0 / bb(2)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7734 new_view(1) += ((y1 - y0) * (180.0 / bb(3)));
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7735
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7736 // Clipping
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7737 new_view(1) = std::min (new_view(1), 90.0);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7738 new_view(1) = std::max (new_view(1), -90.0);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7739 if (new_view(0) > 180.0)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7740 new_view(0) -= 360.0;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7741 else if (new_view(0) < -180.0)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7742 new_view(0) += 360.0;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7743
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7744 // Snapping
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7745 double snapmargin = 1.0;
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7746 for (int a = -90; a <= 90; a += 90)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7747 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7748 if ((a - snapmargin) < new_view(1) && new_view(1) < (a + snapmargin))
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7749 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7750 new_view(1) = a;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7751 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7752 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7753 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7754
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7755 for (int a = -180; a <= 180; a += 180)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7756 if ((a - snapmargin) < new_view(0) && new_view(0) < (a + snapmargin))
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7757 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7758 if (a == 180)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7759 new_view(0) = -180;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7760 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7761 new_view(0) = a;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7762 break;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7763 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7764
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7765 // Update axes properties
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7766 set_view (new_view);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7767 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7768
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7769 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7770 axes::properties::rotate_view (double delta_el, double delta_az,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7771 bool push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7772 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7773 if (push_to_zoom_stack)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7774 push_zoom_stack ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7775
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7776 Matrix v = get_view ().matrix_value ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7777
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7778 v(1) += delta_el;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7779
15017
dd4ad69e4ab9 maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents: 14861
diff changeset
7780 if (v(1) > 90)
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7781 v(1) = 90;
15017
dd4ad69e4ab9 maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents: 14861
diff changeset
7782 if (v(1) < -90)
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7783 v(1) = -90;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
7784
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7785 v(0) = fmod (v(0) - delta_az + 720,360);
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7786
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
7787 set_view (v);
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7788
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
7789 update_transform ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7790 }
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7791
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10733
diff changeset
7792 void
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7793 axes::properties::unzoom (void)
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7794 {
19927
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7795 if (zoom_stack.size () >= 7)
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7796 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7797 view = zoom_stack.front ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7798 zoom_stack.pop_front ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7799
19927
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7800 zlim = zoom_stack.front ();
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7801 zoom_stack.pop_front ();
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7802
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7803 zlimmode = zoom_stack.front ();
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7804 zoom_stack.pop_front ();
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7805
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7806 ylim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7807 zoom_stack.pop_front ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7808
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7809 ylimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7810 zoom_stack.pop_front ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7811
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7812 xlim = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7813 zoom_stack.pop_front ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7814
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7815 xlimmode = zoom_stack.front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7816 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7817
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7818 update_transform ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7819
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7820 update_xlim ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7821 update_ylim ();
19927
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7822 update_zlim ();
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7823
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7824 update_view ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7825 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7826 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7827
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7828 void
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7829 axes::properties::clear_zoom_stack (bool do_unzoom)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7830 {
19927
0c32e02d60c3 only save one set of limits on the zoom stack (bug #44304)
John W. Eaton <jwe@octave.org>
parents: 19919
diff changeset
7831 size_t items_to_leave_on_stack = do_unzoom ? 7 : 0;
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7832
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7833 while (zoom_stack.size () > items_to_leave_on_stack)
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7834 zoom_stack.pop_front ();
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7835
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7836 if (do_unzoom)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
7837 unzoom ();
7855
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7838 }
f317f14516cb Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7849
diff changeset
7839
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7840 void
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7841 axes::reset_default_properties (void)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7842 {
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
7843 // empty list of local defaults
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
7844 default_properties = property_list ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
7845
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
7846 // reset factory defaults
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
7847 set_defaults ("reset");
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7848 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
7849
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7850 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7851 axes::initialize (const graphics_object& go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7852 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7853 base_graphics_object::initialize (go);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7854
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7855 xinitialize (xproperties.get_title ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7856 xinitialize (xproperties.get_xlabel ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7857 xinitialize (xproperties.get_ylabel ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7858 xinitialize (xproperties.get_zlabel ());
17098
786bcce466e9 Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents: 17081
diff changeset
7859
786bcce466e9 Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents: 17081
diff changeset
7860 xproperties.sync_positions ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7861 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
7862
7363
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7863 // ---------------------------------------------------------------------
c31e5dab4f85 [project @ 2008-01-12 08:21:57 by jwe]
jwe
parents: 7317
diff changeset
7864
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7865 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7866 line::properties::compute_xlim (void) const
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7867 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7868 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7869
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7870 m(0) = xdata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7871 m(1) = xdata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7872 m(2) = xdata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7873 m(3) = xdata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7874
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7875 return m;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7876 }
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7877
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7878 Matrix
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7879 line::properties::compute_ylim (void) const
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7880 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7881 Matrix m (1, 4);
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7882
10596
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7883 m(0) = ydata.min_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7884 m(1) = ydata.max_val ();
24e915c602e7 Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents: 10565
diff changeset
7885 m(2) = ydata.min_pos ();
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
7886 m(3) = ydata.max_neg ();
7862
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7887
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7888 return m;
8f3459a90bf3 Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7860
diff changeset
7889 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7890
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7891 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
7892
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7893 Matrix
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7894 text::properties::get_data_position (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7895 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7896 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7897
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7898 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7899 pos = convert_text_position (pos, *this, get_units (), "data");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7900
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7901 return pos;
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7902 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7903
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7904 Matrix
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7905 text::properties::get_extent_matrix (void) const
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7906 {
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7907 // FIXME: Should this function also add the (x,y) base position?
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7908 return extent.get ().matrix_value ();
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7909 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7910
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7911 octave_value
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7912 text::properties::get_extent (void) const
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7913 {
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7914 // FIXME: This doesn't work right for 3D plots.
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7915 // (It doesn't in Matlab either, at least not in version 6.5.)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7916 Matrix m = extent.get ().matrix_value ();
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7917 Matrix pos = get_position ().matrix_value ();
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7918 Matrix p = convert_text_position (pos, *this, get_units (), "pixels");
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7919
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7920 m(0) += p(0);
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
7921 m(1) += p(1);
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7922
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7923 return convert_text_position (m, *this, "pixels", get_units ());
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7924 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7925
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7926 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7927 text::properties::set_fontunits (const octave_value& val)
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7928 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7929 caseless_str old_fontunits = get_fontunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7930
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7931 if (fontunits.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7932 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7933 update_fontunits (old_fontunits);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
7934 mark_modified ();
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7935 }
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7936 }
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7937
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7938 void
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7939 text::properties::update_fontunits (const caseless_str& old_units)
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7940 {
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7941 caseless_str new_units = get_fontunits ();
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7942 double parent_height = 0;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7943 double fontsz = get_fontsize ();
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7944
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7945 if (new_units == "normalized")
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7946 {
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7947 graphics_object go (gh_manager::get_object (get___myhandle__ ()));
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7948 graphics_object ax (go.get_ancestor ("axes"));
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7949
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7950 parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7951 }
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7952
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7953 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7954
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
7955 set_fontsize (octave_value (fontsz));
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7956 }
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7957
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7958 void
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7959 text::properties::update_font (void)
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7960 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
7961 #ifdef HAVE_FREETYPE
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
7962 #ifdef HAVE_FONTCONFIG
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7963 renderer.set_font (get ("fontname").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7964 get ("fontweight").string_value (),
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7965 get ("fontangle").string_value (),
19081
1288a2f27769 Handle non "points" fontunits properties (bug # 40158)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19078
diff changeset
7966 get ("fontsize_points").double_value ());
10526
660c244d3206 Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents: 10402
diff changeset
7967 #endif
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7968 renderer.set_color (get_color_rgb ());
12777
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7969 #endif
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7970 }
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7971
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7972 void
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7973 text::properties::update_text_extent (void)
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7974 {
6c1d0f03c331 Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents: 12685
diff changeset
7975 #ifdef HAVE_FREETYPE
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7976
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
7977 int halign = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
7978 int valign = 0;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7979
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7980 if (horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7981 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7982 else if (horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7983 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
7984
16206
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7985 if (verticalalignment_is ("middle"))
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7986 valign = 1;
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7987 else if (verticalalignment_is ("top"))
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7988 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7989 else if (verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7990 valign = 3;
16206
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7991 else if (verticalalignment_is ("cap"))
9ba5c5ed3aeb Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents: 16204
diff changeset
7992 valign = 4;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7993
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7994 Matrix bbox;
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7995
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
7996 // FIXME: string should be parsed only when modified, for efficiency
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7997
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7998 octave_value string_prop = get_string ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
7999
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
8000 string_vector sv = string_prop.all_strings ();
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
8001
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
8002 renderer.text_to_pixels (sv.join ("\n"), pixels, bbox,
17319
27fc61cfbc6e Use interpreter property when rendering text objects (bug #39830).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17286
diff changeset
8003 halign, valign, get_rotation (),
27fc61cfbc6e Use interpreter property when rendering text objects (bug #39830).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17286
diff changeset
8004 get_interpreter ());
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
8005 /* The bbox is relative to the text's position.
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
8006 We'll leave it that way, because get_position () does not return
14413
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
8007 valid results when the text is first constructed.
4f160344236a 2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents: 14395
diff changeset
8008 Conversion to proper coordinates is performed in get_extent. */
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 11450
diff changeset
8009 set_extent (bbox);
12965
22bc9ec80c2c allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents: 12910
diff changeset
8010
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8011 #endif
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
8012
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8013 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel")
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8014 || autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
12440
2ed62b9f949e synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents: 12422
diff changeset
8015 update_autopos ("sync");
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8016 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8017
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8018 void
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
8019 text::properties::request_autopos (void)
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
8020 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8021 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel")
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8022 || autopos_tag_is ("zlabel") || autopos_tag_is ("title"))
12422
a3be83af8cfa simplifications in position updating functions for axes labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents: 12389
diff changeset
8023 update_autopos (get_autopos_tag ());
12389
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
8024 }
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
8025
5367bd36b9f8 implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents: 12348
diff changeset
8026 void
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8027 text::properties::update_units (void)
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8028 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8029 if (! units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8030 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8031 set_xliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8032 set_yliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8033 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8034 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8035
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8036 Matrix pos = get_position ().matrix_value ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8037
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8038 pos = convert_text_position (pos, *this, cached_units, get_units ());
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8039
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8040 // FIXME: if the current axes view is 2D, then one should probably drop
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8041 // the z-component of "pos" and leave "zliminclude" to "off".
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8042
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8043 bool autopos = positionmode_is ("auto");
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8044
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8045 set_position (pos);
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8046
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8047 if (autopos)
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8048 set_positionmode ("auto");
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
8049
10402
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8050 if (units_is ("data"))
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8051 {
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8052 set_xliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8053 set_yliminclude ("on");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8054 // FIXME: see above
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8055 set_zliminclude ("off");
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8056 }
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8057
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8058 cached_units = get_units ();
9f2bf537a651 Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents: 10315
diff changeset
8059 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8060
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8061 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8062 text::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8063 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8064 double fontsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8065 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8066
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8067 if (fontunits_is ("normalized") && parent_height <= 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8068 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8069 graphics_object go (gh_manager::get_object (get___myhandle__ ()));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8070 graphics_object ax (go.get_ancestor ("axes"));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8071
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
8072 parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8073 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8074
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8075 return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8076 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8077
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8078 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8079
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
8080 octave_value
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
8081 image::properties::get_color_data (void) const
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
8082 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8083 return convert_cdata (*this, get_cdata (), cdatamapping_is ("scaled"), 3);
9680
73153525df9a initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9605
diff changeset
8084 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8085
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8086 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8087
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
8088 octave_value
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
8089 patch::properties::get_color_data (void) const
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
8090 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
8091 octave_value fvc = get_facevertexcdata ();
11168
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
8092 if (fvc.is_undefined () || fvc.is_empty ())
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
8093 return Matrix ();
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
8094 else
36442102c340 Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents: 11167
diff changeset
8095 return convert_cdata (*this, fvc,cdatamapping_is ("scaled"), 2);
7833
8ff92634982d Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7829
diff changeset
8096 }
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
8097
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8098 static bool updating_patch_data = false;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8099
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8100 void
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8101 patch::properties::update_fvc (void)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8102 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8103 if (updating_patch_data)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8104 return;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8105
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8106 Matrix xd = get_xdata ().matrix_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8107 Matrix yd = get_ydata ().matrix_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8108 Matrix zd = get_zdata ().matrix_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8109 NDArray cd = get_cdata ().array_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8110
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8111 bad_data_msg = std::string ();
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8112 if (xd.dims () != yd.dims ()
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19895
diff changeset
8113 || (xd.dims () != zd.dims () && ! zd.is_empty ()))
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8114 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8115 bad_data_msg = "x/y/zdata must have the same dimensions";
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8116 return;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8117 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8118
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8119 // Faces and Vertices
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8120 dim_vector dv;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8121 bool is3D = false;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8122 octave_idx_type nr = xd.rows ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8123 octave_idx_type nc = xd.columns ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8124 if (nr == 1 && nc > 1)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8125 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8126 nr = nc;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8127 nc = 1;
18985
5bfedd39cc77 Fix indexing in patch if x/y/zdata are row vectors (bug #42822)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18939
diff changeset
8128 xd = xd.as_column ();
5bfedd39cc77 Fix indexing in patch if x/y/zdata are row vectors (bug #42822)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18939
diff changeset
8129 yd = yd.as_column ();
5bfedd39cc77 Fix indexing in patch if x/y/zdata are row vectors (bug #42822)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18939
diff changeset
8130 zd = zd.as_column ();
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8131 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8132
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8133 dv(0) = nr * nc;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8134 if (zd.is_empty ())
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8135 dv(1) = 2;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8136 else
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8137 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8138 dv(1) = 3;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8139 is3D = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8140 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8141
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8142 Matrix vert (dv);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8143 Matrix idx (nc, nr);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8144
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8145 octave_idx_type kk = 0;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8146 for (octave_idx_type jj = 0; jj < nc; jj++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8147 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8148 for (octave_idx_type ii = 0; ii < nr; ii++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8149 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8150 vert(kk,0) = xd(ii,jj);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8151 vert(kk,1) = yd(ii,jj);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8152 if (is3D)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8153 vert(kk,2) = zd(ii,jj);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8154
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8155 idx(jj,ii) = static_cast<double> (kk+1);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8156
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8157 kk++;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8158 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8159 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8160
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8161 // facevertexcdata
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8162 Matrix fvc;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8163 if (cd.ndims () == 3)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8164 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8165 dv(0) = cd.rows () * cd.columns ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8166 dv(1) = cd.dims ()(2);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8167 fvc = cd.reshape (dv);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8168 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8169 else
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8170 fvc = cd.as_column ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8171
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8172 // FIXME: shouldn't we update facevertexalphadata here ?
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8173
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8174 unwind_protect frame;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8175 frame.protect_var (updating_patch_data);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8176 updating_patch_data = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8177
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8178 faces.set (idx);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8179 vertices.set (vert);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8180 facevertexcdata.set (fvc);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8181 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8182
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8183
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8184 void
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8185 patch::properties::update_data (void)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8186 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8187 if (updating_patch_data)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8188 return;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8189
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8190 Matrix idx = get_faces ().matrix_value ().transpose ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8191 Matrix vert = get_vertices ().matrix_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8192 NDArray fvc = get_facevertexcdata ().array_value ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8193
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8194 octave_idx_type nfaces = idx.columns ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8195 octave_idx_type nvert = vert.rows ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8196
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8197 // Check all vertices in faces are defined
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8198 bad_data_msg = std::string ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8199 if (static_cast<double> (nvert) < idx.row_max ().max ())
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8200 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8201 bad_data_msg = "some vertices in \"faces\" property are undefined";
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8202 return;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8203 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8204
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8205 // Replace NaNs
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8206 if (idx.any_element_is_inf_or_nan ())
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8207 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8208 for (octave_idx_type jj = 0; jj < idx.columns (); jj++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8209 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8210 double valid_vert = idx(0,jj);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8211 bool turn_valid = false;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8212 for (octave_idx_type ii = 0; ii < idx.rows (); ii++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8213 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8214 if (xisnan (idx(ii,jj)) || turn_valid)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8215 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8216 idx(ii,jj) = valid_vert;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8217 turn_valid = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8218 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8219 else
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8220 valid_vert = idx(ii,jj);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8221 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8222 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8223 }
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
8224
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8225 // Build cdata
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8226 dim_vector dv = dim_vector::alloc (3);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8227 NDArray cd;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8228 bool pervertex = false;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8229
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8230 if (fvc.rows () == nfaces || fvc.rows () == 1)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8231 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8232 dv(0) = 1;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8233 dv(1) = fvc.rows ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8234 dv(2) = fvc.columns ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8235 cd = fvc.reshape (dv);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8236 }
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
8237 else
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8238 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8239 if (! fvc.is_empty ())
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8240 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8241 dv(0) = idx.rows ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8242 dv(1) = nfaces;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8243 dv(2) = fvc.columns ();
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8244 cd.resize (dv);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8245 pervertex = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8246 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8247 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8248
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
8249 // Build x,y,zdata and eventually per vertex cdata
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
8250 Matrix xd (idx.dims ());
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8251 Matrix yd (idx.dims ());
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8252 Matrix zd;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8253 bool has_zd = false;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8254 if (vert.columns () > 2)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8255 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8256 zd = Matrix (idx.dims ());
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8257 has_zd = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8258 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8259
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8260 for (octave_idx_type jj = 0; jj < nfaces; jj++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8261 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8262 for (octave_idx_type ii = 0; ii < idx.rows (); ii++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8263 {
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8264 octave_idx_type row = static_cast<octave_idx_type> (idx(ii,jj)-1);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8265 xd(ii,jj) = vert(row,0);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8266 yd(ii,jj) = vert(row,1);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8267
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8268 if (has_zd)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8269 zd(ii,jj) = vert(row,2);
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
8270
18935
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8271 if (pervertex)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8272 for (int kk = 0; kk < fvc.columns (); kk++)
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8273 cd(ii,jj,kk) = fvc(row,kk);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8274 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8275 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8276
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8277
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8278 unwind_protect frame;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8279 frame.protect_var (updating_patch_data);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8280 updating_patch_data = true;
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8281
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8282 set_xdata (xd);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8283 set_ydata (yd);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8284 set_zdata (zd);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8285 set_cdata (cd);
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8286 }
df972b9d080a Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18926
diff changeset
8287
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
8288 // ---------------------------------------------------------------------
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
8289
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8290 octave_value
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8291 surface::properties::get_color_data (void) const
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8292 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8293 return convert_cdata (*this, get_cdata (), cdatamapping_is ("scaled"), 3);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8294 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8295
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8296 inline void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8297 cross_product (double x1, double y1, double z1,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8298 double x2, double y2, double z2,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8299 double& x, double& y, double& z)
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8300 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8301 x += (y1 * z2 - z1 * y2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8302 y += (z1 * x2 - x1 * z2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8303 z += (x1 * y2 - y1 * x2);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8304 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8305
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8306 void
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8307 surface::properties::update_normals (void)
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8308 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8309 if (normalmode_is ("auto"))
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8310 {
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8311 Matrix x = get_xdata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8312 Matrix y = get_ydata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8313 Matrix z = get_zdata ().matrix_value ();
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8314
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
8315 int p = z.columns ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
8316 int q = z.rows ();
18986
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8317
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8318 // FIXME: There might be a cleaner way to do this. When data is changed
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8319 // the update_xdata, update_ydata, update_zdata routines are called in a
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8320 // serial fashion. Until the final call to update_zdata the matrices
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8321 // will be of mismatched dimensions which can cause an out-of-bound
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8322 // indexing in the code below. This one-liner prevents calculating
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8323 // normals until dimensions match.
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8324 if (x.columns () != p || y.rows () != q)
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8325 return;
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8326
c66029adf853 Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents: 18985
diff changeset
8327 NDArray n (dim_vector (q, p, 3), 0.0);
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8328
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8329 bool x_mat = (x.rows () == q);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8330 bool y_mat = (y.columns () == p);
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8331
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
8332 int i1, i2, i3, j1, j2, j3;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
8333 i1 = i2 = i3 = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17861
diff changeset
8334 j1 = j2 = j3 = 0;
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8335
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8336 for (int i = 0; i < p; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8337 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8338 if (y_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8339 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8340 i1 = i - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8341 i2 = i;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8342 i3 = i + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8343 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8344
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8345 for (int j = 0; j < q; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8346 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8347 if (x_mat)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8348 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8349 j1 = j - 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8350 j2 = j;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8351 j3 = j + 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8352 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8353
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8354 double& nx = n(j, i, 0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8355 double& ny = n(j, i, 1);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8356 double& nz = n(j, i, 2);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8357
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8358 if ((j > 0) && (i > 0))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8359 // upper left quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8360 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8361 (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8362 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8363 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8364
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8365 if ((j > 0) && (i < (p -1)))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8366 // upper right quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8367 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8368 (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8369 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8370 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8371
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8372 if ((j < (q - 1)) && (i > 0))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8373 // lower left quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8374 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8375 (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8376 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8377 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8378
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8379 if ((j < (q - 1)) && (i < (p -1)))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8380 // lower right quadrangle
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8381 cross_product
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8382 (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8383 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
8384 nx, ny, nz);
8449
448188853722 Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents: 8341
diff changeset
8385
11450
5eb10763069f substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents: 11431
diff changeset
8386 double d = -std::max (std::max (fabs (nx), fabs (ny)), fabs (nz));
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8387
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8388 nx /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8389 ny /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8390 nz /= d;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8391 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
8392 }
7829
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8393 vertexnormals = n;
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8394 }
8ca8e97e8c0a Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7828
diff changeset
8395 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8396
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8397 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8398
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8399 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8400 hggroup::properties::update_limits (void) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8401 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8402 graphics_object go = gh_manager::get_object (__myhandle__);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8403
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8404 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8405 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8406 go.update_axis_limits ("xlim");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8407 go.update_axis_limits ("ylim");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8408 go.update_axis_limits ("zlim");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8409 go.update_axis_limits ("clim");
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8410 go.update_axis_limits ("alim");
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8411 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8412 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8413
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8414 void
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8415 hggroup::properties::update_limits (const graphics_handle& h) const
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8416 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8417 graphics_object go = gh_manager::get_object (__myhandle__);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8418
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8419 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8420 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8421 go.update_axis_limits ("xlim", h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8422 go.update_axis_limits ("ylim", h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8423 go.update_axis_limits ("zlim", h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8424 go.update_axis_limits ("clim", h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8425 go.update_axis_limits ("alim", h);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8426 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8427 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8428
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8429 static bool updating_hggroup_limits = false;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8430
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8431 void
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8432 hggroup::update_axis_limits (const std::string& axis_type,
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8433 const graphics_handle& h)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8434 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8435 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8436 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8437
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8438 Matrix kids = Matrix (1, 1, h.value ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8439
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8440 double min_val = octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8441 double max_val = -octave_Inf;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8442 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8443 double max_neg = -octave_Inf;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8444
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8445 Matrix limits;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8446 double val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8447
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8448 char update_type = 0;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8449
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8450 if (axis_type == "xlim" || axis_type == "xliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8451 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8452 limits = xproperties.get_xlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8453 update_type = 'x';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8454 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8455 else if (axis_type == "ylim" || axis_type == "yliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8456 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8457 limits = xproperties.get_ylim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8458 update_type = 'y';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8459 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8460 else if (axis_type == "zlim" || axis_type == "zliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8461 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8462 limits = xproperties.get_zlim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8463 update_type = 'z';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8464 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8465 else if (axis_type == "clim" || axis_type == "climinclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8466 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8467 limits = xproperties.get_clim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8468 update_type = 'c';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8469 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8470 else if (axis_type == "alim" || axis_type == "aliminclude")
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8471 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8472 limits = xproperties.get_alim ().matrix_value ();
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8473 update_type = 'a';
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8474 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8475
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
8476 if (limits.numel () == 4)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8477 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8478 val = limits(0);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
8479 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8480 min_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8481 val = limits(1);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
8482 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8483 max_val = val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8484 val = limits(2);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
8485 if (xfinite (val))
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8486 min_pos = val;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8487 val = limits(3);
16971
259c1f295a1e Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents: 16892
diff changeset
8488 if (xfinite (val))
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8489 max_neg = val;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8490 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8491 else
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8492 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8493 limits.resize (4, 1);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8494 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8495 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8496 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8497 limits(3) = max_neg;
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8498 }
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8499
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8500 get_children_limits (min_val, max_val, min_pos, max_neg, kids, update_type);
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8501
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8502 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8503 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8504
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8505 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8506
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8507 if (limits(0) != min_val || limits(1) != max_val
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8508 || limits(2) != min_pos || limits(3) != max_neg)
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8509 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8510 limits(0) = min_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8511 limits(1) = max_val;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8512 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8513 limits(3) = max_neg;
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8514
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8515 switch (update_type)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8516 {
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8517 case 'x':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8518 xproperties.set_xlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8519 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8520
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8521 case 'y':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8522 xproperties.set_ylim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8523 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8524
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8525 case 'z':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8526 xproperties.set_zlim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8527 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8528
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8529 case 'c':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8530 xproperties.set_clim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8531 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8532
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8533 case 'a':
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8534 xproperties.set_alim (limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8535 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8536
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8537 default:
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8538 break;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8539 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8540
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8541 base_graphics_object::update_axis_limits (axis_type, h);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8542 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8543 }
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8544
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8545 void
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8546 hggroup::update_axis_limits (const std::string& axis_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8547 {
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8548 if (updating_hggroup_limits)
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8549 return;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8550
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8551 Matrix kids = xproperties.get_children ();
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8552
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8553 double min_val = octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8554 double max_val = -octave_Inf;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8555 double min_pos = octave_Inf;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8556 double max_neg = -octave_Inf;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8557
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8558 char update_type = 0;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8559
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
8560 if (axis_type == "xlim" || axis_type == "xliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8561 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8562 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x');
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11576
diff changeset
8563
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8564 update_type = 'x';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8565 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
8566 else if (axis_type == "ylim" || axis_type == "yliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8567 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8568 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8569
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8570 update_type = 'y';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8571 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
8572 else if (axis_type == "zlim" || axis_type == "zliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8573 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8574 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8575
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8576 update_type = 'z';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8577 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
8578 else if (axis_type == "clim" || axis_type == "climinclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8579 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8580 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8581
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8582 update_type = 'c';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8583 }
8081
b1634dd9ebe7 Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents: 8075
diff changeset
8584 else if (axis_type == "alim" || axis_type == "aliminclude")
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8585 {
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8586 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a');
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8587
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8588 update_type = 'a';
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8589 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8590
11175
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8591 unwind_protect frame;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8592 frame.protect_var (updating_hggroup_limits);
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8593
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8594 updating_hggroup_limits = true;
c0a95a5c6d25 Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents: 11168
diff changeset
8595
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8596 Matrix limits (1, 4, 0.0);
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8597
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8598 limits(0) = min_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8599 limits(1) = max_val;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8600 limits(2) = min_pos;
13132
e3e8ca96f923 Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents: 13130
diff changeset
8601 limits(3) = max_neg;
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8602
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8603 switch (update_type)
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8604 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8605 case 'x':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8606 xproperties.set_xlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8607 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8608
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8609 case 'y':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8610 xproperties.set_ylim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8611 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8612
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8613 case 'z':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8614 xproperties.set_zlim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8615 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8616
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8617 case 'c':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8618 xproperties.set_clim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8619 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8620
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8621 case 'a':
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8622 xproperties.set_alim (limits);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8623 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8624
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8625 default:
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8626 break;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8627 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8628
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8629 base_graphics_object::update_axis_limits (axis_type);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8630 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8631
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8632 // ---------------------------------------------------------------------
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
8633
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8634 uicontextmenu::~uicontextmenu (void)
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20207
diff changeset
8635 {
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8636 std::list<graphics_handle> lst = xproperties.get_dependent_obj_list ();
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8637 std::list<graphics_handle>::const_iterator it;
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20207
diff changeset
8638
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8639 for (it = lst.begin (); it != lst.end (); it++)
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8640 {
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8641 graphics_object go = gh_manager::get_object (*it);
20216
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20207
diff changeset
8642
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8643 if (go.valid_object () &&
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8644 go.get ("uicontextmenu") == xproperties.get___myhandle__ ())
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8645 go.set ("uicontextmenu", Matrix ());
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8646 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8647 }
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8648
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8649
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8650 /*
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8651 ## Test deletion/reset of uicontextmenu
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8652 %!test
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8653 %! hf = figure ("visible", "off");
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8654 %! hax = axes ("parent", hf);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8655 %! unwind_protect
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8656 %! hctx1 = uicontextmenu ("parent", hf);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8657 %! hctx2 = uicontextmenu ("parent", hf);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8658 %! set (hf, "uicontextmenu", hctx2);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8659 %! set (hax, "uicontextmenu", hctx2);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8660 %! assert (get (hf, "uicontextmenu"), hctx2);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8661 %! assert (get (hax, "uicontextmenu"), hctx2);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8662 %! assert (get (hf, "children"), [hctx2; hctx1; hax]);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8663 %! delete (hctx2);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8664 %! assert (get (hf, "uicontextmenu"), []);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8665 %! assert (get (hax, "uicontextmenu"), []);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8666 %! assert (get (hf, "children"), [hctx1; hax]);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8667 %! set (hf, "uicontextmenu", hctx1);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8668 %! assert (get (hf, "uicontextmenu"), hctx1);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8669 %! set (hf, "uicontextmenu", []);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8670 %! assert (get (hf, "uicontextmenu"), []);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8671 %! assert (get (hf, "children"), [hctx1; hax]);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8672 %! unwind_protect_cleanup
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8673 %! close (hf);
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8674 %! end_unwind_protect;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8675 */
20112
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8676
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8677 // ---------------------------------------------------------------------
69f92e0affd2 Handle uicontextmenu deletion/reset (bug #44801)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20086
diff changeset
8678
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8679 octave_value
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8680 uicontrol::properties::get_extent (void) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8681 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8682 Matrix m = extent.get ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8683
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8684 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8685 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8686 Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8687
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8688 return convert_position (m, "pixels", get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8689 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8690
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8691 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8692 uicontrol::properties::update_text_extent (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8693 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8694 #ifdef HAVE_FREETYPE
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8695
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8696 text_element *elt;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8697 ft_render text_renderer;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8698 Matrix box;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8699
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8700 // FIXME: parsed content should be cached for efficiency
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8701 // FIXME: support multiline text
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8702
17269
5b088598df1d Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17260
diff changeset
8703 elt = text_parser::parse (get_string_string (), "none");
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8704 #ifdef HAVE_FONTCONFIG
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8705 text_renderer.set_font (get_fontname (),
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8706 get_fontweight (),
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8707 get_fontangle (),
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8708 get_fontsize ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8709 #endif
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8710 box = text_renderer.get_extent (elt, 0);
17192
755ec7bce733 corefcn/graphics.cc: Fix memory leak in uicontrol::properties::update_text_extent.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17150
diff changeset
8711 delete elt;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8712
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8713 Matrix ext (1, 4);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8714
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8715 // FIXME: also handle left and bottom components
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8716
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8717 ext(0) = ext(1) = 1;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8718 ext(2) = box(0);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8719 ext(3) = box(1);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8720
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8721 set_extent (ext);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8722
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8723 #endif
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8724 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8725
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8726 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8727 uicontrol::properties::update_units (void)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8728 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8729 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8730
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8731 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8732 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8733 Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8734
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8735 pos = convert_position (pos, cached_units, get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8736 set_position (pos);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8737
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8738 cached_units = get_units ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8739 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8740
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8741 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8742 uicontrol::properties::set_style (const octave_value& st)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8743 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
8744 if (get___object__ ().is_empty ())
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8745 style = st;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8746 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8747 error ("set: cannot change the style of a uicontrol object after creation.");
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8748 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8749
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8750 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8751 uicontrol::properties::get_boundingbox (bool,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8752 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8753 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8754 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8755 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8756
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8757 if (parent_size.is_empty ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8758 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8759 graphics_object go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8760
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8761 if (go.valid_object ())
17608
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
8762 parent_size =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8763 go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
17608
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
8764 else
e7692efcbd0d graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17607
diff changeset
8765 parent_size = default_figure_position ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8766 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8767
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8768 pos = convert_position (pos, get_units (), "pixels", parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8769
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8770 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8771 pos(1)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8772 pos(1) = parent_size(1) - pos(1) - pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8773
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8774 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8775 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8776
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8777 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8778 uicontrol::properties::set_fontunits (const octave_value& val)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8779 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8780 caseless_str old_fontunits = get_fontunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8781
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8782 if (fontunits.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8783 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8784 update_fontunits (old_fontunits);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8785 mark_modified ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8786 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8787 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8788
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8789 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8790 uicontrol::properties::update_fontunits (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8791 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8792 caseless_str new_units = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8793 double parent_height = get_boundingbox (false).elem (3);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8794 double fontsz = get_fontsize ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8795
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8796 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8797
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8798 fontsize.set (octave_value (fontsz), true);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8799 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8800
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8801 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8802 uicontrol::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8803 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8804 double fontsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8805 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8806
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8807 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
8808 parent_height = get_boundingbox (false).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8809
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8810 return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8811 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8812
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8813 // ---------------------------------------------------------------------
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8814
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8815 Matrix
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8816 uipanel::properties::get_boundingbox (bool internal,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8817 const Matrix& parent_pix_size) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8818 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8819 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8820 Matrix parent_size (parent_pix_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8821
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8822 if (parent_size.is_empty ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8823 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8824 graphics_object go = gh_manager::get_object (get_parent ());
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8825
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8826 parent_size =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8827 go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8828 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8829
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8830 pos = convert_position (pos, get_units (), "pixels", parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8831
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8832 pos(0)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8833 pos(1)--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8834 pos(1) = parent_size(1) - pos(1) - pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8835
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8836 if (internal)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8837 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8838 double outer_height = pos(3);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8839
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8840 pos(0) = pos(1) = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8841
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8842 if (! bordertype_is ("none"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8843 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8844 double bw = get_borderwidth ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8845 double mul = 1.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8846
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8847 if (bordertype_is ("etchedin") || bordertype_is ("etchedout"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8848 mul = 2.0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8849
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8850 pos(0) += mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8851 pos(1) += mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8852 pos(2) -= 2 * mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8853 pos(3) -= 2 * mul * bw;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8854 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8855
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8856 if (! get_title ().empty ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8857 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8858 double fontsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8859
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8860 if (! fontunits_is ("pixels"))
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8861 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8862 double res = xget (0, "screenpixelsperinch").double_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8863
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8864 if (fontunits_is ("points"))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8865 fontsz *= (res / 72.0);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8866 else if (fontunits_is ("inches"))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8867 fontsz *= res;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8868 else if (fontunits_is ("centimeters"))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8869 fontsz *= (res / 2.54);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8870 else if (fontunits_is ("normalized"))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8871 fontsz *= outer_height;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8872 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8873
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8874 if (titleposition_is ("lefttop") || titleposition_is ("centertop")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8875 || titleposition_is ("righttop"))
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8876 pos(1) += (fontsz / 2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8877 pos(3) -= (fontsz / 2);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8878 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8879 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8880
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8881 return pos;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8882 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8883
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8884 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8885 uipanel::properties::set_units (const octave_value& val)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8886 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8887 caseless_str old_units = get_units ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8888
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8889 if (units.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8890 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8891 update_units (old_units);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8892 mark_modified ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8893 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8894 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8895
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8896 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8897 uipanel::properties::update_units (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8898 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8899 Matrix pos = get_position ().matrix_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8900
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8901 graphics_object parent_go = gh_manager::get_object (get_parent ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8902 Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8903 Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
8904
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8905 pos = convert_position (pos, old_units, get_units (), parent_size);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8906 set_position (pos);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8907 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8908
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8909 void
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8910 uipanel::properties::set_fontunits (const octave_value& val)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8911 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8912 caseless_str old_fontunits = get_fontunits ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8913
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8914 if (fontunits.set (val, true))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8915 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8916 update_fontunits (old_fontunits);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
8917 mark_modified ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8918 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8919 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8920
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8921 void
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8922 uipanel::properties::update_fontunits (const caseless_str& old_units)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8923 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8924 caseless_str new_units = get_fontunits ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8925 double parent_height = get_boundingbox (false).elem (3);
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8926 double fontsz = get_fontsize ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8927
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8928 fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8929
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8930 set_fontsize (octave_value (fontsz));
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8931 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8932
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8933 double
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8934 uipanel::properties::get_fontsize_points (double box_pix_height) const
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8935 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8936 double fontsz = get_fontsize ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8937 double parent_height = box_pix_height;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8938
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8939 if (fontunits_is ("normalized") && parent_height <= 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
8940 parent_height = get_boundingbox (false).elem (3);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8941
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8942 return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8943 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8944
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8945 // ---------------------------------------------------------------------
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8946
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8947 octave_value
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8948 uitoolbar::get_default (const caseless_str& pname) const
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8949 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8950 octave_value retval = default_properties.lookup (pname);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8951
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8952 if (retval.is_undefined ())
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8953 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8954 graphics_handle parent_h = get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8955 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8956
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8957 retval = parent_go.get_default (pname);
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8958 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8959
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8960 return retval;
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8961 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8962
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8963 void
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8964 uitoolbar::reset_default_properties (void)
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8965 {
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
8966 // empty list of local defaults
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
8967 default_properties = property_list ();
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
8968
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8969 xreset_default_properties (get_handle (), xproperties.factory_defaults ());
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8970 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8971
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8972 // ---------------------------------------------------------------------
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8973
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
8974 octave_value
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8975 base_graphics_object::get_default (const caseless_str& pname) const
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8976 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8977 graphics_handle parent_h = get_parent ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8978 graphics_object parent_go = gh_manager::get_object (parent_h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8979
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8980 return parent_go.get_default (type () + pname);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8981 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8982
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8983 octave_value
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7176
diff changeset
8984 base_graphics_object::get_factory_default (const caseless_str& name) const
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8985 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8986 graphics_object parent_go = gh_manager::get_object (0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8987
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
8988 return parent_go.get_factory_default (type () + name);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8989 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8990
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
8991 // We use a random value for the handle to avoid issues with plots and
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
8992 // scalar values for the first argument.
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8993 gh_manager::gh_manager (void)
7286
c0c6aa5afff4 [project @ 2007-12-11 16:52:56 by jwe]
jwe
parents: 7283
diff changeset
8994 : handle_map (), handle_free_list (),
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
8995 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)),
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8996 figure_list (), graphics_lock (), event_queue (),
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
8997 callback_objects (), event_processing (0)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8998 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
8999 handle_map[0] = graphics_object (new root_figure ());
7847
40b16e04172a Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7844
diff changeset
9000
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9001 // Make sure the default graphics toolkit is registered.
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
9002 gtk_manager::default_toolkit ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9003 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9004
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9005 void
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9006 gh_manager::create_instance (void)
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9007 {
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9008 instance = new gh_manager ();
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9009
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
9010 if (instance)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14006
diff changeset
9011 singleton_cleanup_list::add (cleanup_instance);
13992
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9012 }
e1f76bfe0452 apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents: 13955
diff changeset
9013
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9014 graphics_handle
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9015 gh_manager::do_make_graphics_handle (const std::string& go_name,
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9016 const graphics_handle& p,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9017 bool integer_figure_handle,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9018 bool do_createfcn,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9019 bool do_notify_toolkit)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9020 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
9021 graphics_handle h = get_handle (integer_figure_handle);
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9022
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9023 base_graphics_object *bgo = 0;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9024
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9025 bgo = make_graphics_object_from_type (go_name, h, p);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9026
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9027 if (bgo)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9028 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9029 graphics_object go (bgo);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9030
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9031 handle_map[h] = go;
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9032
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9033 // Overriding defaults will work now because the handle is valid
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9034 // and we can find parent objects (not just handles).
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9035 go.override_defaults ();
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9036
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9037 if (go_name == "axes")
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9038 {
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9039 // Handle defaults for labels since overriding defaults for
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9040 // them can't work before the axes object is fully
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9041 // constructed.
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9042
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9043 axes::properties& props =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9044 dynamic_cast<axes::properties&> (go.get_properties ());
20086
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9045
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9046 graphics_object tgo;
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9047
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9048 tgo = gh_manager::get_object (props.get_xlabel ());
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9049 tgo.override_defaults ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9050
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9051 tgo = gh_manager::get_object (props.get_ylabel ());
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9052 tgo.override_defaults ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9053
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9054 tgo = gh_manager::get_object (props.get_zlabel ());
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9055 tgo.override_defaults ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9056
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9057 tgo = gh_manager::get_object (props.get_title ());
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9058 tgo.override_defaults ();
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9059 }
10600b2dd3c1 make units other than data work for axes labels and title (bug #35857)
John W. Eaton <jwe@octave.org>
parents: 20082
diff changeset
9060
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
9061 if (do_createfcn)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9062 bgo->get_properties ().execute_createfcn ();
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
9063
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9064 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9065 if (do_notify_toolkit)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9066 go.initialize ();
7370
74d64ead0cd7 [project @ 2008-01-14 19:12:45 by jwe]
jwe
parents: 7367
diff changeset
9067 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9068 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
9069 error ("gh_manager::do_make_graphics_handle: invalid object type '%s'",
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9070 go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9071
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9072 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9073 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9074
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9075 graphics_handle
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9076 gh_manager::do_make_figure_handle (double val, bool do_notify_toolkit)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9077 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9078 graphics_handle h = val;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9079
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9080 base_graphics_object* bgo = new figure (h, 0);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9081 graphics_object go (bgo);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9082
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9083 handle_map[h] = go;
8058
ca39c21fa4b8 [mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents: 8052
diff changeset
9084
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
9085 // Notify graphics toolkit.
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9086 if (do_notify_toolkit)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9087 go.initialize ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9088
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9089 go.override_defaults ();
20118
ade6e5ae6164 Stop unexpected switches between graphic toolkits (bug #44838).
Pantxo <pantxo.diribarne@gmail.com>
parents: 20112
diff changeset
9090
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9091 return h;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9092 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9093
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9094 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9095 gh_manager::do_push_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9096 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9097 do_pop_figure (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9098
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9099 figure_list.push_front (h);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9100 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9101
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9102 void
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9103 gh_manager::do_pop_figure (const graphics_handle& h)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9104 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9105 for (figure_list_iterator p = figure_list.begin ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9106 p != figure_list.end ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9107 p++)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9108 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9109 if (*p == h)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9110 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9111 figure_list.erase (p);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9112 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9113 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9114 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9115 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9116
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9117 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9118 callback_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9119 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9120 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9121 callback_event (const graphics_handle& h, const std::string& name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9122 const octave_value& data = Matrix ())
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9123 : base_graphics_event (), handle (h), callback_name (name),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9124 callback (), callback_data (data) { }
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
9125
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9126 callback_event (const graphics_handle& h, const octave_value& cb,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9127 const octave_value& data = Matrix ())
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9128 : base_graphics_event (), handle (h), callback_name (),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9129 callback (cb), callback_data (data) { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9130
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9131 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9132 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9133 if (callback.is_defined ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9134 gh_manager::execute_callback (handle, callback, callback_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9135 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9136 gh_manager::execute_callback (handle, callback_name, callback_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9137 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9138
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9139 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9140 callback_event (void)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9141 : base_graphics_event (), handle (), callback_name (), callback_data ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9142 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9143
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9144 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9145 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9146 std::string callback_name;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9147 octave_value callback;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9148 octave_value callback_data;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9149 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9150
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9151 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9152 function_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9153 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9154 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9155 function_event (graphics_event::event_fcn fcn, void* data = 0)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9156 : base_graphics_event (), function (fcn), function_data (data)
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9157 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9158
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9159 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9160 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9161 function (function_data);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9162 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9163
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9164 private:
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
9165
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9166 graphics_event::event_fcn function;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9167
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9168 void* function_data;
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9169
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9170 // function_event objects must be created with at least a function.
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9171 function_event (void);
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9172
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9173 // No copying!
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9174
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9175 function_event (const function_event&);
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9176
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9177 function_event & operator = (const function_event&);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9178 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9179
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9180 class
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9181 set_event : public base_graphics_event
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9182 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9183 public:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9184 set_event (const graphics_handle& h, const std::string& name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9185 const octave_value& value, bool do_notify_toolkit = true)
17652
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9186 : base_graphics_event (), handle (h), property_name (name),
57750dc54ab6 maint: Correct indentation in graphics.cc, graphics.in.h. No code changes.
Rik <rik@octave.org>
parents: 17641
diff changeset
9187 property_value (value), notify_toolkit (do_notify_toolkit) { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9188
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9189 void execute (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9190 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9191 gh_manager::auto_lock guard;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9192
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9193 graphics_object go = gh_manager::get_object (handle);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9194
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9195 if (go)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9196 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9197 property p = go.get_properties ().get_property (property_name);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9198
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9199 if (p.ok ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9200 p.set (property_value, true, notify_toolkit);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9201 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9202 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9203
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9204 private:
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9205 set_event (void)
12174
db1f49eaba6b whitespace fixes
John W. Eaton <jwe@octave.org>
parents: 12164
diff changeset
9206 : base_graphics_event (), handle (), property_name (), property_value ()
12164
18e9a8da7d18 eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 12159
diff changeset
9207 { }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9208
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9209 private:
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9210 graphics_handle handle;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9211 std::string property_name;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9212 octave_value property_value;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9213 bool notify_toolkit;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9214 };
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9215
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9216 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9217 graphics_event::create_callback_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9218 const std::string& name,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9219 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9220 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9221 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9222
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9223 e.rep = new callback_event (h, name, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9224
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9225 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9226 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9227
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9228 graphics_event
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9229 graphics_event::create_callback_event (const graphics_handle& h,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9230 const octave_value& cb,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9231 const octave_value& data)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9232 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9233 graphics_event e;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9234
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9235 e.rep = new callback_event (h, cb, data);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9236
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9237 return e;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9238 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9239
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9240 graphics_event
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9241 graphics_event::create_function_event (graphics_event::event_fcn fcn,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9242 void *data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9243 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9244 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9245
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9246 e.rep = new function_event (fcn, data);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9247
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9248 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9249 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9250
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9251 graphics_event
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9252 graphics_event::create_set_event (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9253 const std::string& name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9254 const octave_value& data,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9255 bool notify_toolkit)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9256 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9257 graphics_event e;
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9258
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9259 e.rep = new set_event (h, name, data, notify_toolkit);
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9260
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9261 return e;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9262 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9263
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9264 static void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9265 xset_gcbo (const graphics_handle& h)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9266 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9267 graphics_object go = gh_manager::get_object (0);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9268 root_figure::properties& props =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9269 dynamic_cast<root_figure::properties&> (go.get_properties ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9270
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9271 props.set_callbackobject (h.as_octave_value ());
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9272 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9273
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9274 void
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9275 gh_manager::do_restore_gcbo (void)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9276 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9277 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9278
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9279 callback_objects.pop_front ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9280
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9281 xset_gcbo (callback_objects.empty ()
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9282 ? graphics_handle () : callback_objects.front ().get_handle ());
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9283 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9284
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9285 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9286 gh_manager::do_execute_listener (const graphics_handle& h,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9287 const octave_value& l)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9288 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9289 if (octave_thread::is_octave_thread ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9290 gh_manager::execute_callback (h, l, octave_value ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9291 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9292 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9293 gh_manager::auto_lock guard;
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
9294
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9295 do_post_event (graphics_event::create_callback_event (h, l));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9296 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9297 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9298
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9299 void
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9300 gh_manager::do_execute_callback (const graphics_handle& h,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9301 const octave_value& cb_arg,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9302 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9303 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9304 if (cb_arg.is_defined () && ! cb_arg.is_empty ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9305 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9306 octave_value_list args;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9307 octave_function *fcn = 0;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9308
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9309 args(0) = h.as_octave_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9310 if (data.is_defined ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9311 args(1) = data;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9312 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9313 args(1) = Matrix ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9314
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9315 unwind_protect_safe frame;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9316 frame.add_fcn (gh_manager::restore_gcbo);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9317
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9318 if (true)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9319 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9320 gh_manager::auto_lock guard;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9321
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9322 callback_objects.push_front (get_object (h));
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9323 xset_gcbo (h);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9324 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9325
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9326 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9327
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9328 // Copy CB because "function_value" method is non-const.
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9329
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9330 octave_value cb = cb_arg;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9331
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
9332 if (cb.is_function () || cb.is_function_handle ())
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9333 fcn = cb.function_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9334 else if (cb.is_string ())
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9335 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9336 int status;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9337 std::string s = cb.string_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9338
13940
bf209050014f Use nargout = 0 in graphics callbacks specified as string.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13935
diff changeset
9339 eval_string (s, false, status, 0);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9340 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9341 else if (cb.is_cell () && cb.length () > 0
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9342 && (cb.rows () == 1 || cb.columns () == 1)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
9343 && (cb.cell_value ()(0).is_function ()
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
9344 || cb.cell_value ()(0).is_function_handle ()))
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9345 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9346 Cell c = cb.cell_value ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9347
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9348 fcn = c(0).function_value ();
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9349
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9350 for (int i = 1; i < c.numel () ; i++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9351 args(1+i) = c(i);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9352 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9353 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9354 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9355 std::string nm = cb.class_name ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9356 error ("trying to execute non-executable object (class = %s)",
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9357 nm.c_str ());
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9358 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9359
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9360 if (fcn)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9361 feval (fcn, args);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9362
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9363 END_INTERRUPT_WITH_EXCEPTIONS;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9364 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9365 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9366
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9367 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9368 gh_manager::do_post_event (const graphics_event& e)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9369 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9370 event_queue.push_back (e);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9371
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9372 command_editor::add_event_hook (gh_manager::process_events);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9373 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9374
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9375 void
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9376 gh_manager::do_post_callback (const graphics_handle& h, const std::string& name,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9377 const octave_value& data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9378 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9379 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9380
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9381 graphics_object go = get_object (h);
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9382
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9383 if (go.valid_object ())
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9384 {
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9385 if (callback_objects.empty ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9386 do_post_event (graphics_event::create_callback_event (h, name, data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9387 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9388 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9389 const graphics_object& current = callback_objects.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9390
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9391 if (current.get_properties ().is_interruptible ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9392 do_post_event (graphics_event::create_callback_event (h, name,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9393 data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9394 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9395 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9396 caseless_str busy_action (go.get_properties ().get_busyaction ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9397
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9398 if (busy_action.compare ("queue"))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9399 do_post_event (graphics_event::create_callback_event (h, name,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9400 data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9401 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9403 caseless_str cname (name);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9404
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9405 if (cname.compare ("deletefcn") || cname.compare ("createfcn")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9406 || (go.isa ("figure")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9407 && (cname.compare ("closerequestfcn")
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9408 || cname.compare ("resizefcn"))))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9409 do_post_event (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9410 graphics_event::create_callback_event (h, name, data));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9411 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9412 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9413 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9414 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9415 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9416
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9417 void
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9418 gh_manager::do_post_function (graphics_event::event_fcn fcn, void* fcn_data)
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9419 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9420 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9421
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9422 do_post_event (graphics_event::create_function_event (fcn, fcn_data));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9423 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9424
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9425 void
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9426 gh_manager::do_post_set (const graphics_handle& h, const std::string& name,
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9427 const octave_value& value, bool notify_toolkit)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9428 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9429 gh_manager::auto_lock guard;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9430
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9431 do_post_event (graphics_event::create_set_event (h, name, value,
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9432 notify_toolkit));
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9433 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9434
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9435 int
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9436 gh_manager::do_process_events (bool force)
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9437 {
7964
9cd3ee5298a0 Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents: 7936
diff changeset
9438 graphics_event e;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9439 bool old_Vdrawnow_requested = Vdrawnow_requested;
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9440 bool events_executed = false;
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9441
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9442 do
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9443 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9444 e = graphics_event ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9445
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9446 gh_manager::lock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9447
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9448 if (! event_queue.empty ())
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9449 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9450 if (callback_objects.empty () || force)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9451 {
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9452 e = event_queue.front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9453
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9454 event_queue.pop_front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9455 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9456 else
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9457 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9458 const graphics_object& go = callback_objects.front ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9459
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9460 if (go.get_properties ().is_interruptible ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9461 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9462 e = event_queue.front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9463
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9464 event_queue.pop_front ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9465 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9466 }
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9467 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9468
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9469 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9470
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9471 if (e.ok ())
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9472 {
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9473 e.execute ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9474 events_executed = true;
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9475 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9476 }
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9477 while (e.ok ());
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9478
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9479 gh_manager::lock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9480
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9481 if (event_queue.empty () && event_processing == 0)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9482 command_editor::remove_event_hook (gh_manager::process_events);
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9483
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9484 gh_manager::unlock ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9485
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9486 if (events_executed)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9487 flush_octave_stdout ();
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9488
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9489 if (Vdrawnow_requested && ! old_Vdrawnow_requested)
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9490 {
15423
53d073233fa4 call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents: 15220
diff changeset
9491 Fdrawnow ();
13935
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9492
e48e8253ce58 Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13929
diff changeset
9493 Vdrawnow_requested = false;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9494 }
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9495
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9496 return 0;
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9497 }
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9498
13908
32a77debff75 strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents: 13897
diff changeset
9499 void
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9500 gh_manager::do_enable_event_processing (bool enable)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9501 {
13736
deb69dab4514 Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13713
diff changeset
9502 gh_manager::auto_lock guard;
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9503
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9504 if (enable)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9505 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9506 event_processing++;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9507
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9508 command_editor::add_event_hook (gh_manager::process_events);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9509 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9510 else
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9511 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9512 event_processing--;
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9513
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9514 if (event_queue.empty () && event_processing == 0)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9515 command_editor::remove_event_hook (gh_manager::process_events);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9516 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9517 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9518
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9519 property_list::plist_map_type
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9520 root_figure::init_factory_properties (void)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9521 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9522 property_list::plist_map_type plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9523
6844
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9524 plist_map["figure"] = figure::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9525 plist_map["axes"] = axes::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9526 plist_map["line"] = line::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9527 plist_map["text"] = text::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9528 plist_map["image"] = image::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9529 plist_map["patch"] = patch::properties::factory_defaults ();
9ac351b05b51 [project @ 2007-08-30 00:46:23 by jwe]
jwe
parents: 6841
diff changeset
9530 plist_map["surface"] = surface::properties::factory_defaults ();
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
9531 plist_map["hggroup"] = hggroup::properties::factory_defaults ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
9532 plist_map["uimenu"] = uimenu::properties::factory_defaults ();
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9533 plist_map["uicontrol"] = uicontrol::properties::factory_defaults ();
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9534 plist_map["uipanel"] = uipanel::properties::factory_defaults ();
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9535 plist_map["uicontextmenu"] = uicontextmenu::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9536 plist_map["uitoolbar"] = uitoolbar::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9537 plist_map["uipushtool"] = uipushtool::properties::factory_defaults ();
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
9538 plist_map["uitoggletool"] = uitoggletool::properties::factory_defaults ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9539
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9540 return plist_map;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9541 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9542
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9543 // ---------------------------------------------------------------------
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9544
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9545 DEFUN (ishandle, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9546 "-*- texinfo -*-\n\
6678
49724abe1236 [project @ 2007-05-31 19:44:45 by jwe]
jwe
parents: 6595
diff changeset
9547 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9548 Return true if @var{h} is a graphics handle and false otherwise.\n\
17123
bcada0a4f8a7 isaxes.m: New function to determine if object is axes handle.
Rik <rik@octave.org>
parents: 17098
diff changeset
9549 \n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9550 @var{h} may also be a matrix of handles in which case a logical array is\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9551 returned that is true where the elements of @var{h} are graphics handles and\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9552 false where they are not.\n\
17123
bcada0a4f8a7 isaxes.m: New function to determine if object is axes handle.
Rik <rik@octave.org>
parents: 17098
diff changeset
9553 @seealso{isaxes, isfigure}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9554 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9555 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9556 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9557
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9558 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9559
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9560 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9561 retval = is_handle (args(0));
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9562 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9563 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9564
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9565 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9566 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9567
13327
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9568 static bool
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9569 is_handle_visible (const graphics_handle& h)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9570 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9571 return h.ok () && gh_manager::is_handle_visible (h);
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9572 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9573
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9574 static bool
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9575 is_handle_visible (double val)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9576 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9577 return is_handle_visible (gh_manager::lookup (val));
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9578 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9579
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9580 static octave_value
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9581 is_handle_visible (const octave_value& val)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9582 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9583 octave_value retval = false;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9584
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9585 if (val.is_real_scalar () && is_handle_visible (val.double_value ()))
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9586 retval = true;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9587 else if (val.is_numeric_type () && val.is_real_type ())
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9588 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9589 const NDArray handles = val.array_value ();
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9590
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9591 boolNDArray result (handles.dims ());
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9592
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9593 for (octave_idx_type i = 0; i < handles.numel (); i++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9594 result.xelem (i) = is_handle_visible (handles(i));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9595
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9596 retval = result;
13327
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9597 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9598
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9599 return retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9600 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9601
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9602 DEFUN (__is_handle_visible__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9603 "-*- texinfo -*-\n\
19186
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19121
diff changeset
9604 @deftypefn {Built-in Function} {} __is_handle_visible__ (@var{h})\n\
13327
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9605 Undocumented internal function.\n\
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9606 @end deftypefn")
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9607 {
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9608 octave_value retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9609
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9610 if (args.length () == 1)
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9611 retval = is_handle_visible (args(0));
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9612 else
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9613 print_usage ();
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9614
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9615 return retval;
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9616 }
f81fcceb394c axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents: 13324
diff changeset
9617
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9618 DEFUN (reset, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9619 "-*- texinfo -*-\n\
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9620 @deftypefn {Built-in Function} {} reset (@var{h})\n\
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9621 Reset the properties of the graphic object @var{h} to their default values.\n\
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9622 \n\
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9623 For figures, the properties @qcode{\"position\"}, @qcode{\"units\"},\n\
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9624 @qcode{\"windowstyle\"}, and @qcode{\"paperunits\"} are not affected.\n\
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9625 For axes, the properties @qcode{\"position\"} and @qcode{\"units\"} are\n\
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9626 not affected.\n\
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9627 \n\
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9628 The input @var{h} may also be a vector of graphic handles in which case\n\
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9629 each individual object will be reset.\n\
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9630 @seealso{cla, clf, newplot}\n\
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9631 @end deftypefn")
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9632 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9633 int nargin = args.length ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9634
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9635 if (nargin != 1)
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9636 print_usage ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9637 else
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9638 {
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9639 // get vector of graphics handles
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9640 ColumnVector hcv (args(0).vector_value ());
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9641
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9642 // loop over graphics objects
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9643 for (octave_idx_type n = 0; n < hcv.numel (); n++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9644 gh_manager::get_object (hcv(n)).reset_default_properties ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9645
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9646 Fdrawnow ();
10722
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9647 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9648
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9649 return octave_value ();
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9650 }
755fcb5baad3 Add the reset built function
David Bateman <dbateman@free.fr>
parents: 10717
diff changeset
9651
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9652 /*
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9653
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9654 %!test # line object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9655 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9656 %! unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9657 %! tol = 20 * eps;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9658 %! hax = axes ("defaultlinelinewidth", 3);
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9659 %!
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9660 %! hli = line (1:10, 1:10, 1:10, "marker", "o",
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9661 %! "markerfacecolor", "b", "linestyle", ":");
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9662 %!
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9663 %! reset (hli);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9664 %! assert (get (hli, "marker"), get (0, "defaultlinemarker"));
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9665 %! assert (get (hli, "markerfacecolor"),
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9666 %! get (0, "defaultlinemarkerfacecolor"));
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9667 %! assert (get (hli, "linestyle"),
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9668 %! get (0, "defaultlinelinestyle"));
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9669 %! assert (get (hli, "linewidth"), 3, tol); # parent axes defaults
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9670 %!
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9671 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9672 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9673 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9674
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9675 %!test # patch object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9676 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9677 %! unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9678 %! tol = 20 * eps;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9679 %! t1 = (1/16:1/8:1)' * 2*pi;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9680 %! t2 = ((1/16:1/16:1)' + 1/32) * 2*pi;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9681 %! x1 = sin (t1) - 0.8;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9682 %! y1 = cos (t1);
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9683 %! x2 = sin (t2) + 0.8;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9684 %! y2 = cos (t2);
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9685 %! vert = [x1, y1; x2, y2];
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9686 %! fac = [1:8,NaN(1,8);9:24];
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9687 %! hpa = patch ("Faces",fac, "Vertices",vert, "FaceColor","r");
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9688 %!
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9689 %! reset (hpa);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9690 %! assert (get (hpa, "faces"), get (0, "defaultpatchfaces"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9691 %! assert (get (hpa, "vertices"), get (0, "defaultpatchvertices"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9692 %! assert (get (hpa, "facevertexcdata"),
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9693 %! get (0, "defaultpatchfacevertexcdata"), tol);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9694 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9695 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9696 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9697
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9698 %!test # surface object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9699 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9700 %! unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9701 %! tol = 20 * eps;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9702 %! hsu = surface (peaks, "edgecolor", "none");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9703 %!
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9704 %! reset (hsu);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9705 %! assert (get (hsu, "xdata"), get (0, "defaultsurfacexdata"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9706 %! assert (get (hsu, "ydata"), get (0, "defaultsurfaceydata"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9707 %! assert (get (hsu, "zdata"), get (0, "defaultsurfacezdata"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9708 %! assert (get (hsu, "edgecolor"),
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9709 %! get (0, "defaultsurfaceedgecolor"), tol);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9710 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9711 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9712 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9713
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9714 %!test # image object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9715 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9716 %! unwind_protect
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9717 %! tol = 20 * eps;
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9718 %! him = image (rand (10,10), "cdatamapping", "scaled");
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9719 %!
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9720 %! reset (him);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9721 %! assert (get (him, "cdata"), get (0, "defaultimagecdata"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9722 %! assert (get (him, "cdatamapping"),
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9723 %! get (0, "defaultimagecdatamapping"), tol);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9724 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9725 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9726 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9727
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9728 %!test # text object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9729 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9730 %! unwind_protect
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9731 %! tol = 20 * eps;
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9732 %! hte = text (5, 5, "Hi!", "fontsize", 20 ,"color", "r");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9733 %!
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9734 %! reset (hte);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9735 %! assert (get (hte, "position"), get (0, "defaulttextposition"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9736 %! assert (get (hte, "fontsize"), get (0, "defaulttextfontsize"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9737 %! assert (get (hte, "color"), get (0, "defaulttextcolor"), tol);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9738 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9739 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9740 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9741
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9742 %!test # axes object
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9743 %! hf = figure ("visible", "off");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9744 %! unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9745 %! tol = 20 * eps;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9746 %! pos = get (0, "defaultaxesposition") * .5;
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9747 %! hax = axes ("linewidth", 2, "position", pos);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9748 %! title ("Reset me, please!");
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9749 %!
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9750 %! reset (hax);
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9751 %! assert (get (hax, "linewidth"), get (0, "defaultaxeslinewidth"), tol);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9752 %! assert (get (hax, "position"), pos, tol); # axes position is unchanged
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9753 %! assert (get (hax, "default"), struct ()); # no more axes' defaults
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9754 %! assert (get (get (hax, "title"), "string"), "");
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9755 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9756 %! close (hf);
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9757 %! end_unwind_protect
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9758
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9759 %!test # root figure object
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9760 %! set (0, "defaultfigurevisible", "off");
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9761 %! hf = figure ("visible", "off", "paperunits", "centimeters",
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9762 %! "papertype", "a4");
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9763 %! unwind_protect
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9764 %! reset (hf);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9765 %! assert (get (hf, "papertype"), get (0, "defaultfigurepapertype"));
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9766 %! assert (get (hf, "paperunits"), "centimeters"); # paperunits is unchanged
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9767 %! assert (get (hf, "visible"), get (0, "defaultfigurevisible"));
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9768 %! unwind_protect_cleanup
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9769 %! close (hf);
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9770 %! set (0, "defaultfigurevisible", "remove");
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9771 %! end_unwind_protect
18998
a0c514c243f6 maint: Use Octave coding conventions for %!test in graphics.cc.
Rik <rik@octave.org>
parents: 18997
diff changeset
9772
18997
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9773 */
a30e1d20fd3c Freset: properly reset graphics objects (bug #35511)
pantxo <pantxo.diribarne@gmail.com>
parents: 18996
diff changeset
9774
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9775 DEFUN (set, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9776 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
9777 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9778 @deftypefnx {Built-in Function} {} set (@var{h}, @var{properties}, @var{values})\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9779 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\
18576
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9780 @deftypefnx {Built-in Function} {@var{value_list} =} set (@var{h}, @var{property})\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9781 @deftypefnx {Built-in Function} {@var{all_value_list} =} set (@var{h})\n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9782 Set named property values for the graphics handle (or vector of graphics\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9783 handles) @var{h}.\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9784 \n\
18576
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9785 There are three ways to give the property names and values:\n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9786 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9787 @itemize\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9788 @item as a comma separated list of @var{property}, @var{value} pairs\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9789 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9790 Here, each @var{property} is a string containing the property name, each\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9791 @var{value} is a value of the appropriate type for the property.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
9792 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9793 @item as a cell array of strings @var{properties} containing property names\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9794 and a cell array @var{values} containing property values.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9795 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9796 In this case, the number of columns of @var{values} must match the number of\n\
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9797 elements in @var{properties}. The first column of @var{values} contains\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9798 values for the first entry in @var{properties}, etc. The number of rows of\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9799 @var{values} must be 1 or match the number of elements of @var{h}. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9800 first case, each handle in @var{h} will be assigned the same values. In the\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9801 latter case, the first handle in @var{h} will be assigned the values from\n\
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10840
diff changeset
9802 the first row of @var{values} and so on.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
9803 \n\
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9804 @item as a structure array @var{pv}\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9805 \n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9806 Here, the field names of @var{pv} represent the property names, and the field\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9807 values give the property values. In contrast to the previous case, all\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9808 elements of @var{pv} will be set in all handles in @var{h} independent of\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9809 the dimensions of @var{pv}.\n\
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9810 @end itemize\n\
18576
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9811 \n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9812 @code{set} is also used to query the list of values a named property will\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9813 take. @code{@var{clist} = set (@var{h}, \"property\")} will return the list\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9814 of possible values for @qcode{\"property\"} in the cell list @var{clist}.\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9815 If no output variable is used then the list is formatted and printed to the\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9816 screen.\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9817 \n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9818 If no property is specified (@code{@var{slist} = set (@var{h})}) then a\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9819 structure @var{slist} is returned where the fieldnames are the properties of\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9820 the object @var{h} and the fields are the list of possible values for each\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9821 property. If no output variable is used then the list is formatted and\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9822 printed to the screen.\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9823 \n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9824 For example,\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9825 \n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9826 @example\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9827 @group\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9828 hf = figure ();\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9829 set (hf, \"paperorientation\")\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9830 @result{} paperorientation: [ landscape | @{portrait@} | rotated ]\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9831 @end group\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9832 @end example\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9833 \n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9834 @noindent\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9835 shows the paperorientation property can take three values with the default\n\
3dac2a233386 doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents: 18499
diff changeset
9836 being @qcode{\"portrait\"}.\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
9837 @seealso{get}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9838 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9839 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9840 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9841
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9842 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9843
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9844 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9845
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9846 if (nargin > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9847 {
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9848 // get vector of graphics handles
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9849 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9850
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9851 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9852 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9853 bool request_drawnow = false;
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
9854
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9855 // loop over graphics objects
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
9856 for (octave_idx_type n = 0; n < hcv.numel (); n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9857 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9858 graphics_object go = gh_manager::get_object (hcv(n));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9859
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9860 if (go)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9861 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9862 if (nargin == 3
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9863 && args(1).is_cellstr () && args(2).is_cell ())
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9864 {
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9865 if (args(2).cell_value ().rows () == 1)
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9866 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9867 go.set (args(1).cellstr_value (),
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9868 args(2).cell_value (), 0);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9869 }
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
9870 else if (hcv.numel () == args(2).cell_value ().rows ())
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9871 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9872 go.set (args(1).cellstr_value (),
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9873 args(2).cell_value (), n);
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9874 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9875 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9876 {
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
9877 error ("set: number of graphics handles must match number of value rows (%d != %d)",
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
9878 hcv.numel (), args(2).cell_value ().rows ());
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9879 break;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9880
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9881 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9882 }
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9883 else if (nargin == 2 && args(1).is_map ())
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9884 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9885 go.set (args(1).map_value ());
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9886 }
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9887 else if (nargin == 2 && args(1).is_string ())
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9888 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9889 std::string property = args(1).string_value ();
19631
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19630
diff changeset
9890
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9891 octave_map pmap = go.values_as_struct ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9892
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9893 if (go.has_readonly_property (property))
18580
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9894 if (nargout != 0)
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9895 retval = Matrix ();
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9896 else
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9897 octave_stdout << "set: " << property
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9898 <<" is read-only" << std::endl;
5264b0ec9f97 Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents: 18576
diff changeset
9899 else if (pmap.isfield (property))
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9900 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9901 if (nargout != 0)
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9902 retval = pmap.getfield (property)(0);
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9903 else
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9904 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9905 std::string s = go.value_as_string (property);
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9906
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9907 octave_stdout << s;
18117
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9908 }
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9909 }
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9910 else
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9911 {
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9912 error ("set: unknown property");
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9913 break;
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9914 }
ca84d3c9dc24 set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 18111
diff changeset
9915 }
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9916 else if (nargin == 1)
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9917 {
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9918 if (nargout != 0)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9919 retval = go.values_as_struct ();
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9920 else
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9921 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9922 std::string s = go.values_as_string ();
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9923
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9924 octave_stdout << s;
10717
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9925 }
9d4a198614ab Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents: 10711
diff changeset
9926 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9927 else
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9928 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9929 go.set (args.splice (0, 1));
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9930 request_drawnow = true;
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9931 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9932 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9933 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9934 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9935 error ("set: invalid handle (= %g)", hcv(n));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9936 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9937 }
10056
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9938
33ba83a06a42 Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9972
diff changeset
9939 request_drawnow = true;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9940 }
6733
d6e615183a80 [project @ 2007-06-15 18:21:22 by jwe]
jwe
parents: 6732
diff changeset
9941
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
9942 if (request_drawnow)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
9943 Vdrawnow_requested = true;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9944 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9945 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
9946 error ("set: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9947 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9948 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9949 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9950
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9951 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9952 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9953
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9954 static std::string
18118
ec9b35e60f95 style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents: 18117
diff changeset
9955 get_graphics_object_type (double val)
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9956 {
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9957 std::string retval;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9958
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9959 graphics_object go = gh_manager::get_object (val);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9960
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9961 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
9962 retval = go.type ();
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9963 else
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9964 error ("get: invalid handle (= %g)", val);
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9965
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9966 return retval;
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9967 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
9968
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9969 DEFUN (get, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
9970 "-*- texinfo -*-\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
9971 @deftypefn {Built-in Function} {@var{val} =} get (@var{h})\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
9972 @deftypefnx {Built-in Function} {@var{val} =} get (@var{h}, @var{p})\n\
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
9973 Return the value of the named property @var{p} from the graphics handle\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9974 @var{h}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9975 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9976 If @var{p} is omitted, return the complete property list for @var{h}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9977 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9978 If @var{h} is a vector, return a cell array including the property values or\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
9979 lists respectively.\n\
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 16750
diff changeset
9980 @seealso{set}\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9981 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9982 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
9983 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
9984
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9985 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
9986
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
9987 Cell vals;
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9988
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9989 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9990
13955
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
9991 bool use_cell_format = false;
ffbbe6719ef5 Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13940
diff changeset
9992
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9993 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
9994 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
9995 if (args(0).is_empty ())
12678
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
9996 {
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
9997 retval = Matrix ();
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
9998 return retval;
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
9999 }
69cd5ebe5fb5 Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents: 12587
diff changeset
10000
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10001 ColumnVector hcv (args(0).vector_value ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10002
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10003 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10004 {
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
10005 octave_idx_type len = hcv.numel ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10006
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10007 if (nargin == 1 && len > 1)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10008 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10009 std::string typ0 = get_graphics_object_type (hcv(0));
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10010
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10011 for (octave_idx_type n = 1; n < len; n++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10012 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10013 std::string typ = get_graphics_object_type (hcv(n));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10014
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10015 if (typ != typ0)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10016 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10017 error ("get: vector of handles must all have same type");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10018 break;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10019 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10020 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10021 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10022
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10023 if (nargin > 1 && args(1).is_cellstr ())
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10024 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10025 Array<std::string> plist = args(1).cellstr_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10026
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10027 if (! error_state)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10028 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10029 octave_idx_type plen = plist.numel ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10030
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10031 use_cell_format = true;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10032
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10033 vals.resize (dim_vector (len, plen));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10034
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10035 for (octave_idx_type n = 0; n < len; n++)
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10036 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10037 graphics_object go = gh_manager::get_object (hcv(n));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10038
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10039 if (go)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10040 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10041 for (octave_idx_type m = 0; m < plen; m++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10042 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10043 caseless_str property = plist(m);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10044
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10045 vals(n, m) = go.get (property);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10046 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10047 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10048 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10049 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10050 error ("get: invalid handle (= %g)", hcv(n));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10051 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10052 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10053 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10054 }
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10055 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10056 error ("get: expecting property name or cell array of property names as second argument");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10057 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10058 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10059 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10060 caseless_str property;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10061
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10062 if (nargin > 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10063 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10064 property = args(1).string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10065
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10066 if (error_state)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10067 error ("get: expecting property name or cell array of property names as second argument");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10068 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10069
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10070 vals.resize (dim_vector (len, 1));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10071
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10072 for (octave_idx_type n = 0; n < len; n++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10073 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10074 graphics_object go = gh_manager::get_object (hcv(n));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10075
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10076 if (go)
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10077 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10078 if (nargin == 1)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10079 vals(n) = go.get ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10080 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10081 vals(n) = go.get (property);
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10082 }
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10083 else
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10084 {
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10085 error ("get: invalid handle (= %g)", hcv(n));
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10086 break;
13210
d0f9d7353ee5 return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
10087 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10088 }
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10089 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10090 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10091 else
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10092 error ("get: expecting graphics handle as first argument");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10093 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10094 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10095 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10096
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10097 if (use_cell_format)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10098 retval = vals;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10099 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10100 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10101 octave_idx_type len = vals.numel ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10102
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10103 if (len == 0)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10104 retval = Matrix ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10105 else if (len == 1)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10106 retval = vals(0);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10107 else if (len > 1 && nargin == 1)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10108 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10109 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10110
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10111 for (octave_idx_type n = 0; n < len; n++)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10112 tmp[n] = vals(n).scalar_map_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10113
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10114 retval = octave_map::cat (0, len, tmp);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10115 }
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
10116 else
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10117 retval = vals;
6732
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10118 }
4ba39e63b005 [project @ 2007-06-15 18:07:29 by jwe]
jwe
parents: 6727
diff changeset
10119
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10120 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10121 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10122
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
10123 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14413
diff changeset
10124 %!assert (get (findobj (0, "Tag", "nonexistenttag"), "nonexistentproperty"), [])
11456
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
10125 */
fbdb95640852 get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents: 11455
diff changeset
10126
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
10127 // Return all properties from the graphics handle @var{h}.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
10128 // If @var{h} is a vector, return a cell array including the
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
10129 // property values or lists respectively.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
10130
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10131 DEFUN (__get__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10132 "-*- texinfo -*-\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10133 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8740
diff changeset
10134 Undocumented internal function.\n\
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10135 @end deftypefn")
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10136 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10137 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10138
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10139 octave_value retval;
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
10140
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
10141 Cell vals;
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10142
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10143 int nargin = args.length ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10144
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10145 if (nargin == 1)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10146 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10147 ColumnVector hcv (args(0).vector_value ());
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10148
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10149 if (! error_state)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10150 {
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
10151 octave_idx_type len = hcv.numel ();
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10152
8896
f155e9d1f086 graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
10153 vals.resize (dim_vector (len, 1));
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10154
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10155 for (octave_idx_type n = 0; n < len; n++)
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10156 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10157 graphics_object go = gh_manager::get_object (hcv(n));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10158
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10159 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10160 vals(n) = go.get (true);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10161 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10162 {
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10163 error ("get: invalid handle (= %g)", hcv(n));
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10164 break;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10165 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10166 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10167 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10168 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10169 error ("get: expecting graphics handle as first argument");
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10170 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10171 else
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10172 print_usage ();
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10173
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10174 octave_idx_type len = vals.numel ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10175
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10176 if (len > 1)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10177 retval = vals;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10178 else if (len == 1)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10179 retval = vals(0);
7379
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10180
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10181 return retval;
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10182 }
a78c7bccda91 [project @ 2008-01-15 18:42:29 by jwe]
jwe
parents: 7378
diff changeset
10183
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10184 static octave_value
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10185 make_graphics_object (const std::string& go_name,
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10186 bool integer_figure_handle,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10187 const octave_value_list& args)
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10188 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10189 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10190
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10191 double val = octave_NaN;
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10192
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10193 octave_value_list xargs = args.splice (0, 1);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10194
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10195 caseless_str p ("parent");
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10196
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10197 for (int i = 0; i < xargs.length (); i++)
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10198 if (xargs(i).is_string () && p.compare (xargs(i).string_value ()))
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10199 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10200 if (i < (xargs.length () - 1))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10201 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10202 val = xargs(i+1).double_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10203
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10204 xargs = xargs.splice (i, 2);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10205 break;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10206 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10207 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10208 error ("__go_%s__: missing value for parent property",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10209 go_name.c_str ());
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10210 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10211
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10212 if (xisnan (val))
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10213 val = args(0).double_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10214
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10215 if (! error_state)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10216 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10217 graphics_handle parent = gh_manager::lookup (val);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10218
7056
2002804df782 [project @ 2007-10-24 00:32:44 by jwe]
jwe
parents: 7030
diff changeset
10219 if (parent.ok ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10220 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10221 graphics_handle h
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10222 = gh_manager::make_graphics_handle (go_name, parent,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10223 integer_figure_handle,
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10224 false, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10225
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10226 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10227 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10228 adopt (parent, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10229
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10230 xset (h, xargs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10231 xcreatefcn (h);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10232 xinitialize (h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10233
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10234 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10235
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10236 Vdrawnow_requested = true;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10237 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10238 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10239 error ("__go%s__: unable to create graphics handle",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10240 go_name.c_str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10241 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10242 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10243 error ("__go_%s__: invalid parent", go_name.c_str ());
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10244 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10245 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10246 error ("__go_%s__: invalid parent", go_name.c_str ());
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10247
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10248 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10249 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10250
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10251 DEFUN (__go_figure__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10252 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10253 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10254 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10255 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10256 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10257 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10258
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10259 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10260
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10261 if (args.length () > 0)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10262 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10263 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10264
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10265 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10266 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10267 if (is_figure (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10268 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10269 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10270
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10271 xset (h, args.splice (0, 1));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10272
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10273 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10274 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10275 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10276 {
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10277 bool int_fig_handle = true;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10278
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10279 octave_value_list xargs = args.splice (0, 1);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10280
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10281 graphics_handle h = octave_NaN;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10282
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10283 if (xisnan (val))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10284 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10285 caseless_str pname ("integerhandle");
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10286
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10287 for (int i = 0; i < xargs.length (); i++)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10288 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10289 if (xargs(i).is_string ()
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10290 && pname.compare (xargs(i).string_value ()))
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10291 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10292 if (i < (xargs.length () - 1))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10293 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10294 std::string pval = xargs(i+1).string_value ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10295
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10296 caseless_str on ("on");
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10297 int_fig_handle = on.compare (pval);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10298 xargs = xargs.splice (i, 2);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10299
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10300 break;
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10301 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10302 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10303 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10304
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10305 h = gh_manager::make_graphics_handle ("figure", 0,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10306 int_fig_handle,
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10307 false, false);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10308
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10309 if (! int_fig_handle)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10310 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10311 // We need to initialize the integerhandle property
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10312 // without calling the set_integerhandle method,
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10313 // because doing that will generate a new handle value...
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10314
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10315 graphics_object go = gh_manager::get_object (h);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10316 go.get_properties ().init_integerhandle ("off");
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10317 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10318 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10319 else if (val > 0 && D_NINT (val) == val)
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10320 h = gh_manager::make_figure_handle (val, false);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10321
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10322 if (! error_state && h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10323 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10324 adopt (0, h);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10325
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10326 gh_manager::push_figure (h);
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10327
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
10328 xset (h, xargs);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10329 xcreatefcn (h);
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10330 xinitialize (h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10331
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10332 retval = h.value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10333 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10334 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10335 error ("__go_figure__: failed to create figure handle");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10336 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10337 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10338 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10339 error ("__go_figure__: expecting figure number to be double value");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10340 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10341 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10342 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10343
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10344 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10345 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10346
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10347 #define GO_BODY(TYPE) \
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10348 gh_manager::auto_lock guard; \
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10349 \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10350 octave_value retval; \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10351 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10352 if (args.length () > 0) \
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10353 retval = make_graphics_object (#TYPE, false, args); \
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10354 else \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10355 print_usage (); \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10356 \
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10357 return retval
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10358
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10359 int
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10360 calc_dimensions (const graphics_object& go)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10361 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10362 int nd = 2;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10363
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10364 if (go.isa ("surface"))
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10365 nd = 3;
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10366 else if ((go.isa ("line") || go.isa ("patch"))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10367 && ! go.get ("zdata").is_empty ())
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10368 nd = 3;
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10369 else
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10370 {
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10371 Matrix kids = go.get_properties ().get_children ();
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10372
20267
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20216
diff changeset
10373 for (octave_idx_type i = 0; i < kids.numel (); i++)
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10374 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10375 graphics_handle hkid = gh_manager::lookup (kids(i));
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10376
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10377 if (hkid.ok ())
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10378 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10379 const graphics_object& kid = gh_manager::get_object (hkid);
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10380
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10381 if (kid.valid_object ())
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10382 nd = calc_dimensions (kid);
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10383
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10384 if (nd == 3)
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10385 break;
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10386 }
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10387 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10388 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10389
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10390 return nd;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10391 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10392
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10393 DEFUN (__calc_dimensions__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10394 "-*- texinfo -*-\n\
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10395 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10396 Internal function.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10397 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10398 Determine the number of dimensions in a graphics object, either 2 or 3.\n\
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10399 @end deftypefn")
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10400 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10401 gh_manager::auto_lock guard;
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10402
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10403 octave_value retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10404
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10405 int nargin = args.length ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10406
18806
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10407 if (nargin == 1)
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10408 {
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10409 double h = args(0).double_value ();
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10410 if (! error_state)
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10411 retval = calc_dimensions (gh_manager::get_object (h));
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10412 else
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10413 error ("__calc_dimensions__: expecting graphics handle as only argument");
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10414 }
5e99fd6ea758 graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents: 17861
diff changeset
10415 else
17564
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10416 print_usage ();
234731d524c2 axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents: 17544
diff changeset
10417
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10418 return retval;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10419 }
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10846
diff changeset
10420
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10421 DEFUN (__go_axes__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10422 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10423 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10424 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10425 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10426 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10427 GO_BODY (axes);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10428 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10429
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10430 DEFUN (__go_line__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10431 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10432 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10433 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10434 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10435 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10436 GO_BODY (line);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10437 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10438
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10439 DEFUN (__go_text__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10440 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10441 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10442 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10443 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10444 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10445 GO_BODY (text);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10446 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10447
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10448 DEFUN (__go_image__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10449 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10450 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10451 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10452 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10453 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10454 GO_BODY (image);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10455 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10456
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10457 DEFUN (__go_surface__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10458 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10459 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10460 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10461 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10462 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10463 GO_BODY (surface);
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10464 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10465
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10466 DEFUN (__go_patch__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10467 "-*- texinfo -*-\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10468 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10469 Undocumented internal function.\n\
6807
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10470 @end deftypefn")
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10471 {
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10472 GO_BODY (patch);
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10473 }
0089a504fdd6 [project @ 2007-08-10 17:34:59 by jwe]
jwe
parents: 6790
diff changeset
10474
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10475 DEFUN (__go_hggroup__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10476 "-*- texinfo -*-\n\
7865
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10477 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10478 Undocumented internal function.\n\
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10479 @end deftypefn")
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10480 {
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10481 GO_BODY (hggroup);
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10482 }
b74039822fd2 Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7864
diff changeset
10483
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10484 DEFUN (__go_uimenu__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10485 "-*- texinfo -*-\n\
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10486 @deftypefn {Built-in Function} {} __go_uimenu__ (@var{parent})\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10487 Undocumented internal function.\n\
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10488 @end deftypefn")
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10489 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10490 GO_BODY (uimenu);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10491 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11076
diff changeset
10492
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10493 DEFUN (__go_uicontrol__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10494 "-*- texinfo -*-\n\
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10495 @deftypefn {Built-in Function} {} __go_uicontrol__ (@var{parent})\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10496 Undocumented internal function.\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10497 @end deftypefn")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10498 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10499 GO_BODY (uicontrol);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10500 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10501
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10502 DEFUN (__go_uipanel__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10503 "-*- texinfo -*-\n\
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10504 @deftypefn {Built-in Function} {} __go_uipanel__ (@var{parent})\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10505 Undocumented internal function.\n\
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10506 @end deftypefn")
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10507 {
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10508 GO_BODY (uipanel);
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10509 }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10510
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10511 DEFUN (__go_uicontextmenu__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10512 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10513 @deftypefn {Built-in Function} {} __go_uicontextmenu__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10514 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10515 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10516 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10517 GO_BODY (uicontextmenu);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10518 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10519
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10520 DEFUN (__go_uitoolbar__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10521 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10522 @deftypefn {Built-in Function} {} __go_uitoolbar__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10523 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10524 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10525 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10526 GO_BODY (uitoolbar);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10527 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10528
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10529 DEFUN (__go_uipushtool__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10530 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10531 @deftypefn {Built-in Function} {} __go_uipushtool__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10532 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10533 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10534 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10535 GO_BODY (uipushtool);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10536 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10537
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10538 DEFUN (__go_uitoggletool__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10539 "-*- texinfo -*-\n\
13703
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10540 @deftypefn {Built-in Function} {} __go_uitoggletool__ (@var{parent})\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10541 Undocumented internal function.\n\
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10542 @end deftypefn")
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10543 {
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10544 GO_BODY (uitoggletool);
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10545 }
22ce748da25f Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13327
diff changeset
10546
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10547 DEFUN (__go_delete__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10548 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10549 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10550 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10551 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10552 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10553 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10554
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10555 octave_value_list retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10556
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10557 if (args.length () == 1)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10558 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10559 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10560
18111
b560bac0fca2 maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents: 18099
diff changeset
10561 const NDArray vals = args(0).array_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10562
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10563 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10564 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10565 // Check all the handles to delete are valid first, as callbacks
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10566 // might delete one of the handles we later want to delete
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10567 for (octave_idx_type i = 0; i < vals.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10568 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10569 h = gh_manager::lookup (vals(i));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10570
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10571 if (! h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10572 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10573 error ("delete: invalid graphics object (= %g)", vals(i));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10574 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10575 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10576 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10577
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10578 delete_graphics_objects (vals);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10579 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10580 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10581 error ("delete: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10582 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10583 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10584 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10585
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10586 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10587 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10588
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10589 DEFUN (__go_axes_init__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10590 "-*- texinfo -*-\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10591 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10592 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10593 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10594 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10595 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10596
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10597 octave_value retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10598
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10599 int nargin = args.length ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10600
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10601 std::string mode = "";
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10602
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10603 if (nargin == 2)
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10604 mode = args(1).string_value ();
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10605
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10606 if (nargin == 1 || nargin == 2)
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10607 {
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10608 graphics_handle h = octave_NaN;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10609
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10610 double val = args(0).double_value ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10611
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10612 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10613 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10614 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10615
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10616 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10617 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10618 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10619
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10620 go.set_defaults (mode);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10621
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10622 h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10623 if (! h.ok ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10624 error ("__go_axes_init__: axis deleted during initialization (= %g)",
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10625 val);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10626 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10627 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10628 error ("__go_axes_init__: invalid graphics object (= %g)", val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10629 }
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10630 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10631 error ("__go_axes_init__: invalid graphics object");
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10632 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10633 else
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10634 print_usage ();
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10635
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10636 return retval;
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10637 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10638
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10639 DEFUN (__go_handles__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10640 "-*- texinfo -*-\n\
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10641 @deftypefn {Built-in Function} {} __go_handles__ (@var{show_hidden})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10642 Undocumented internal function.\n\
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10643 @end deftypefn")
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10644 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10645 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10646
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10647 bool show_hidden = false;
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10648
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10649 if (args.length () > 0)
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10650 show_hidden = args(0).bool_value ();
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10651
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10652 return octave_value (gh_manager::handle_list (show_hidden));
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10653 }
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10654
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10655 DEFUN (__go_figure_handles__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10656 "-*- texinfo -*-\n\
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10657 @deftypefn {Built-in Function} {} __go_figure_handles__ (@var{show_hidden})\n\
6945
6bbf56a9718a [project @ 2007-10-02 20:47:22 by jwe]
jwe
parents: 6938
diff changeset
10658 Undocumented internal function.\n\
6425
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
10659 @end deftypefn")
0cc5ca7b1e91 [project @ 2007-03-21 15:57:19 by jwe]
jwe
parents: 6424
diff changeset
10660 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10661 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10662
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10663 bool show_hidden = false;
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10664
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10665 if (args.length () > 0)
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10666 show_hidden = args(0).bool_value ();
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10667
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10668 return octave_value (gh_manager::figure_handle_list (show_hidden));
6406
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10669 }
f7c06f96bd18 [project @ 2007-03-14 18:26:00 by jwe]
jwe
parents:
diff changeset
10670
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10671 DEFUN (__go_execute_callback__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10672 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
10673 @deftypefn {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name})\n\
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10674 @deftypefnx {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name}, @var{param})\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10675 Undocumented internal function.\n\
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10676 @end deftypefn")
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10677 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10678 octave_value retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10679
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10680 int nargin = args.length ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10681
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10682 if (nargin == 2 || nargin == 3)
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10683 {
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10684 double val = args(0).double_value ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10685
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10686 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10687 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10688 graphics_handle h = gh_manager::lookup (val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10689
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10690 if (h.ok ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10691 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10692 std::string name = args(1).string_value ("__go_execute_callback__: invalid callback name");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10693
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10694 if (nargin == 2)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10695 gh_manager::execute_callback (h, name);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10696 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10697 gh_manager::execute_callback (h, name, args(2));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10698 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10699 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10700 error ("__go_execute_callback__: invalid graphics object (= %g)",
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10701 val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10702 }
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10703 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10704 error ("__go_execute_callback__: invalid graphics object");
7967
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10705 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10706 else
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10707 print_usage ();
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10708
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10709 return retval;
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10710 }
6add0f974aee Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents: 7964
diff changeset
10711
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10712 DEFUN (__image_pixel_size__, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10713 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
10714 @deftypefn {Built-in Function} {@var{px}, @var{py}} __image_pixel_size__ (@var{h})\n\
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10715 Internal function: returns the pixel size of the image in normalized units.\n\
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10716 @end deftypefn")
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10717 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10718 octave_value retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10719
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10720 int nargin = args.length ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10721
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10722 if (nargin == 1)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10723 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10724 double h = args(0).double_value ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10725
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10726 if (! error_state)
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10727 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10728 graphics_object go = gh_manager::get_object (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10729 if (go && go.isa ("image"))
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10730 {
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10731 image::properties& ip =
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10732 dynamic_cast<image::properties&> (go.get_properties ());
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10733
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10734 Matrix dp = Matrix (1, 2);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10735 dp(0) = ip.pixel_xsize ();
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
10736 dp(1) = ip.pixel_ysize ();
11076
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10737 retval = dp;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10738 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10739 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10740 error ("__image_pixel_size__: object is not an image");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10741 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10742 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10743 error ("__image_pixel_size__: argument is not a handle");
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10744 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10745 else
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10746 print_usage ();
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10747
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10748 return retval;
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10749 }
b748b86cb8c1 fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents: 11074
diff changeset
10750
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10751 gtk_manager *gtk_manager::instance = 0;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10752
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10753 void
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10754 gtk_manager::create_instance (void)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10755 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10756 instance = new gtk_manager ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10757
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10758 if (instance)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10759 singleton_cleanup_list::add (cleanup_instance);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10760 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10761
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10762 graphics_toolkit
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10763 gtk_manager::do_get_toolkit (void) const
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10764 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10765 graphics_toolkit retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10766
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10767 if (! dtk.empty ())
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10768 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10769 const_loaded_toolkits_iterator pl = loaded_toolkits.find (dtk);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10770
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10771 if (pl == loaded_toolkits.end ())
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10772 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10773 const_available_toolkits_iterator pa = available_toolkits.find (dtk);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10774
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10775 if (pa != available_toolkits.end ())
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10776 {
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10777 octave_value_list args;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10778 args(0) = dtk;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10779 feval ("graphics_toolkit", args);
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10780
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10781 pl = loaded_toolkits.find (dtk);
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10782
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10783 if (error_state || pl == loaded_toolkits.end ())
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10784 error ("failed to load %s graphics toolkit", dtk.c_str ());
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10785 else
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10786 retval = pl->second;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10787 }
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10788 else
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10789 error ("default graphics toolkit '%s' is not available!",
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10790 dtk.c_str ());
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10791 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10792 else
19680
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10793 retval = pl->second;
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10794 }
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10795 else
408361a8c72f Don't register gnuplot toolkit if gnuplot is not available (bug #35391)
Mike Miller <mtmiller@ieee.org>
parents: 19631
diff changeset
10796 error ("no graphics toolkits are available!");
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10797
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10798 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10799 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10800
19629
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19628
diff changeset
10801 void
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10802 gtk_manager::do_register_toolkit (const std::string& name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10803 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10804 if (dtk.empty () || name == "qt"
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10805 || (name == "fltk"
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10806 && available_toolkits.find ("qt") == available_toolkits.end ()))
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10807 dtk = name;
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10808
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10809 available_toolkits.insert (name);
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10810 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10811
19629
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19628
diff changeset
10812 void
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10813 gtk_manager::do_unregister_toolkit (const std::string& name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10814 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10815 available_toolkits.erase (name);
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10816
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10817 if (dtk == name)
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10818 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10819 if (available_toolkits.empty ())
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10820 dtk.clear ();
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10821 else
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10822 {
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10823 const_available_toolkits_iterator pa = available_toolkits.begin ();
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10824
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10825 dtk = *pa++;
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10826
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10827 while (pa != available_toolkits.end ())
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10828 {
18714
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18711
diff changeset
10829 std::string tk_name = *pa++;
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18711
diff changeset
10830
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18711
diff changeset
10831 if (tk_name == "qt"
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18711
diff changeset
10832 || (tk_name == "fltk"
19411
9ef286208da1 maint: Periodic merge of gui-release to default.
John W. Eaton <jwe@octave.org>
parents: 19355 19408
diff changeset
10833 && (available_toolkits.find ("qt")
9ef286208da1 maint: Periodic merge of gui-release to default.
John W. Eaton <jwe@octave.org>
parents: 19355 19408
diff changeset
10834 == available_toolkits.end ())))
18714
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18711
diff changeset
10835 dtk = tk_name;
18571
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10836 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10837 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10838 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10839 }
ca1648b2e673 set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents: 18498
diff changeset
10840
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
10841 DEFUN (available_graphics_toolkits, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10842 "-*- texinfo -*-\n\
12215
4ae2a74ed04c Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12189
diff changeset
10843 @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
10844 Return a cell array of registered graphics toolkits.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
10845 @seealso{graphics_toolkit, register_graphics_toolkit}\n\
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
10846 @end deftypefn")
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
10847 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
10848 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10849
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10850 return octave_value (gtk_manager::available_toolkits_list ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10851 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10852
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10853 DEFUN (register_graphics_toolkit, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10854 "-*- texinfo -*-\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10855 @deftypefn {Built-in Function} {} register_graphics_toolkit (@var{toolkit})\n\
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10856 List @var{toolkit} as an available graphics toolkit.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
10857 @seealso{available_graphics_toolkits}\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10858 @end deftypefn")
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10859 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10860 octave_value retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10861
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10862 gh_manager::auto_lock guard;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10863
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10864 if (args.length () == 1)
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10865 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10866 std::string name = args(0).string_value ("register_graphics_toolkit: TOOLKIT must be a string");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10867
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10868 gtk_manager::register_toolkit (name);
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10869 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10870 else
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10871 print_usage ();
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10872
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10873 return retval;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10874 }
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10875
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10876 DEFUN (loaded_graphics_toolkits, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10877 "-*- texinfo -*-\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10878 @deftypefn {Built-in Function} {} loaded_graphics_toolkits ()\n\
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10879 Return a cell array of the currently loaded graphics toolkits.\n\
14134
84f38aeb9f0e doc: Add register_graphics_toolkit() and loaded_graphics_toolkits() to documentation
Rik <octave@nomad.inbox5.com>
parents: 14062
diff changeset
10880 @seealso{available_graphics_toolkits}\n\
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10881 @end deftypefn")
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10882 {
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10883 gh_manager::auto_lock guard;
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10884
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14016
diff changeset
10885 return octave_value (gtk_manager::loaded_toolkits_list ());
7835
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
10886 }
ca8b97bb952c added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents: 7833
diff changeset
10887
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10888 DEFUN (drawnow, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10889 "-*- texinfo -*-\n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
10890 @deftypefn {Built-in Function} {} drawnow ()\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
10891 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
10892 @deftypefnx {Built-in Function} {} drawnow (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10893 Update figure windows and their children.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10894 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10895 The event queue is flushed and any callbacks generated are executed.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10896 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10897 With the optional argument @qcode{\"expose\"}, only graphic objects are\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10898 updated and no other events or callbacks are processed.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10899 \n\
9316
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
10900 The third calling form of @code{drawnow} is for debugging and is\n\
c539ec5726e7 Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents: 9311
diff changeset
10901 undocumented.\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
10902 @seealso{refresh}\n\
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10903 @end deftypefn")
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10904 {
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10905 static int drawnow_executing = 0;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10906
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10907 octave_value retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10908
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10909 gh_manager::lock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10910
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
10911 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
10912 frame.protect_var (Vdrawnow_requested, false);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
10913
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 10056
diff changeset
10914 frame.protect_var (drawnow_executing);
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
10915
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
10916 if (++drawnow_executing <= 1)
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
10917 {
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
10918 if (args.length () == 0 || args.length () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10919 {
13801
195ff3561152 allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
10920 Matrix hlist = gh_manager::figure_handle_list (true);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10921
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
10922 for (int i = 0; i < hlist.numel (); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10923 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10924 graphics_handle h = gh_manager::lookup (hlist(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10925
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10926 if (h.ok () && h != 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10927 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10928 graphics_object go = gh_manager::get_object (h);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10929 figure::properties& fprops
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
10930 = dynamic_cast <figure::properties&> (go.get_properties ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10931
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10932 if (fprops.is_modified ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10933 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10934 if (fprops.is_visible ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10935 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10936 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10937
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
10938 fprops.get_toolkit ().redraw_figure (go);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10939
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10940 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10941 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10942
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10943 fprops.set_modified (false);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10944 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10945 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10946 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10947
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10948 bool do_events = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10949
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10950 if (args.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10951 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10952 caseless_str val (args(0).string_value ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10953
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10954 if (! error_state && val.compare ("expose"))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10955 do_events = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10956 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10957 {
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
10958 error ("drawnow: invalid argument, expected 'expose' as argument");
20082
0f1a722133f4 Fix deadlock condition on error in drawnow() (bug #44759).
Rik <rik@octave.org>
parents: 20066
diff changeset
10959
0f1a722133f4 Fix deadlock condition on error in drawnow() (bug #44759).
Rik <rik@octave.org>
parents: 20066
diff changeset
10960 gh_manager::unlock ();
0f1a722133f4 Fix deadlock condition on error in drawnow() (bug #44759).
Rik <rik@octave.org>
parents: 20066
diff changeset
10961
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10962 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10963 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10964 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10965
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10966 if (do_events)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10967 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10968 gh_manager::unlock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10969
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10970 gh_manager::process_events ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10971
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10972 gh_manager::lock ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10973 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10974 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
10975 else if (args.length () >= 2 && args.length () <= 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10976 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10977 std::string term, file, debug_file;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10978 bool mono;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
10979
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10980 term = args(0).string_value ("drawnow: invalid terminal TERM, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10981
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10982 file = args(1).string_value ("drawnow: invalid FILE, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10983
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10984 size_t pos_p = file.find_first_of ("|");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10985 size_t pos_c = file.find_first_not_of ("| ");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10986
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10987 if (pos_p == std::string::npos &&
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10988 pos_c == std::string::npos)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10989 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10990 error ("drawnow: empty output ''");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10991
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10992 gh_manager::unlock ();
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10993
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10994 return retval;
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10995 }
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10996 else if (pos_c == std::string::npos)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10997 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10998 error ("drawnow: empty pipe '|'");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
10999
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11000 gh_manager::unlock ();
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11001
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11002 return retval;
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11003 }
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11004 else if (pos_p != std::string::npos && pos_p < pos_c)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11005 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11006 // Strip leading pipe character
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11007 file = file.substr (pos_c);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11008 }
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11009 else
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11010 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11011 size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11012
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11013 if (pos != std::string::npos)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11014 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11015 std::string dirname = file.substr (pos_c, pos+1);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11016
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11017 file_stat fs (dirname);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11018
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11019 if (! (fs && fs.is_dir ()))
19919
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11020 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11021 error ("drawnow: nonexistent directory '%s'",
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11022 dirname.c_str ());
19919
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11023
20082
0f1a722133f4 Fix deadlock condition on error in drawnow() (bug #44759).
Rik <rik@octave.org>
parents: 20066
diff changeset
11024 gh_manager::unlock ();
0f1a722133f4 Fix deadlock condition on error in drawnow() (bug #44759).
Rik <rik@octave.org>
parents: 20066
diff changeset
11025
19919
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11026 return retval;
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11027 }
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11028 }
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11029 }
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11030
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11031 mono = (args.length () >= 3 ? args(2).bool_value () : false);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11032
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11033 if (! error_state)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11034 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11035 debug_file = (args.length () > 3 ? args(3).string_value () : "");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11036
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11037 if (! error_state)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11038 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11039 graphics_handle h = gcf ();
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11040
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11041 if (h.ok ())
19919
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11042 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11043 graphics_object go = gh_manager::get_object (h);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11044
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11045 gh_manager::unlock ();
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11046
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11047 go.get_toolkit ().print_figure (go, term, file,
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11048 mono, debug_file);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11049
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11050 gh_manager::lock ();
19919
e814e202cd84 Account for whitespace and other anomalies in print function pipe/file string.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19909
diff changeset
11051 }
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12445
diff changeset
11052 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11053 error ("drawnow: nothing to draw");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11054 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11055 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11056 error ("drawnow: invalid DEBUG_FILE, expected a string value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11057 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11058 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11059 error ("drawnow: invalid colormode MONO, expected a boolean value");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11060 }
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
11061 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11062 print_usage ();
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
11063 }
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7408
diff changeset
11064
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11065 gh_manager::unlock ();
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11066
7408
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
11067 return retval;
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
11068 }
246f905cb984 [project @ 2008-01-22 19:42:47 by jwe]
jwe
parents: 7403
diff changeset
11069
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
11070 DEFUN (addlistener, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
11071 "-*- texinfo -*-\n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
11072 @deftypefn {Built-in Function} {} addlistener (@var{h}, @var{prop}, @var{fcn})\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11073 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11074 object @var{h}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11075 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11076 Property listeners are executed (in order of registration) when the property\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11077 is set. The new value is already available when the listeners are executed.\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11078 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11079 @var{prop} must be a string naming a valid property in @var{h}.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11080 \n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11081 @var{fcn} can be a function handle, a string or a cell array whose first\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11082 element is a function handle. If @var{fcn} is a function handle, the\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11083 corresponding function should accept at least 2 arguments, that will be\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11084 set to the object handle and the empty matrix respectively. If @var{fcn}\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11085 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11086 array, the first element must be a function handle with the same signature\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11087 as described above. The next elements of the cell array are passed\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11088 as additional arguments to the function.\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11089 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11090 Example:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11091 \n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11092 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11093 @group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11094 function my_listener (h, dummy, p1)\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11095 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11096 endfunction\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11097 \n\
7859
fdd465b00ec0 Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7857
diff changeset
11098 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11099 @end group\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11100 @end example\n\
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11101 \n\
17486
b4343603f7ab doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents: 17483
diff changeset
11102 @seealso{addproperty, hggroup}\n\
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11103 @end deftypefn")
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11104 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
11105 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11106
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11107 octave_value retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11108
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
11109 if (args.length () >= 3 && args.length () <= 4)
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11110 {
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11111 double h = args(0).double_value ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11112
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11113 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11114 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11115 std::string pname = args(1).string_value ("addlistener: invalid property name, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11116
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11117 graphics_handle gh = gh_manager::lookup (h);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11118
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11119 if (gh.ok ())
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11120 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11121 graphics_object go = gh_manager::get_object (gh);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11122
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11123 go.add_property_listener (pname, args(2), POSTSET);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11124
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11125 if (args.length () == 4)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11126 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11127 caseless_str persistent = args(3).string_value ();
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11128 if (persistent.compare ("persistent"))
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11129 go.add_property_listener (pname, args(2), PERSISTENT);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11130 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11131 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11132 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11133 error ("addlistener: invalid graphics object (= %g)", h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11134 }
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11135 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11136 error ("addlistener: invalid handle");
7849
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11137 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11138 else
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11139 print_usage ();
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11140
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11141 return retval;
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11142 }
3249f64f69b2 Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7848
diff changeset
11143
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11144 DEFUN (dellistener, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
11145 "-*- texinfo -*-\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11146 @deftypefn {Built-in Function} {} dellistener (@var{h}, @var{prop}, @var{fcn})\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11147 Remove the registration of @var{fcn} as a listener for the property\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11148 @var{prop} of the graphics object @var{h}.\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11149 \n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11150 The function @var{fcn} must be the same variable (not just the same value),\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11151 as was passed to the original call to @code{addlistener}.\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11152 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11153 If @var{fcn} is not defined then all listener functions of @var{prop}\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11154 are removed.\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11155 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11156 Example:\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11157 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11158 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11159 @group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11160 function my_listener (h, dummy, p1)\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11161 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11162 endfunction\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11163 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11164 c = @{@@my_listener, \"my string\"@};\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11165 addlistener (gcf, \"position\", c);\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11166 dellistener (gcf, \"position\", c);\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11167 @end group\n\
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11168 @end example\n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11169 \n\
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11170 @end deftypefn")
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11171 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
11172 gh_manager::auto_lock guard;
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11173
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11174 octave_value retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11175
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11176 if (args.length () == 3 || args.length () == 2)
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11177 {
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11178 double h = args(0).double_value ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11179
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11180 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11181 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11182 std::string pname = args(1).string_value ("dellistener: invalid property name, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11183
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11184 graphics_handle gh = gh_manager::lookup (h);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11185
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11186 if (gh.ok ())
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11187 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11188 graphics_object go = gh_manager::get_object (gh);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11189
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11190 if (args.length () == 2)
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11191 go.delete_property_listener (pname, octave_value (), POSTSET);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11192 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11193 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11194 if (args(2).is_string ()
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11195 && args(2).string_value () == "persistent")
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
11196 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11197 go.delete_property_listener (pname, octave_value (),
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11198 PERSISTENT);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11199 go.delete_property_listener (pname, octave_value (),
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11200 POSTSET);
12506
0dda50ae4997 add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents: 12502
diff changeset
11201 }
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11202 else
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11203 go.delete_property_listener (pname, args(2), POSTSET);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11204 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11205 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11206 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11207 error ("dellistener: invalid graphics object (= %g)", h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11208 }
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11209 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11210 error ("dellistener: invalid handle");
8299
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11211 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11212 else
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11213 print_usage ();
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11214
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11215 return retval;
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11216 }
be9b14945774 Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents: 8291
diff changeset
11217
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11218 DEFUN (addproperty, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
11219 "-*- texinfo -*-\n\
11572
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
11220 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type})\n\
7d6d8c1e471f Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
11221 @deftypefnx {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type}, @var{arg}, @dots{})\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11222 Create a new property named @var{name} in graphics object @var{h}.\n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11223 \n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11224 @var{type} determines the type of the property to create. @var{args}\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11225 usually contains the default value of the property, but additional\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11226 arguments might be given, depending on the type of the property.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11227 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11228 The supported property types are:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11229 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11230 @table @code\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11231 @item string\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11232 A string property. @var{arg} contains the default string value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11233 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11234 @item any\n\
16826
a4969508008e doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents: 16814
diff changeset
11235 An @nospell{un-typed} property. This kind of property can hold any octave\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11236 value. @var{args} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11237 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11238 @item radio\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11239 A string property with a limited set of accepted values. The first\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11240 argument must be a string with all accepted values separated by\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11241 a vertical bar ('|'). The default value can be marked by enclosing\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11242 it with a '@{' '@}' pair. The default value may also be given as\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11243 an optional second string argument.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11244 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11245 @item boolean\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11246 A boolean property. This property type is equivalent to a radio\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11247 property with \"on|off\" as accepted values. @var{arg} contains\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11248 the default property value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11249 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11250 @item double\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11251 A scalar double property. @var{arg} contains the default value.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11252 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11253 @item handle\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11254 A handle property. This kind of property holds the handle of a\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11255 graphics object. @var{arg} contains the default handle value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11256 When no default value is given, the property is initialized to\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11257 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11258 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11259 @item data\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11260 A data (matrix) property. @var{arg} contains the default data\n\
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11261 value. When no default value is given, the data is initialized to\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11262 the empty matrix.\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10792
diff changeset
11263 \n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11264 @item color\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11265 A color property. @var{arg} contains the default color value.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11266 When no default color is given, the property is set to black.\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11267 An optional second string argument may be given to specify an\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11268 additional set of accepted string values (like a radio property).\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11269 @end table\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11270 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11271 @var{type} may also be the concatenation of a core object type and\n\
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8961
diff changeset
11272 a valid property name for that object type. The property created\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11273 then has the same characteristics as the referenced property (type,\n\
20132
1f9ed81bd173 maint: Fix spelling and grammar mistakes in docs and comments (bug #44878)
Rafael Laboissiere <rafael@laboissiere.net>
parents: 20118
diff changeset
11274 possible values, hidden state@dots{}). This allows one to clone an\n\
1f9ed81bd173 maint: Fix spelling and grammar mistakes in docs and comments (bug #44878)
Rafael Laboissiere <rafael@laboissiere.net>
parents: 20118
diff changeset
11275 existing property into the graphics object @var{h}.\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11276 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11277 Examples:\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11278 \n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11279 @example\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11280 @group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11281 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11282 addproperty (\"my_radio\", gcf, \"radio\", \"val_1|val_2|@{val_3@}\");\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11283 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\
9064
7c02ec148a3c Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
11284 @end group\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11285 @end example\n\
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11286 \n\
17486
b4343603f7ab doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents: 17483
diff changeset
11287 @seealso{addlistener, hggroup}\n\
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11288 @end deftypefn")
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11289 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
11290 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11291
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11292 octave_value retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11293
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11294 if (args.length () >= 3)
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11295 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11296 std::string name = args(0).string_value ("addproperty: invalid property NAME, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11297
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11298 double h = args(1).double_value ();
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11299
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11300 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11301 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11302 graphics_handle gh = gh_manager::lookup (h);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11303
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11304 if (gh.ok ())
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11305 {
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11306 graphics_object go = gh_manager::get_object (gh);
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11307
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11308 std::string type = args(2).string_value ("addproperty: invalid property TYPE, expected a string value");
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11309
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11310 if (! go.get_properties ().has_property (name))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11311 {
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11312 property p = property::create (name, gh, type,
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11313 args.splice (0, 3));
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11314
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11315 go.get_properties ().insert_property (name, p);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11316 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11317 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11318 error ("addproperty: a '%s' property already exists in the graphics object",
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11319 name.c_str ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11320 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11321 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11322 error ("addproperty: invalid graphics object (= %g)", h);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11323 }
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11324 else
20617
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20597
diff changeset
11325 error ("addproperty: invalid handle value");
7864
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11326 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11327 else
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11328 print_usage ();
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11329
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11330 return retval;
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11331 }
56f781f38f0b Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents: 7862
diff changeset
11332
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11333 octave_value
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
11334 get_property_from_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11335 const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11336 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
11337 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11338
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11339 octave_value retval;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11340 graphics_object go = gh_manager::get_object (handle);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11341
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11342 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11343 retval = go.get (caseless_str (property));
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11344 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
11345 error ("%s: invalid handle (= %g)", func.c_str (), handle);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11346
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11347 return retval;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11348 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11349
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11350 bool
7447
25018e35b4cb [project @ 2008-02-05 22:38:57 by jwe]
jwe
parents: 7446
diff changeset
11351 set_property_in_handle (double handle, const std::string& property,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10301
diff changeset
11352 const octave_value& arg, const std::string& func)
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11353 {
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13247
diff changeset
11354 gh_manager::auto_lock guard;
7936
78400fde223e Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents: 7924
diff changeset
11355
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11356 int ret = false;
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11357 graphics_object go = gh_manager::get_object (handle);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11358
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11359 if (go)
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11360 {
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11361 go.set (caseless_str (property), arg);
9582
bdcfb756d721 improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents: 9561
diff changeset
11362
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11363 ret = true;
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11364 }
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11365 else
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14798
diff changeset
11366 error ("%s: invalid handle (= %g)", func.c_str (), handle);
6595
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11367
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11368 return ret;
55586d763de1 [project @ 2007-04-27 15:31:10 by dbateman]
dbateman
parents: 6568
diff changeset
11369 }
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11370
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11371 static bool
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11372 compare_property_values (const octave_value& ov1, const octave_value& ov2)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11373 {
18111
b560bac0fca2 maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents: 18099
diff changeset
11374 octave_value_list args(2);
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11375
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11376 args(0) = ov1;
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11377 args(1) = ov2;
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11378
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11379 octave_value_list result = feval ("isequal", args, 1);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11380
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11381 if (result.length () > 0)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11382 return result(0).bool_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11383
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11384 return false;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11385 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11386
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11387 static std::map<uint32_t, bool> waitfor_results;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11388
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11389 static void
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11390 cleanup_waitfor_id (uint32_t id)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11391 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11392 waitfor_results.erase (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11393 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11394
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11395 static void
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11396 do_cleanup_waitfor_listener (const octave_value& listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11397 listener_mode mode = POSTSET)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11398 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11399 Cell c = listener.cell_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11400
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11401 if (c.numel () >= 4)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11402 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11403 double h = c(2).double_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11404
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11405 caseless_str pname = c(3).string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11406
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11407 gh_manager::auto_lock guard;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11408
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11409 graphics_handle gh = gh_manager::lookup (h);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11410
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11411 if (gh.ok ())
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11412 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11413 graphics_object go = gh_manager::get_object (gh);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11414
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11415 if (go.get_properties ().has_property (pname))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11416 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11417 go.get_properties ().delete_listener (pname, listener, mode);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11418
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11419 if (mode == POSTSET)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11420 go.get_properties ().delete_listener (pname, listener,
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11421 PERSISTENT);
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11422 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11423 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11424 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11425 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11426
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11427 static void
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
11428 cleanup_waitfor_postset_listener (const octave_value& listener)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11429 { do_cleanup_waitfor_listener (listener, POSTSET); }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11430
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11431 static void
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
11432 cleanup_waitfor_predelete_listener (const octave_value& listener)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11433 { do_cleanup_waitfor_listener (listener, PREDELETE); }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11434
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11435 static octave_value_list
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11436 waitfor_listener (const octave_value_list& args, int)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11437 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11438 if (args.length () > 3)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11439 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11440 uint32_t id = args(2).uint32_scalar_value ().value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11441
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11442 if (args.length () > 5)
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11443 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11444 double h = args(0).double_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11445
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11446 caseless_str pname = args(4).string_value ();
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11447
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11448 gh_manager::auto_lock guard;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11449
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11450 graphics_handle gh = gh_manager::lookup (h);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11451
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11452 if (gh.ok ())
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11453 {
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11454 graphics_object go = gh_manager::get_object (gh);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11455 octave_value pvalue = go.get (pname);
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11456
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11457 if (compare_property_values (pvalue, args(5)))
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11458 waitfor_results[id] = true;
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11459 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11460 }
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11461 else
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11462 waitfor_results[id] = true;
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11463 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11464
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11465 return octave_value_list ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11466 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11467
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11468 static octave_value_list
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11469 waitfor_del_listener (const octave_value_list& args, int)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11470 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11471 if (args.length () > 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11472 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11473 uint32_t id = args(2).uint32_scalar_value ().value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11474
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11475 waitfor_results[id] = true;
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11476 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11477
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11478 return octave_value_list ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11479 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11480
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11481 DEFUN (waitfor, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
11482 "-*- texinfo -*-\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11483 @deftypefn {Built-in Function} {} waitfor (@var{h})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11484 @deftypefnx {Built-in Function} {} waitfor (@var{h}, @var{prop})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11485 @deftypefnx {Built-in Function} {} waitfor (@var{h}, @var{prop}, @var{value})\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11486 @deftypefnx {Built-in Function} {} waitfor (@dots{}, \"timeout\", @var{timeout})\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11487 Suspend the execution of the current program until a condition is\n\
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
11488 satisfied on the graphics handle @var{h}.\n\
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
11489 \n\
20207
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11490 While the program is suspended graphics events are still processed normally,\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11491 allowing callbacks to modify the state of graphics objects. This function\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11492 is reentrant and can be called from a callback, while another @code{waitfor}\n\
4f45eaf83908 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20132
diff changeset
11493 call is pending at the top-level.\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11494 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11495 In the first form, program execution is suspended until the graphics object\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11496 @var{h} is destroyed. If the graphics handle is invalid, the function\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11497 returns immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11498 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11499 In the second form, execution is suspended until the graphics object is\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11500 destroyed or the property named @var{prop} is modified. If the graphics\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11501 handle is invalid or the property does not exist, the function returns\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11502 immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11503 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11504 In the third form, execution is suspended until the graphics object is\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11505 destroyed or the property named @var{prop} is set to @var{value}. The\n\
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11506 function @code{isequal} is used to compare property values. If the graphics\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11507 handle is invalid, the property does not exist or the property is already\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11508 set to @var{value}, the function returns immediately.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11509 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11510 An optional timeout can be specified using the property @code{timeout}.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11511 This timeout value is the number of seconds to wait for the condition to be\n\
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11512 true. @var{timeout} must be at least 1. If a smaller value is specified, a\n\
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 13925
diff changeset
11513 warning is issued and a value of 1 is used instead. If the timeout value is\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11514 not an integer, it is truncated towards 0.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11515 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11516 To define a condition on a property named @code{timeout}, use the string\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11517 @code{\\timeout} instead.\n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11518 \n\
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11519 In all cases, typing CTRL-C stops program execution immediately.\n\
17483
710309214e0d doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents: 17443
diff changeset
11520 @seealso{waitforbuttonpress, isequal}\n\
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11521 @end deftypefn")
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11522 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11523 if (args.length () > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11524 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11525 double h = args(0).double_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11526
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11527 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11528 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11529 caseless_str pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11530
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11531 unwind_protect frame;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11532
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11533 static uint32_t id_counter = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11534 uint32_t id = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11535
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11536 int max_arg_index = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11537 int timeout_index = -1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11538
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11539 int timeout = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11540
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11541 if (args.length () > 1)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11542 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11543 pname = args(1).string_value ();
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11544
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11545 if (! error_state
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11546 && ! pname.empty () && ! pname.compare ("timeout"))
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11547 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11548 if (pname.compare ("\\timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11549 pname = "timeout";
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11550
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11551 static octave_value wf_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11552
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11553 if (! wf_listener.is_defined ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11554 wf_listener =
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11555 octave_value (new octave_builtin (waitfor_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11556 "waitfor_listener"));
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11557
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11558 max_arg_index++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11559 if (args.length () > 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11560 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11561 if (args(2).is_string ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11562 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11563 caseless_str s = args(2).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11564
19777
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19731
diff changeset
11565 if (s.compare ("timeout"))
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19731
diff changeset
11566 timeout_index = 2;
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19731
diff changeset
11567 else
67f2c76f9f4d Remove unnecessary checking of error_state after is_string validation.
Rik <rik@octave.org>
parents: 19731
diff changeset
11568 max_arg_index++;
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11569 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11570 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11571 max_arg_index++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11572 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11573
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11574 Cell listener (1, max_arg_index >= 2 ? 5 : 4);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11575
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11576 id = id_counter++;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11577 frame.add_fcn (cleanup_waitfor_id, id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11578 waitfor_results[id] = false;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11579
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11580 listener(0) = wf_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11581 listener(1) = octave_uint32 (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11582 listener(2) = h;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11583 listener(3) = pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11584
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11585 if (max_arg_index >= 2)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11586 listener(4) = args(2);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11587
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11588 octave_value ov_listener (listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11589
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11590 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11591
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11592 graphics_handle gh = gh_manager::lookup (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11593
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11594 if (gh.ok ())
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11595 {
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11596 graphics_object go = gh_manager::get_object (gh);
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11597
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11598 if (max_arg_index >= 2
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11599 && compare_property_values (go.get (pname),
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11600 args(2)))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11601 waitfor_results[id] = true;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11602 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11603 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11604
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11605 frame.add_fcn (cleanup_waitfor_postset_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11606 ov_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11607 go.add_property_listener (pname, ov_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11608 POSTSET);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11609 go.add_property_listener (pname, ov_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11610 PERSISTENT);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11611
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11612 if (go.get_properties ()
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11613 .has_dynamic_property (pname))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11614 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11615 static octave_value wf_del_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11616
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11617 if (! wf_del_listener.is_defined ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11618 wf_del_listener =
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11619 octave_value (new octave_builtin
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11620 (waitfor_del_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11621 "waitfor_del_listener"));
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11622
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11623 Cell del_listener (1, 4);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11624
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11625 del_listener(0) = wf_del_listener;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11626 del_listener(1) = octave_uint32 (id);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11627 del_listener(2) = h;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11628 del_listener(3) = pname;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11629
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11630 octave_value ov_del_listener (del_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11631
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11632 frame.add_fcn (cleanup_waitfor_predelete_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11633 ov_del_listener);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11634 go.add_property_listener (pname, ov_del_listener,
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11635 PREDELETE);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11636 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11637 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11638 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11639 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11640 else if (error_state || pname.empty ())
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11641 error ("waitfor: invalid property name, expected a non-empty string value");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11642 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11643
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11644 if (timeout_index < 0 && args.length () > (max_arg_index + 1))
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11645 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11646 caseless_str s = args(max_arg_index + 1).string_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11647
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11648 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11649 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11650 if (s.compare ("timeout"))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11651 timeout_index = max_arg_index + 1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11652 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
11653 error ("waitfor: invalid parameter '%s'", s.c_str ());
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11654 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11655 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14325
diff changeset
11656 error ("waitfor: invalid parameter, expected 'timeout'");
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11657 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11658
20597
bc6daa38ff50 eliminate more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20566
diff changeset
11659 if (timeout_index >= 0)
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11660 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11661 if (args.length () > (timeout_index + 1))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11662 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11663 timeout = static_cast<int>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
11664 (args(timeout_index + 1).scalar_value ());
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11665
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11666 if (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11667 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11668 if (timeout < 1)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11669 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11670 warning ("waitfor: the timeout value must be >= 1, using 1 instead");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11671 timeout = 1;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11672 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11673 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11674 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11675 error ("waitfor: invalid timeout value, expected a value >= 1");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11676 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11677 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11678 error ("waitfor: missing timeout value");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11679 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11680
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11681 // FIXME: There is still a "hole" in the following loop. The code
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11682 // assumes that an object handle is unique, which is a fair
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11683 // assumption, except for figures. If a figure is destroyed
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11684 // then recreated with the same figure ID, within the same
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11685 // run of event hooks, then the figure destruction won't be
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11686 // caught and the loop will not stop. This is an unlikely
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11687 // possibility in practice, though.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11688 //
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11689 // Using deletefcn callback is also unreliable as it could be
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11690 // modified during a callback execution and the waitfor loop
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11691 // would not stop.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11692 //
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11693 // The only "good" implementation would require object
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11694 // listeners, similar to property listeners.
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11695
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11696 time_t start = 0;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11697
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11698 if (timeout > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11699 start = time (0);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11700
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11701 while (! error_state)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11702 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11703 if (true)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11704 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11705 gh_manager::auto_lock guard;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11706
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11707 graphics_handle gh = gh_manager::lookup (h);
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11708
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11709 if (gh.ok ())
13924
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11710 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11711 if (! pname.empty () && waitfor_results[id])
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11712 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11713 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11714 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11715 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11716 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11717
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11718 octave_usleep (100000);
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11719
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11720 OCTAVE_QUIT;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11721
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11722 command_editor::run_event_hooks ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11723
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11724 if (timeout > 0)
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11725 {
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11726 if (start + timeout < time (0))
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11727 break;
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11728 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11729 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11730 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11731 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11732 error ("waitfor: invalid handle value.");
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11733 }
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11734 else
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11735 print_usage ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11736
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11737 return octave_value ();
3b654a0753b1 Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13910
diff changeset
11738 }
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11739
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11740 DEFUN (__zoom__, args, ,
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11741 "-*- texinfo -*-\n\
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11742 @deftypefn {Built-in Function} {} __zoom__ (@var{axes}, @var{mode}, @var{factor})\n\
19829
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19777
diff changeset
11743 @deftypefnx {Built-in Function} {} __zoom__ (@var{axes}, \"out\")\n\
ca7599ae464d doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents: 19777
diff changeset
11744 @deftypefnx {Built-in Function} {} __zoom__ (@var{axes}, \"reset\")\n\
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11745 Undocumented internal function.\n\
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11746 @end deftypefn")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11747 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11748 octave_value retval;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11749
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11750 int nargin = args.length ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11751
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11752 if (nargin != 2 && nargin != 3)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11753 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11754 print_usage ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11755 return retval;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11756 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11757
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11758 double h = args(0).double_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11759
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11760 gh_manager::auto_lock guard;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11761
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11762 graphics_handle handle = gh_manager::lookup (h);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11763
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11764 if (! handle.ok ())
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11765 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11766 error ("__zoom__: invalid handle");
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11767 return retval;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11768 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11769
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11770 graphics_object ax = gh_manager::get_object (handle);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11771
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11772 axes::properties& ax_props =
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11773 dynamic_cast<axes::properties&> (ax.get_properties ());
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11774
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11775 if (nargin == 2)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11776 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11777 std::string opt = args(1).string_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11778
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11779 if (opt == "out" || opt == "reset")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11780 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11781 if (opt == "out")
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11782 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11783 ax_props.clear_zoom_stack ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11784 Vdrawnow_requested = true;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11785 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11786 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11787 ax_props.clear_zoom_stack (false);
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11788 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11789 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11790 else
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11791 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11792 std::string mode = args(1).string_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11793 double factor = args(2).scalar_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11794
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11795 ax_props.zoom (mode, factor);
19969
f0e5c6742716 also request redraw after zooming by a factor (bug #44523)
John W. Eaton <jwe@octave.org>
parents: 19930
diff changeset
11796 Vdrawnow_requested = true;
19697
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11797 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11798
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11799 return retval;
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19693
diff changeset
11800 }
20307
c2206fda3986 graphics.cc: Clean up variable names, line wrapping, comments, etc.
Rik <rik@octave.org>
parents: 20302
diff changeset
11801